minfra-cli 4.2.0 → 4.3.0

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: 3130c38b75f95a1e33c187d6b2026ef0eead6ae92855021ef8c52a3d47aefc28
4
+ data.tar.gz: fe0fbbfee11d712ae34668bd9c5f87696fbf7c08186b409f0e33baf1d24ec449
5
5
  SHA512:
6
- metadata.gz: '086bbbf454c3718828da81615cc774944b1e48bb029c51fde17ed222927f80f22d384367968da7c8256eb4b56d175bfca473dd8d8b1a56a69bf0d1a91e18aa11'
7
- data.tar.gz: 5d34129f956690ef81f21740903e1ffa1bde883358e5deb01342103971293c942b6e18883d8aee14060bfe0ea1baea0399fd19d5edb57fd32f24251cd63bcb2a
6
+ metadata.gz: 5b52d83585031a954c4db6a632322ecb3077936bed7ffa824d125e5ca6fb6341aead5abf1220671e9e17fcd6c7c0f541ea2a39405d541b51b5c1db11d9c8ffd1
7
+ data.tar.gz: 46aaa7a2acfe06a6fc190a21e5c7e0c391a55d503eda59618961b77f334203a1efa47d6c0ea337bdccbf2c22d255021ca1f148e9a23ae9f1863e543fa1748e27
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 4.3.0
2
+ * raising EnvNotFound when the environment is not found
3
+ * instead of patching yaml we're introducing yeaml backend to lookup eyaml files without decryption
4
+ * fixing hiera setup so environment file is loaded first and merged into scope
1
5
  # 4.2.0
2
6
  * --no-rc don't load rc files
3
7
  * 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.0'
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
metadata CHANGED
@@ -1,7 +1,7 @@
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.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Schrammel
@@ -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