minfra-cli 4.2.0 → 4.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d03bf07a73181fc3684097f17a648f741a090faeb2c978d3811595419c16e6e
4
- data.tar.gz: 2a34f444e718d6dea3b8cc667d015a0d7dcbdcea3a642dccef010d249c8c7295
3
+ metadata.gz: f391beecc0c949b1d7c1858dc6ccfdcabe22b975fa8e9cd2c610cdd410debc72
4
+ data.tar.gz: 7bf5463712d8846e987f18c2a28a26972278abc60b5b04014573676a5ff4db37
5
5
  SHA512:
6
- metadata.gz: '086bbbf454c3718828da81615cc774944b1e48bb029c51fde17ed222927f80f22d384367968da7c8256eb4b56d175bfca473dd8d8b1a56a69bf0d1a91e18aa11'
7
- data.tar.gz: 5d34129f956690ef81f21740903e1ffa1bde883358e5deb01342103971293c942b6e18883d8aee14060bfe0ea1baea0399fd19d5edb57fd32f24251cd63bcb2a
6
+ metadata.gz: 69e60f521c841f05498f7fb3d63190058826f8f95ffa9c5fbdb8e17607ef2f165491edad8a4e5c0a8459099706872d2299e0664d0f9daa013825aaead7767170
7
+ data.tar.gz: 8b84fb6a9c24b756a090f772cf5faa3733b3f3e10109701791e45997cb104f7f43c63799bc6f3a76a816047ae511701a9b606cc09412cc95e99c2114edd4ef45
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 4.3.1
2
+ * hashie mash hashes for helm values are now type converted correctl
3
+ # 4.3.0
4
+ * raising EnvNotFound when the environment is not found
5
+ * instead of patching yaml we're introducing yeaml backend to lookup eyaml files without decryption
6
+ * fixing hiera setup so environment file is loaded first and merged into scope
1
7
  # 4.2.0
2
8
  * --no-rc don't load rc files
3
9
  * MINFRA_DEBUG_HIERA_LOOKUPS=true also shows the results of the lookup
@@ -1,13 +1,15 @@
1
+ require 'hiera/backend/yaml_backend'
2
+ # require 'debug'
1
3
  class Hiera
2
4
  module Backend
3
- class Yaml_backend
4
-
5
+ class Yeaml_backend < Hiera::Backend::Yaml_backend
5
6
  def lookup(key, scope, order_override, resolution_type, context)
6
7
  answer = nil
7
8
  found = false
8
9
 
9
- Hiera.debug("Looking up #{key} in YAML backend")
10
- Backend.datasourcefiles(:yaml, scope, Config[:yaml][:extension] || "yaml", order_override) do |source, yamlfile|
10
+ Hiera.debug("Looking up #{key} in YEAML backend")
11
+ Backend.datasourcefiles(:yeaml, scope, Config[:yeaml][:extension] || "eyaml", order_override) do |source, yamlfile|
12
+ # debugger if scope['env']== "dev-on-premises" && ['cluster', 'env','lookup_options'].include?(key)
11
13
  data = @cache.read_file(yamlfile, Hash) do |data|
12
14
  YAML.load(data) || {}
13
15
  end
@@ -153,6 +153,10 @@ module Minfra
153
153
  backends: ENV.fetch('MINFRA_HIERA_BACKENDS','').split(',')
154
154
  )
155
155
  end
156
+ unless @envs[@env_name]
157
+ @logger.error("Environment '#{@env_name}' not found")
158
+ raise Errors::EnvNotFound.new(@env_name)
159
+ end
156
160
  @env = @envs[@env_name] # set the current env
157
161
  end
158
162
 
@@ -5,6 +5,8 @@ module Minfra
5
5
  module Errors
6
6
  class ExitError < StandardError
7
7
  end
8
+ class EnvNotFound < StandardError
9
+ end
8
10
  end
9
11
  end
10
12
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'English'
4
+ # require 'debug'
4
5
  module Minfra
5
6
  module Cli
6
7
  class HieraLooker
@@ -12,11 +13,10 @@ module Minfra
12
13
 
13
14
  @hiera = Hiera.new(config: @root.join('hiera.yaml').to_s)
14
15
  # now that hiera has loaded the backends let's patch 'em
15
- require 'minfra/cli/hiera_yaml_backend_patch' if defined?(Hiera::Backend::Yaml_backend)
16
16
 
17
17
  Hiera.logger = :noop
18
18
  if backends && !backends.empty?
19
- @hiera.config[:backends] = backends
19
+ @hiera.config[:backends] = backends
20
20
  Hiera::Config.load_backends
21
21
  end
22
22
 
@@ -25,11 +25,11 @@ module Minfra
25
25
  raise("unknown environment #{@env_name}, I expect a file at #{hiera_main_path}") unless hiera_main_path.exist?
26
26
 
27
27
  scope = { 'hieraroot' => @root.to_s, 'env' => @env_name }
28
+ # we have to do this first as the hierarchy definitions only are valid if with the env variables injected
29
+ node_scope = @hiera.lookup('env', {}, scope, nil, :priority)
30
+ @scope = scope.merge(node_scope)
28
31
 
29
32
  @special_lookups = @hiera.lookup('lookup_options', {}, scope, nil, :priority)
30
-
31
- node_scope = @hiera.lookup('env', {}, scope, nil, :deeper)
32
- @scope = scope.merge(node_scope)
33
33
  @debug_lookups = debug_lookups
34
34
  debug("hiera: scope -> #{@scope}") if @debug_lookups
35
35
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Minfra
4
4
  module Cli
5
- VERSION = '4.2.0'
5
+ VERSION = '4.3.1'
6
6
  end
7
7
  end
data/lib/minfra/cli.rb CHANGED
@@ -51,6 +51,7 @@ module Minfra
51
51
  end
52
52
 
53
53
  def self.exec(argv)
54
+
54
55
  init(argv) unless init?
55
56
  cli.install
56
57
  cli.run
@@ -257,6 +257,8 @@ module Orchparty
257
257
  { variable => value.to_s}.to_yaml[4..-1]
258
258
  when yml.match(/!ruby\/array:Hashie::Array/)
259
259
  { variable => value.to_a}.to_yaml[4..-1]
260
+ when yml.match(/!ruby\/hash:Hashie::Mash/)
261
+ { variable => value.to_h}.to_yaml[4..-1]
260
262
  else
261
263
  yml
262
264
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minfra-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0
4
+ version: 4.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Schrammel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-15 00:00:00.000000000 Z
11
+ date: 2024-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -182,6 +182,7 @@ files:
182
182
  - exe/minfra
183
183
  - lib/deep_merge.rb
184
184
  - lib/hash.rb
185
+ - lib/hiera/backend/yeaml_backend.rb
185
186
  - lib/minfra/cli.rb
186
187
  - lib/minfra/cli/ask.rb
187
188
  - lib/minfra/cli/cli_starter.rb
@@ -205,7 +206,6 @@ files:
205
206
  - lib/minfra/cli/errors.rb
206
207
  - lib/minfra/cli/helm_runner.rb
207
208
  - lib/minfra/cli/hiera_looker.rb
208
- - lib/minfra/cli/hiera_yaml_backend_patch.rb
209
209
  - lib/minfra/cli/hook.rb
210
210
  - lib/minfra/cli/kubectl_runner.rb
211
211
  - lib/minfra/cli/logging.rb