minfra-cli 4.1.1 → 4.2.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: ea616e6ead0473faae98389aa80a06a829059445d4e2c04c6860b8ab293f557e
4
- data.tar.gz: 75e9ef0413aeaf293e69c1e19918dc9cb7179bdb97fac7450fdc8b21bfce3565
3
+ metadata.gz: 6d03bf07a73181fc3684097f17a648f741a090faeb2c978d3811595419c16e6e
4
+ data.tar.gz: 2a34f444e718d6dea3b8cc667d015a0d7dcbdcea3a642dccef010d249c8c7295
5
5
  SHA512:
6
- metadata.gz: d68c1105544f8f64cc80d46dd4ee534e1e46ce4827c38dbbfc50e503283185ba4c1a15b1287e9e05584fb6a4b5ab34e72bca0a93c8533472cddaeec869dc170e
7
- data.tar.gz: f8ee54db259d6afed47ea39c1b1f5ba8af5438c9f063607719028e4360f0f45e15aeeeab53d723e153a147cf1c5c6c5d2e73c428b673e0bc0a23fb41e6b3728b
6
+ metadata.gz: '086bbbf454c3718828da81615cc774944b1e48bb029c51fde17ed222927f80f22d384367968da7c8256eb4b56d175bfca473dd8d8b1a56a69bf0d1a91e18aa11'
7
+ data.tar.gz: 5d34129f956690ef81f21740903e1ffa1bde883358e5deb01342103971293c942b6e18883d8aee14060bfe0ea1baea0399fd19d5edb57fd32f24251cd63bcb2a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 4.2.0
2
+ * --no-rc don't load rc files
3
+ * MINFRA_DEBUG_HIERA_LOOKUPS=true also shows the results of the lookup
4
+ * adding some needed hiera patches
1
5
  # 4.1.1
2
6
  * fix: puts statement removed
3
7
  # 4.1.0
@@ -26,7 +30,7 @@
26
30
  * fixing: setup dev
27
31
  * adding: colored errors and warnings
28
32
  * change: wrapping hiera lookup errors of gpg
29
- * adding: HIERA_DEBUG_LOOKUPS=true
33
+ * adding: MINFRA_DEBUG_HIERA_LOOKUPS=true
30
34
  # 2.0.1
31
35
  Refactorings
32
36
  * installing into Kernel only when 'exec' not at 'init' time
@@ -27,9 +27,9 @@ module Minfra
27
27
 
28
28
  init_logger
29
29
 
30
- @logger.debug("Minfra: loglevel: #{@logger.level}, env: #{@config.orch_env}")
30
+ @logger.debug("Minfra: loglevel: #{@logger.level}, env: #{@config.orch_env}, options: #{@options.inspect}")
31
31
 
32
- init_minfrarc
32
+ init_minfrarc unless @options[:norc]
33
33
  init_envs
34
34
 
35
35
  init_hiera
@@ -86,28 +86,23 @@ module Minfra
86
86
 
87
87
  # will parse -e, --argv_file, --
88
88
  def parse_global_options
89
- @options = {}
90
- if (idx = @argv.index('-e'))
91
- @options[:env] = @argv[idx + 1]
92
- @argv.delete_at(idx)
93
- @argv.delete_at(idx)
94
- end
95
-
96
- if (idx = argv.index('--minfra_argv_file'))
97
- @options[:argv_file] = @argv[idx + 1]
98
- @argv.delete_at(idx)
99
- @argv.delete_at(idx)
100
- end
89
+ extract_option('-e', :env, 1)
90
+ extract_option('--minfra_argv_file', :argv_file, 1)
91
+ extract_option('--minfra_path', :base_path, 1)
92
+ extract_option('--no-rc', :norc)
93
+ end
101
94
 
102
- if (idx = argv.index('--minfra_path'))
103
- @options[:base_path] = @argv[idx + 1]
104
- @argv.delete_at(idx)
95
+ def extract_option(name, sym, arity=0)
96
+ if idx = @argv.index(name)
97
+ if arity == 0
98
+ @options[sym] = true
99
+ else
100
+ @options[sym] = @argv[idx + 1]
101
+ @argv.delete_at(idx)
102
+ end
105
103
  @argv.delete_at(idx)
106
104
  end
107
-
108
- @options
109
105
  end
110
-
111
106
  def init_minfrarc
