class Hako::EnvProviders::Gcredstash
Public Class Methods
new(root_path, options)
click to toggle source
@param [Pathname] root_path @param [Hash<String, Object>] options
# File lib/hako/env_providers/gcredstash.rb, line 8 def initialize(root_path, options) unless options['app'] validation_error!('app must be set') end @app = options['app'] @env = options['env'] end
Public Instance Methods
ask(variables)
click to toggle source
@param [Array<String>] variables @return [Hash<String, String>]
# File lib/hako/env_providers/gcredstash.rb, line 18 def ask(variables) env = {} read_from_gcredstash do |key, val| if variables.include?(key) env[key] = val end end env end
Private Instance Methods
read_from_gcredstash(&block)
click to toggle source
@yieldparam [String] key @yieldparam [String] val @return [nil]
# File lib/hako/env_providers/gcredstash.rb, line 33 def read_from_gcredstash(&block) base_key = @env.nil? ? @app : "#{@app}.#{@env}." cred_value = `gcredstash list | grep #{base_key} | awk '{print $1}'`.strip cred_value.each_line.each do |key| val = `gcredstash get #{key}` block.call(key, val) end end