Sha256: 8563db7aa6e070f6be30cc5054c1d6b4e1a3371a70d252cf459b853d03b98cad
Contents?: true
Size: 1.89 KB
Versions: 1
Compression:
Stored size: 1.89 KB
Contents
# encoding: utf-8 # # A class for the secrets.json file # module LeapCli; module Config class Secrets < Object attr_reader :node_list def initialize(manager=nil) super(manager) @discovered_keys = {} end # we can't use fetch() or get(), since those already have special meanings def retrieve(key, environment) environment ||= 'default' self.fetch(environment, {})[key.to_s] end def set(*args, &block) if block_given? set_with_block(*args, &block) else set_without_block(*args) end end def set_without_block(key, value, environment) set_with_block(key, environment) {value} end def set_with_block(key, environment, &block) environment ||= 'default' key = key.to_s @discovered_keys[environment] ||= {} @discovered_keys[environment][key] = true self[environment] ||= {} self[environment][key] ||= yield end # # if clean is true, then only secrets that have been discovered # during this run will be exported. # # if environment is also pinned, then we will clean those secrets # just for that environment. # # the clean argument should only be used when all nodes have # been processed, otherwise secrets that are actually in use will # get mistakenly removed. # def dump_json(clean=false) pinned_env = LeapCli.leapfile.environment if clean self.each_key do |environment| if pinned_env.nil? || pinned_env == environment self[environment].each_key do |key| unless @discovered_keys[environment] && @discovered_keys[environment][key] self[environment].delete(key) end end if self[environment].empty? self.delete(environment) end end end end super() end end end; end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
leap_cli-1.7.4 | lib/leap_cli/config/secrets.rb |