module Muchkeys::CLI::MuchkeysExecutor
Public Instance Methods
check(app_name)
click to toggle source
# File lib/muchkeys/cli.rb, line 113 def check(app_name) Muchkeys.configure { |c| c.application_name = app_name } Muchkeys::ApplicationClient.new(Muchkeys.config).verify_keys(*Muchkeys.env_keys) "All keys present and accounted for." end
decrypt(consul_key, public_key, private_key)
click to toggle source
# File lib/muchkeys/cli.rb, line 83 def decrypt(consul_key, public_key, private_key) Muchkeys::ApplicationClient.new.fetch_key(consul_key, public_key: public_key, private_key: private_key) end
delete(consul_key)
click to toggle source
# File lib/muchkeys/cli.rb, line 132 def delete(consul_key) app = Muchkeys::ApplicationClient.new app.allow_unsafe_operation do app.delete_key(consul_key) end "Key #{consul_key} deleted" end
encrypt(file, public_key)
click to toggle source
# File lib/muchkeys/cli.rb, line 78 def encrypt(file, public_key) string_to_encrypt = File.read(file) Muchkeys::ApplicationClient.new.secret_adapter.encrypt_string(string_to_encrypt.chomp, public_key) end
fetch(consul_key)
click to toggle source
# File lib/muchkeys/cli.rb, line 141 def fetch(consul_key) Muchkeys::ApplicationClient.new.fetch_key(consul_key) end
list(app_name)
click to toggle source
# File lib/muchkeys/cli.rb, line 106 def list(app_name) Muchkeys.configure { |c| c.application_name = app_name } keys = Muchkeys::ApplicationClient.new(Muchkeys.config).known_keys keys.join("\n") end
store(consul_key, data, public_key: nil, private_key: nil)
click to toggle source
# File lib/muchkeys/cli.rb, line 87 def store(consul_key, data, public_key: nil, private_key: nil) Muchkeys.configure { |c| c.public_key = public_key; c.private_key = private_key } app = Muchkeys::ApplicationClient.new(Muchkeys.config) if data == "-" data = $stdin.read end app.allow_unsafe_operation do if public_key && private_key app.set_key(consul_key, data, type: :secret) "Secret '#{data}' stored in #{consul_key}" else app.set_key(consul_key, data) "'#{data}' stored in #{consul_key}" end end end
wipeout(app_name: nil)
click to toggle source
# File lib/muchkeys/cli.rb, line 120 def wipeout(app_name: nil) Muchkeys.configure { |c| c.application_name = app_name } app = Muchkeys::ApplicationClient.new app.allow_unsafe_operation do app.each_path do |path| app.delete_key(path) end end "Everything deleted!" end