112
107
  # load minfrarc for configs
113
108
  project_minfrarc_path = @config.base_path.join('config', 'minfrarc.rb')
@@ -149,12 +144,12 @@ module Minfra
149
144
  env_path = config.project.dig(:minfra, :hiera, :env_path) || 'environments'
150
145
  root = base_path.join('hiera')
151
146
  root.join('hieradata',env_path).glob('*.eyaml').sort.each do |path|
152
- env_name = path.basename.sub(/(\..+)/,'').to_s
153
- @envs[env_name]=Env.new(
147
+ local_env_name = path.basename.sub(/(\..+)/,'').to_s
148
+ @envs[local_env_name]=Env.new(
154
149
  hiera_root: root,
155
150
  hiera_env_path: env_path,
156
- name: env_name,
157
- hiera_debug_lookups: ENV['MINFRA_DEBUG_HIERA_LOOKUPS'] == 'true',
151
+ name: local_env_name,
152
+ hiera_debug_lookups: ENV['MINFRA_DEBUG_HIERA_LOOKUPS'] == 'true' && env_name == local_env_name,
158
153
  backends: ENV.fetch('MINFRA_HIERA_BACKENDS','').split(',')
159
154
  )
160
155
  end
@@ -31,11 +31,10 @@ module Minfra
31
31
  node_scope = @hiera.lookup('env', {}, scope, nil, :deeper)
32
32
  @scope = scope.merge(node_scope)
33
33
  @debug_lookups = debug_lookups
34
+ debug("hiera: scope -> #{@scope}") if @debug_lookups
34
35
  end
35
36
 
36
37
  def l(value, default = nil)
37
- debug "hiera: #{value}" if @debug_lookups
38
- # debugger if @env_name == 'production-management' && value == 'env.tags'
39
38
  return @cache[value] if @cache.key?(value)
40
39
 
41
40
  values = value.split('.')
@@ -67,6 +66,7 @@ module Minfra
67
66
  result = default if result.nil?
68
67
  result = Hashie::Mash.new(result) if result.is_a?(Hash)
69
68
  @cache[value] = result
69
+ debug "hiera: #{value} -> #{result.inspect}" if @debug_lookups
70
70
  result
71
71
  end
72
72
 
@@ -0,0 +1,9 @@
1
+ require 'highline/import'
2
+ module HieraPatch
3
+ def hiera?
4
+ false
5
+ end
6
+ end
7
+ require 'hiera/backend/eyaml/encryptors/gpg'
8
+
9
+ Hiera::Backend::Eyaml::Encryptors::Gpg.extend(HieraPatch)
@@ -24,7 +24,7 @@ module Minfra
24
24
  end
25
25
  end
26
26
 
27
- def self.read(path, params: {}, fallback: nil)
27
+ def self.read(path, params: {}, helpers: [], fallback: nil)
28
28
  p = Pathname.new(path)
29
29
  if p.exist?
30
30
  content = File.read(path)
@@ -34,7 +34,7 @@ module Minfra
34
34
  content = fallback
35
35
 
36
36
  end
37
- render(content, params)
37
+ render(content, params, helpers: )
38
38
  end
39
39
 
40
40
  def self.render(template, params, helpers: [])
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Minfra
4
4
  module Cli
5
- VERSION = '4.1.1'
5
+ VERSION = '4.2.0'
6
6
  end
7
7
  end
data/lib/minfra/cli.rb CHANGED
@@ -7,6 +7,8 @@ require 'ostruct'
7
7
  require 'hiera'
8
8
 
9
9
  require_relative 'cli/core_ext'
10
+ require_relative 'cli/patches'
11
+
10
12
  require_relative 'cli/errors'
11
13
  require_relative 'cli/logging'
12
14
  require_relative 'cli/templater'
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.1.1
4
+ version: 4.2.0
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-04-10 00:00:00.000000000 Z
11
+ date: 2024-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -210,6 +210,7 @@ files:
210
210
  - lib/minfra/cli/kubectl_runner.rb
211
211
  - lib/minfra/cli/logging.rb
212
212
  - lib/minfra/cli/main_command.rb
213
+ - lib/minfra/cli/patches.rb
213
214
  - lib/minfra/cli/plugin.rb
214
215
  - lib/minfra/cli/plugins.rb
215
216
  - lib/minfra/cli/runner.rb