Class: Kubert::Environment
- Inherits:
-
Object
- Object
- Kubert::Environment
- Defined in:
- lib/kubert/environment.rb
Constant Summary collapse
- PEEK_LENGTH =
4
Class Method Summary collapse
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(key, value, raw_options) ⇒ Environment
constructor
A new instance of Environment.
- #set ⇒ Object
Constructor Details
#initialize(key, value, raw_options) ⇒ Environment
Returns a new instance of Environment.
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/kubert/environment.rb', line 16 def initialize(key, value, ) @key = key @value = value = .with_indifferent_access abort("ERROR: Cannot specify env set as both new_secret and new_config") if [:new_config] && [:new_secret] Kubert.ky_configuration() # memoizes and avoids passing to FileAccess @config_data = FileAccess.new(:config, yaml_key) @secret_data = FileAccess.new(:secret, yaml_key) return if print_all? @create_mode = ([:new_config] || [:new_secret])&.to_sym end |
Class Method Details
.get(key, options) ⇒ Object
4 5 6 |
# File 'lib/kubert/environment.rb', line 4 def self.get(key, ) new(key, nil, ).get end |
.set(key, value, options) ⇒ Object
8 9 10 |
# File 'lib/kubert/environment.rb', line 8 def self.set(key, value, ) new(key, value, ).set end |
.unset(key, options) ⇒ Object
12 13 14 |
# File 'lib/kubert/environment.rb', line 12 def self.unset(key, ) new(key, nil, ).set end |
Instance Method Details
#get ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/kubert/environment.rb', line 38 def get return get_all if print_all? case total_found when 0 puts "#{yaml_key} not found in configmap or secrets" when 1 puts existing_value else puts "ERROR! multiple entries found for key: config - #{config_data.found}, secret - #{secret_data.found}" end end |
#set ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/kubert/environment.rb', line 28 def set if create_mode abort("ERROR: #{key} exists but #{create_mode} flag set! Call without flag to update existing value") unless total_found == 0 create else report_unchanged if existing_value == value update end end |