Module: Nucleus::Adapters::V1::OpenshiftV2::Vars

Included in:
Nucleus::Adapters::V1::OpenshiftV2
Defined in:
lib/nucleus/adapters/v1/openshift_v2/vars.rb

Instance Method Summary collapse

Instance Method Details

#create_env_var(application_id, env_var) ⇒ Object



19
20
21
22
# File 'lib/nucleus/adapters/v1/openshift_v2/vars.rb', line 19

def create_env_var(application_id, env_var)
  to_nucleus_var(post("/application/#{app_id_by_name(application_id)}/environment-variables",
                      body: { name: env_var[:key], value: env_var[:value] }).body[:data])
end

#delete_env_var(application_id, env_var_key) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/nucleus/adapters/v1/openshift_v2/vars.rb', line 31

def delete_env_var(application_id, env_var_key)
  id = app_id_by_name(application_id)
  # Openshift returns 204 even if the key did not exist
  if get("/application/#{id}/environment-variable/#{env_var_key}", expects: [200, 404]).status == 404
    fail Errors::AdapterResourceNotFoundError, "Env. var key '#{env_var_key}' does not exist"
  end
  delete("/application/#{id}/environment-variable/#{env_var_key}")
end

#env_var(application_id, env_var_key) ⇒ Object

See Also:



13
14
15
16
# File 'lib/nucleus/adapters/v1/openshift_v2/vars.rb', line 13

def env_var(application_id, env_var_key)
  response = get("/application/#{app_id_by_name(application_id)}/environment-variable/#{env_var_key}")
  to_nucleus_var(response.body[:data])
end

#env_vars(application_id) ⇒ Object

See Also:



7
8
9
10
# File 'lib/nucleus/adapters/v1/openshift_v2/vars.rb', line 7

def env_vars(application_id)
  all_vars = get("/application/#{app_id_by_name(application_id)}/environment-variables").body[:data]
  all_vars.collect { |var| to_nucleus_var(var) }
end

#update_env_var(application_id, env_var_key, env_var) ⇒ Object



25
26
27
28
# File 'lib/nucleus/adapters/v1/openshift_v2/vars.rb', line 25

def update_env_var(application_id, env_var_key, env_var)
  to_nucleus_var(put("/application/#{app_id_by_name(application_id)}/environment-variable/#{env_var_key}",
                     body: { value: env_var[:value] }).body[:data])
end