module Nucleus::Adapters::V1::OpenshiftV2::Vars

Public Instance Methods

create_env_var(application_id, env_var) click to toggle source

@see Stub#create_env_var

# 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) click to toggle source

@see Stub#delete_env_var

# 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
    raise 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) click to toggle source

@see Stub#env_var

# 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) click to toggle source

@see Stub#env_vars

# 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) click to toggle source

@see Stub#update_env_var

# 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

Private Instance Methods

to_nucleus_var(var) click to toggle source
# File lib/nucleus/adapters/v1/openshift_v2/vars.rb, line 42
def to_nucleus_var(var)
  { id: var[:name], key: var[:name], value: var[:value] }
end