Skip to content

Commit

Permalink
move client out of ctor to fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wr0ngway committed Sep 6, 2019
1 parent b05f189 commit b9d8c02
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/simplygenius/atmos/providers/aws/ssm_secret_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ def initialize(provider)
@provider = provider
@path_prefix = "#{Atmos.config[:secret][:prefix]}"
@encrypt = Atmos.config[:secret][:encrypt]
@client = ::Aws::SSM::Client.new
end

def set(key, value, force: false)
Expand All @@ -29,21 +28,21 @@ def set(key, value, force: false)
param_value = value.join(",")
end

@client.put_parameter(name: param_name, value: param_value, type: param_type, overwrite: force)
client.put_parameter(name: param_name, value: param_value, type: param_type, overwrite: force)
end

def get(key)
resp = @client.get_parameter(name: param_name(key), with_decryption: @encrypt)
resp = client.get_parameter(name: param_name(key), with_decryption: @encrypt)
resp.parameter.value
end

def delete(key)
@client.delete_parameter(name: param_name(key))
client.delete_parameter(name: param_name(key))
end

def to_h
result = {}
resp = @client.get_parameters_by_path(path: param_name(""), recursive: true, with_decryption: @encrypt)
resp = client.get_parameters_by_path(path: param_name(""), recursive: true, with_decryption: @encrypt)
resp.parameters.each do |p|
key = p.name.gsub(/^#{param_name("")}/, '')
result[key] = p.value
Expand All @@ -60,6 +59,9 @@ def param_name(key)
param_name
end

def client
@client ||= ::Aws::SSM::Client.new
end
end

end
Expand Down

0 comments on commit b9d8c02

Please sign in to comment.