minfra-cli 4.1.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 559888088dd171a754ae0ccab6b6e8bf9ff0940e5cea2a64da90c83714250e1f
4
- data.tar.gz: 212ed7b65798feda2b14a408d2f8066e73b21736ade7eed3a5fe5fafe50adbc6
3
+ metadata.gz: 6d03bf07a73181fc3684097f17a648f741a090faeb2c978d3811595419c16e6e
4
+ data.tar.gz: 2a34f444e718d6dea3b8cc667d015a0d7dcbdcea3a642dccef010d249c8c7295
5
5
  SHA512:
6
- metadata.gz: 68ae0b701280177906cd79fbbebcd18b53380abb023f23ecb94c40b410ca0be47b6b2ffd2a8bad4e11b5f6e1b8430ff6aa4c3f2f1cde92e4e15d222fef001fc8
7
- data.tar.gz: b47a78a9681d51bbde838d6d9527a5dfb7eea37f37d5cdcf78d28ab037e2bdfc85aca43ae72c3ddae3b1087ab82930f1d7d4097262f0c940ad79693995bed243
6
+ metadata.gz: '086bbbf454c3718828da81615cc774944b1e48bb029c51fde17ed222927f80f22d384367968da7c8256eb4b56d175bfca473dd8d8b1a56a69bf0d1a91e18aa11'
7
+ data.tar.gz: 5d34129f956690ef81f21740903e1ffa1bde883358e5deb01342103971293c942b6e18883d8aee14060bfe0ea1baea0399fd19d5edb57fd32f24251cd63bcb2a
data/CHANGELOG.md CHANGED
@@ -1,10 +1,16 @@
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
5
+ # 4.1.1
6
+ * fix: puts statement removed
1
7
  # 4.1.0
2
- * Minfra::Cli::Templater can now user helper modules
8
+ * improvement: Minfra::Cli::Templater can now user helper modules
3
9
  # 4.0.0
4
- * in apply mode of secrets we prefix the name with the chart name
10
+ * feature: in apply mode of secrets we prefix the name with the chart name
5
11
  # 3.1.0
6
- * overriding backends via MINFRA_HIERA_BACKENDS
7
- * overriding Yaml Backend to allow :extension: setting
12
+ * improvement: overriding backends via MINFRA_HIERA_BACKENDS
13
+ * improvement: overriding Yaml Backend to allow :extension: setting
8
14
  # 3.0.2
9
15
  * removing complex dns manipulation and hardcoding google servers
10
16
  # 3.0.1
@@ -24,7 +30,7 @@
24
30
  * fixing: setup dev
25
31
  * adding: colored errors and warnings
26
32
  * change: wrapping hiera lookup errors of gpg
27
- * adding: HIERA_DEBUG_LOOKUPS=true
33
+ * adding: MINFRA_DEBUG_HIERA_LOOKUPS=true
28
34
  # 2.0.1
29
35
  Refactorings
30
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)
@@ -20,12 +20,11 @@ module Minfra
20
20
  helpers.each do |helper|
21
21
  b.extend helper
22
22
  end
23
- p b._binding.receiver
24
23
  result(b._binding)
25
24
  end
26
25
  end
27
26
 
28
- def self.read(path, params: {}, fallback: nil)
27
+ def self.read(path, params: {}, helpers: [], fallback: nil)
29
28
  p = Pathname.new(path)
30
29
  if p.exist?
31
30
  content = File.read(path)
@@ -35,7 +34,7 @@ module Minfra
35
34
  content = fallback
36
35
 
37
36
  end
38
- render(content, params)
37
+ render(content, params, helpers: )
39
38
  end
40
39
 
41
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.0'
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.0
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-09 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