Class: HelmWrapper::Shared::Config
- Inherits:
-
Object
- Object
- HelmWrapper::Shared::Config
- Includes:
- Logging
- Defined in:
- lib/helm-wrapper/shared/config.rb
Constant Summary collapse
- @@config_exts =
[ "", ".yaml", ".yml" ]
Instance Attribute Summary collapse
-
#atomic ⇒ Object
readonly
Returns the value of attribute atomic.
-
#auths ⇒ Object
readonly
Returns the value of attribute auths.
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#chart ⇒ Object
readonly
Returns the value of attribute chart.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#release ⇒ Object
readonly
Returns the value of attribute release.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
-
#variables ⇒ Object
readonly
Returns the value of attribute variables.
-
#wait ⇒ Object
readonly
Returns the value of attribute wait.
Instance Method Summary collapse
-
#initialize(chart:, options:) ⇒ Config
constructor
A new instance of Config.
Methods included from Logging
configure_logger_for, logger_for
Constructor Details
#initialize(chart:, options:) ⇒ Config
Returns a new instance of Config.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/helm-wrapper/shared/config.rb', line 41 def initialize(chart:, options:) logger.fatal("Configuration atomic mode must be a boolean!") unless [ true, false ].include?(["atomic"]) @atomic = ["atomic"] logger.fatal("Configuration base path must be a string!") unless ["base"].kind_of?(String) logger.fatal("Configuration base path must not be blank!") if ["base"].strip.empty? @base = ["base"] logger.fatal("Configuration name must be a string!") unless ["name"].kind_of?(String) logger.fatal("Configuration name must not be blank!") if ["name"].strip.empty? @name = ["name"] logger.fatal("Configuration release name must be a string!") unless ["release"].kind_of?(String) logger.fatal("Configuration release name must not be blank!") if ["release"].strip.empty? @release = ["release"] logger.fatal("Configuration wait timeout must be a string!") unless ["timeout"].kind_of?(String) logger.fatal("Configuration wait timeout must not be blank!") if ["timeout"].strip.empty? @timeout = ["timeout"] logger.fatal("Configuration authenticator for Azure enabled must be a boolean!") unless [ true, false ].include?(["auth-azure"]) auth_azure = ["auth-azure"] logger.fatal("Configuration authenticator for Azure options must be a hash!") unless ["auth-azure-options"].kind_of?(Hash) = ["auth-azure-options"] logger.fatal("Configuration destination namespace must be a string!") unless ["namespace"].kind_of?(String) logger.fatal("Configuration destination namespace must not be blank!") if ["namespace"].strip.empty? namespace = ["namespace"] logger.fatal("Configuration wait mode must be a boolean!") unless [ true, false ].include?(["wait"]) wait = ["wait"] @chart = chart @path = ::HelmWrapper.find(base: @base, name: @name, exts: @@config_exts, description: "Configuration") @wait = (not @atomic) and wait yaml = YAML.load(File.read(@path)) logger.fatal("Invalid YAML in configuration file: #{@path}") unless yaml.kind_of?(Hash) identifers = yaml.key?("identifiers") ? yaml["identifiers"] : Hash.new @variables = HelmWrapper::Shared::Variables.new(chart: @chart.name, config: @name, namespace: namespace, release: @release, identifiers: identifers) @namespace = @variables.core[:namespace] if yaml.key?("globals") then logger.fatal("Key 'globals' is not a hash in configuration file: #{@path}") unless yaml["globals"].kind_of?(Hash) globals = yaml["globals"] @variables.add_variables(variables: globals["variables"]) if globals.key?("variables") end if yaml.key?("helm") then logger.fatal("Key 'helm' is not a hash in configuration file: #{@path}") unless yaml["helm"].kind_of?(Hash) helm = yaml["helm"] [ "globals", @release ].each do |extra| if helm.key?(extra) then logger.fatal("Key '#{extra}' under 'helm' is not a hash in configuration file: #{@path}") unless helm[extra].kind_of?(Hash) section = helm[extra] @variables.add_variables(variables: section["variables"]) if section.key?("variables") @variables.add_files(base: @base, files: section["files"]) if section.key?("files") end end end @auths = Array.new @auths.append(HelmWrapper::Shared::Auths::Azure.new(options: , variables: @variables)) if auth_azure end |
Instance Attribute Details
#atomic ⇒ Object (readonly)
Returns the value of attribute atomic.
27 28 29 |
# File 'lib/helm-wrapper/shared/config.rb', line 27 def atomic @atomic end |
#auths ⇒ Object (readonly)
Returns the value of attribute auths.
28 29 30 |
# File 'lib/helm-wrapper/shared/config.rb', line 28 def auths @auths end |
#base ⇒ Object (readonly)
Returns the value of attribute base.
29 30 31 |
# File 'lib/helm-wrapper/shared/config.rb', line 29 def base @base end |
#chart ⇒ Object (readonly)
Returns the value of attribute chart.
30 31 32 |
# File 'lib/helm-wrapper/shared/config.rb', line 30 def chart @chart end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
31 32 33 |
# File 'lib/helm-wrapper/shared/config.rb', line 31 def name @name end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
32 33 34 |
# File 'lib/helm-wrapper/shared/config.rb', line 32 def namespace @namespace end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
34 35 36 |
# File 'lib/helm-wrapper/shared/config.rb', line 34 def path @path end |
#release ⇒ Object (readonly)
Returns the value of attribute release.
33 34 35 |
# File 'lib/helm-wrapper/shared/config.rb', line 33 def release @release end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
35 36 37 |
# File 'lib/helm-wrapper/shared/config.rb', line 35 def timeout @timeout end |
#variables ⇒ Object (readonly)
Returns the value of attribute variables.
36 37 38 |
# File 'lib/helm-wrapper/shared/config.rb', line 36 def variables @variables end |
#wait ⇒ Object (readonly)
Returns the value of attribute wait.
37 38 39 |
# File 'lib/helm-wrapper/shared/config.rb', line 37 def wait @wait end |