minfra-cli 1.13.3 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +1 -2
  3. data/.rubocop.yml +31 -0
  4. data/CHANGELOG.md +15 -0
  5. data/Gemfile.lock +1 -1
  6. data/README.md +13 -1
  7. data/exe/minfra +1 -3
  8. data/lib/deep_merge.rb +35 -36
  9. data/lib/hash.rb +19 -18
  10. data/lib/minfra/cli/ask.rb +18 -16
  11. data/lib/minfra/cli/cli_starter.rb +173 -0
  12. data/lib/minfra/cli/command.rb +4 -1
  13. data/lib/minfra/cli/commands/dev.rb +26 -15
  14. data/lib/minfra/cli/commands/kube.rb +97 -88
  15. data/lib/minfra/cli/commands/plugin.rb +9 -8
  16. data/lib/minfra/cli/commands/project/branch.rb +7 -5
  17. data/lib/minfra/cli/commands/project/tag.rb +7 -6
  18. data/lib/minfra/cli/commands/project.rb +40 -40
  19. data/lib/minfra/cli/commands/setup.rb +18 -18
  20. data/lib/minfra/cli/commands/stack/app_template.rb +10 -13
  21. data/lib/minfra/cli/commands/stack/client_template.rb +10 -8
  22. data/lib/minfra/cli/commands/stack/kube_stack_template.rb +49 -51
  23. data/lib/minfra/cli/commands/stack.rb +55 -46
  24. data/lib/minfra/cli/commands/tag.rb +9 -8
  25. data/lib/minfra/cli/common.rb +7 -10
  26. data/lib/minfra/cli/config.rb +36 -63
  27. data/lib/minfra/cli/core_ext.rb +7 -0
  28. data/lib/minfra/cli/document.rb +5 -2
  29. data/lib/minfra/cli/env.rb +24 -0
  30. data/lib/minfra/cli/errors.rb +10 -0
  31. data/lib/minfra/cli/helm_runner.rb +3 -1
  32. data/lib/minfra/cli/hiera_looker.rb +54 -0
  33. data/lib/minfra/cli/hook.rb +36 -24
  34. data/lib/minfra/cli/kubectl_runner.rb +3 -1
  35. data/lib/minfra/cli/logging.rb +5 -1
  36. data/lib/minfra/cli/main_command.rb +2 -1
  37. data/lib/minfra/cli/plugin.rb +74 -0
  38. data/lib/minfra/cli/plugins.rb +18 -87
  39. data/lib/minfra/cli/runner.rb +23 -23
  40. data/lib/minfra/cli/templater.rb +17 -17
  41. data/lib/minfra/cli/version.rb +3 -1
  42. data/lib/minfra/cli.rb +20 -114
  43. data/lib/orchparty/ast.rb +13 -14
  44. data/lib/orchparty/cli.rb +35 -33
  45. data/lib/orchparty/context.rb +15 -15
  46. data/lib/orchparty/dsl_parser.rb +7 -11
  47. data/lib/orchparty/dsl_parser_kubernetes.rb +46 -56
  48. data/lib/orchparty/plugin.rb +10 -9
  49. data/lib/orchparty/plugins/env.rb +14 -13
  50. data/lib/orchparty/transformations/all.rb +3 -1
  51. data/lib/orchparty/transformations/mixin.rb +24 -24
  52. data/lib/orchparty/transformations/remove_internal.rb +3 -2
  53. data/lib/orchparty/transformations/sort.rb +2 -1
  54. data/lib/orchparty/transformations/variable.rb +6 -5
  55. data/lib/orchparty/transformations.rb +2 -0
  56. data/lib/orchparty/version.rb +3 -1
  57. data/lib/orchparty.rb +14 -14
  58. metadata +9 -2
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'pathname'
2
4
 
3
5
  module Minfra
@@ -7,29 +9,29 @@ module Minfra
7
9
  include ::Minfra::Cli::Logging
8
10
 
9
11
  attr_reader :content, :path
12
+
10
13
  def initialize(stack_name, client_name, config)
11
14
  @stack_name = stack_name
12
15
  @client_name = client_name
13
16
  @config = OpenStruct.new
14
- @path = config.stacks_path.join(stack_name, "fxnet-client-#{client_name}-#{config.orch_env}.json")
17
+ @path = config.stacks_path.join(stack_name, "fxnet-client-#{client_name}-#{config.orch_env}.json")
15
18
  read
16
19
  end
17
20
 
18
21
  def exist?
19
22
  @path.exist?
20
23
  end
21
-
24
+
22
25
  def read
23
- if exist?
24
- t=Minfra::Cli::Templater.new(File.read(@path))
25
- @content = Hashie::Mash.new(JSON.parse(t.render({})))
26
- end
26
+ return unless exist?
27
+
28
+ t = Minfra::Cli::Templater.new(File.read(@path))
29
+ @content = Hashie::Mash.new(JSON.parse(t.render({})))
27
30
  end
28
31
 
29
32
  def to_s
30
- JSON.generate(@content, {indent: " ", object_nl: "\n"})
33
+ JSON.generate(@content, { indent: ' ', object_nl: "\n" })
31
34
  end
32
-
33
35
  end
34
36
  end
35
37
  end
@@ -1,75 +1,73 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'pathname'
2
4
  module Minfra
3
5
  module Cli
4
6
  module StackM
5
7
  class KubeStackTemplate
6
- include ::Minfra::Cli::Logging
8
+ include ::Minfra::Cli::Logging
7
9
 
8
- attr_reader :name, :env, :deployment, :config_path
9
- def initialize(name, config, deployment: '', cluster:)
10
- @name = name
11
- @config_path = config.stacks_path.join(name)
12
- @errors = []
13
- @config = config
14
- @env = config.orch_env
15
- @deployment = deployment.freeze
16
- @cluster = cluster.freeze || l!("cluster").id
17
- @result_path = config.status_path.join('stacks', @cluster, name)
18
- debug "Stack selection: #{@name}, #{@config_path}, #{@cluster}, #{@result_path}"
19
- end
10
+ attr_reader :name, :env, :deployment, :config_path
20
11
 
21
- def cluster_name
22
- @cluster
23
- end
12
+ def initialize(name, config, cluster:, deployment: '')
13
+ @name = name
14
+ @config_path = config.stacks_path.join(name)
15
+ @errors = []
16
+ @config = config
17
+ @env = config.orch_env
18
+ @deployment = deployment.freeze
19
+ @cluster = cluster.freeze || l!('cluster').id
20
+ @result_path = config.status_path.join('stacks', @cluster, name)
21
+ debug "Stack selection: #{@name}, #{@config_path}, #{@cluster}, #{@result_path}"
22
+ end
24
23
 
25
- def mixin_env
26
- "#{@env}#{dashed(@deployment)}"
27
- end
24
+ def cluster_name
25
+ @cluster
26
+ end
28
27
 
29
- def valid?
30
- unless @config_path.exist?
31
- @errors << "stack path #{@config_path} doesn't exist"
28
+ def mixin_env
29
+ "#{@env}#{dashed(@deployment)}"
32
30
  end
33
31
 
34
- unless stack_rb_path.exist?
35
- @errors << "stack.rb file #{stack_rb_path} doesn't exist"
32
+ def valid?
33
+ @errors << "stack path #{@config_path} doesn't exist" unless @config_path.exist?
34
+
35
+ @errors << "stack.rb file #{stack_rb_path} doesn't exist" unless stack_rb_path.exist?
36
+ @errors.empty?
36
37
  end
37
- @errors.empty?
38
- end
39
38
 
40
- def stack_rb_path
41
- config_path.join('stack.rb')
42
- end
39
+ def stack_rb_path
40
+ config_path.join('stack.rb')
41
+ end
43
42
 
44
- def compose_path(blank: false)
45
- if blank
46
- release_path.join("compose.yaml")
47
- elsif @cluster
48
- release_path.join("compose#{dashed(@cluster)}.yaml")
49
- else
50
- release_path.join("compose#{dashed(@env)}#{dashed(@deployment)}.yaml")
43
+ def compose_path(blank: false)
44
+ if blank
45
+ release_path.join('compose.yaml')
46
+ elsif @cluster
47
+ release_path.join("compose#{dashed(@cluster)}.yaml")
48
+ else
49
+ release_path.join("compose#{dashed(@env)}#{dashed(@deployment)}.yaml")
50
+ end
51
51
  end
52
- end
53
52
 
54
- def error_message
55
- @errors.join(";\n")
56
- end
53
+ def error_message
54
+ @errors.join(";\n")
55
+ end
57
56
 
58
- def release_path
59
- @result_path
60
- end
57
+ def release_path
58
+ @result_path
59
+ end
61
60
 
61
+ def check_plan
62
+ []
63
+ end
62
64
 
63
- def check_plan
64
- errors = []
65
- errors
66
- end
65
+ private
67
66
 
68
- private
69
- def dashed(sth,set=nil)
70
- sth.nil? || sth.empty? ? '' : "-#{set||sth}"
67
+ def dashed(sth, set = nil)
68
+ sth.nil? || sth.empty? ? '' : "-#{set || sth}"
69
+ end
71
70
  end
72
71
  end
73
72
  end
74
73
  end
75
- end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'fileutils'
2
4
  require_relative 'stack/app_template'
3
5
  require_relative 'stack/client_template'
@@ -6,24 +8,23 @@ require_relative 'stack/kube_stack_template'
6
8
  module Minfra
7
9
  module Cli
8
10
  class Stack < Command
9
-
10
- desc "describe","get information about a stack"
11
+ desc 'describe', 'get information about a stack'
11
12
  option :environment, aliases: ['-e']
12
13
  def describe
13
- pp minfra_config.describe(options["environment"])
14
+ pp minfra_config.describe(options['environment'])
14
15
  end
15
16
 
16
- desc "dashboard <stack_name>", "openening a dashboard for a stack"
17
+ desc 'dashboard <stack_name>', 'openening a dashboard for a stack'
17
18
  option :environment, aliases: ['-e']
18
19
  option :deployment, aliases: ['-d']
19
20
  option :cluster, aliases: ['-c']
20
- def dashboard(stack_name='all')
21
+ def dashboard(stack_name = 'all')
21
22
  kube.dashboard(stack_name, options[:environment], options[:deployment], options[:cluster])
22
23
  end
23
24
 
24
- desc "deploy <stack_name> '<message> (optional)'", "deploy a complete stack"
25
+ desc "deploy <stack_name> '<message> (optional)'", 'deploy a complete stack'
25
26
  option :environment, aliases: ['-e']
26
- # option :deployment, aliases: ['-d']
27
+ # option :deployment, aliases: ['-d']
27
28
  option :cluster, aliases: ['-c']
28
29
  option :dev, type: :boolean # currently, about to be changed
29
30
  option :explain, type: :boolean
@@ -31,45 +32,52 @@ module Minfra
31
32
  option :test, type: :boolean
32
33
  option :opts
33
34
  option :force, type: :boolean
34
- def deploy(stack_name, message='')
35
- kube.deploy(stack_name, message)
35
+ def deploy(stack_name, message = '')
36
+ stacks = l('env.roles') || l('env.stacks') || []
37
+ default_stacks = minfra_config.project.default_stacks || []
38
+ stacks = stacks.concat(default_stacks)
39
+ if stacks.include?(stack_name) || options[:force] || options[:test]
40
+ kube.deploy(stack_name, message)
41
+ else
42
+ exit_error("project:default_stacks or hiera:env.roles or hiera:env.stacks has to include '#{stack_name}' or use --force or --test")
43
+ end
36
44
  end
37
45
 
38
- desc "rollback <extraargs>", "rollback a deployment"
46
+ desc 'rollback <extraargs>', 'rollback a deployment'
39
47
  option :environment, aliases: ['-e']
40
48
  option :deployment, aliases: ['-d']
41
49
  option :cluster, aliases: ['-c']
42
- def rollback(*args)
43
- STDERR.puts "needs implementation"
50
+ def rollback(*_args)
51
+ warn 'needs implementation'
44
52
  exit 1
45
- #kube.rollback(stack_name, options[:environment], options[:deployment], options[:cluster], args)
53
+ # kube.rollback(stack_name, options[:environment], options[:deployment], options[:cluster], args)
46
54
  end
47
55
 
48
- desc "destroy", "remove the whole stack"
56
+ desc 'destroy', 'remove the whole stack'
49
57
  option :environment, aliases: ['-e']
50
58
  option :cluster, aliases: ['-c']
51
59
  def destroy(stack_name)
52
60
  kube.destroy(stack_name)
53
61
  end
54
62
 
55
- desc "list", "list all stacks in an environment"
63
+ desc 'list', 'list all stacks in an environment'
56
64
  option :environment, aliases: ['-e']
57
65
  option :cluster, aliases: ['-c']
58
66
  def list
59
67
  kube.list
60
68
  end
61
69
 
62
- desc "app", "show the app a stack provides"
70
+ desc 'app', 'show the app a stack provides'
63
71
  option :environment, aliases: ['-e']
64
72
  def app(stack_name)
65
- cluster=nil
66
- deployment=nil
73
+ cluster = nil
74
+ deployment = nil
67
75
  template = Minfra::Cli::StackM::AppTemplate.new(stack_name, minfra_config)
68
76
  template.read
69
- puts "Template: #{template.app_path}\n#{template.to_s}"
70
- apps = AppResource.all(filter: {identifier: template.app.identifier} ).data
77
+ puts "Template: #{template.app_path}\n#{template}"
78
+ apps = AppResource.all(filter: { identifier: template.app.identifier }).data
71
79
  if apps.empty?
72
- puts "Auth: app uninstalled"
80
+ puts 'Auth: app uninstalled'
73
81
  atts = {
74
82
  identifier: template.app.identifier,
75
83
  name: template.app.name,
@@ -79,43 +87,44 @@ module Minfra
79
87
  start_url: template.app.start_url,
80
88
  public: template.app.public
81
89
  }
82
- app_res=AppResource.build( {data: {attributes: atts, type: 'apps'}} )
90
+ app_res = AppResource.build({ data: { attributes: atts, type: 'apps' } })
83
91
  app_res.save
84
92
  app = app_res.data
85
93
  else
86
- app = apps.first
87
- end
94
+ app = apps.first
95
+ end
88
96
  puts "Auth: app installed #{app.id}"
89
97
 
90
- clients = OauthClientResource.all(filter: {app_id: app.id}).data
91
- if clients.empty?
92
- puts "Auth: client not registered"
93
- atts= {redirect_uris: template.client.redirect_uris.map { |r| "#{app.start_url}#{r}" },
94
- native: template.client.native, ppid: template.client.ppid, name: template.client.name, app_id: app.id}
95
- client_res=OauthClientResource.build( {data: {attributes: atts, type: 'oauth_clients'}} )
96
- client_res.save
97
- client=client_res.data
98
- else
99
- client = clients.first
100
- end
101
- puts "Auth: client registered #{client.id}"
98
+ clients = OauthClientResource.all(filter: { app_id: app.id }).data
99
+ if clients.empty?
100
+ puts 'Auth: client not registered'
101
+ atts = { redirect_uris: template.client.redirect_uris.map { |r| "#{app.start_url}#{r}" },
102
+ native: template.client.native, ppid: template.client.ppid, name: template.client.name, app_id: app.id }
103
+ client_res = OauthClientResource.build({ data: { attributes: atts, type: 'oauth_clients' } })
104
+ client_res.save
105
+ client = client_res.data
106
+ else
107
+ client = clients.first
108
+ end
109
+ puts "Auth: client registered #{client.id}"
102
110
 
103
- client_template=Minfra::Cli::StackM::ClientTemplate.new(stack_name, client.name, minfra_config)
104
- unless client_template.exist?
105
- File.write(client_template.path.to_s, { name: client.name, identifier: client.identifier, secret: client.secret }.to_json)
106
- end
107
-
111
+ client_template = Minfra::Cli::StackM::ClientTemplate.new(stack_name, client.name, minfra_config)
112
+ return if client_template.exist?
113
+
114
+ File.write(client_template.path.to_s,
115
+ { name: client.name, identifier: client.identifier, secret: client.secret }.to_json)
108
116
 
109
117
  # TODO: create app configuration
110
118
  # TODO: create provider
111
119
  end
112
120
 
113
- private
114
- def kube
115
- Kube.new(options, minfra_config)
116
- end
121
+ private
122
+
123
+ def kube
124
+ Kube.new(options, minfra_config)
125
+ end
117
126
  end
118
127
  end
119
128
  end
120
129
 
121
- Minfra::Cli.register("stack", "dealing wit stacks", Minfra::Cli::Stack)
130
+ Minfra::Cli.register('stack', 'dealing wit stacks', Minfra::Cli::Stack)
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  module Minfra
3
4
  module Cli
4
5
  class Tag
@@ -22,10 +23,10 @@ module Minfra
22
23
  info 'Checking that the current commit is present on the remote.'
23
24
  output = run_cmd(cmd_ensure_commit_is_pushed)
24
25
 
25
- if output.empty?
26
- exit_error "The current commit is not present on the remote.\n" \
27
- 'Please push your changes to origin and try again.'
28
- end
26
+ return unless output.empty?
27
+
28
+ exit_error "The current commit is not present on the remote.\n" \
29
+ 'Please push your changes to origin and try again.'
29
30
  end
30
31
 
31
32
  def cmd_ensure_commit_is_pushed
@@ -45,7 +46,7 @@ module Minfra
45
46
  end
46
47
 
47
48
  def cmd_push
48
- "git push"
49
+ 'git push'
49
50
  end
50
51
 
51
52
  def cmd_push_tag
@@ -55,8 +56,8 @@ module Minfra
55
56
  def git_current_branch
56
57
  `git rev-parse --abbrev-ref HEAD`.strip
57
58
  end
58
-
59
- #TBD: this should be more flexible
59
+
60
+ # TBD: this should be more flexible
60
61
  def tag_name
61
62
  "#{git_current_branch}-REL-#{@now.strftime(@format)}"
62
63
  end
@@ -68,4 +69,4 @@ module Minfra
68
69
  end
69
70
  end
70
71
 
71
- #Minfra::Cli.register("tag", "creating tags", Minfra::Cli::Tag)
72
+ # Minfra::Cli.register("tag", "creating tags", Minfra::Cli::Tag)
@@ -1,13 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'pathname'
2
4
 
3
5
  module Minfra
4
6
  module Cli
5
7
  module Common
6
-
7
- def exit_error(msg)
8
- STDERR.puts("ERROR: #{msg}" )
9
- exit 1
10
- end
8
+ include Minfra::Cli::Logging
11
9
 
12
10
  def run_cmd(cmd, type = :non_system, silence: false)
13
11
  debug(cmd)
@@ -15,12 +13,12 @@ module Minfra
15
13
  when :exec
16
14
  Kernel.exec(cmd)
17
15
  when :bash
18
- res = system(%{bash -c "#{Array.new(cmd).join(' && ')}"})
19
- exit_error("failed!") unless res
16
+ res = system(%(bash -c "#{Array.new(cmd).join(' && ')}"))
17
+ exit_error('failed!') unless res
20
18
  nil # no output!
21
19
  when :system
22
20
  res = system(cmd)
23
- exit_error("failed!") unless res
21
+ exit_error('failed!') unless res
24
22
  nil # no output!
25
23
  else
26
24
  `#{cmd}` # with output!
@@ -28,14 +26,13 @@ module Minfra
28
26
  end
29
27
 
30
28
  def parse_cmd(cmd, silence: false)
31
- reply = JSON.parse(run_cmd(cmd, silence: silence))
29
+ reply = JSON.parse(run_cmd(cmd, silence:))
32
30
  rescue JSON::ParserError, TypeError
33
31
  error "ERROR: #{$ERROR_INFO.message}"
34
32
  error reply
35
33
  error "command was: #{cmd}"
36
34
  exit 1
37
35
  end
38
-
39
36
  end
40
37
  end
41
38
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'pathname'
2
4
  require 'hashie/mash'
3
5
  require 'json'
@@ -8,90 +10,61 @@ module Minfra
8
10
  class Config
9
11
  class ConfigNotFoundError < StandardError
10
12
  end
13
+
11
14
  class EnvironmentNotFoundError < StandardError
12
15
  end
13
16
 
14
- attr_reader :base_path
15
- attr_reader :config_path
16
- attr_reader :stacks_path
17
- attr_reader :status_path
18
- attr_reader :me_path
19
- attr_reader :kube_path
20
- attr_reader :kube_config_path
21
- attr_reader :kind_config_path
22
-
23
- attr_reader :orch_env
24
- attr_reader :orch_env_config
25
- attr_reader :config
26
- attr_reader :project
17
+ attr_reader :base_path, :config_path, :stacks_path, :status_path, :me_path, :kube_path, :kube_config_path,
18
+ :kind_config_path, :orch_env, :orch_env_config, :config, :project
27
19
 
28
- def self.load(orch_env, base_path_str = nil)
29
- new(base_path_str).load(orch_env)
20
+ def initialize(base_path_str, orch_env)
21
+ init!(base_path_str, orch_env)
30
22
  end
31
23
 
32
- def initialize(base_path_str=nil)
33
- init!(base_path_str)
34
- end
35
-
36
- def init!(base_path_str=nil)
37
- @base_path = Pathname.new(base_path_str || ENV["MINFRA_PATH"]).expand_path
24
+ def init!(base_path_str, orch_env)
25
+ @orch_env = orch_env
26
+ @base_path = Pathname.new(base_path_str).expand_path
38
27
  @me_path = @base_path.join('me')
39
- @project_config_path=@base_path.join("config","project.json")
40
- @config_path = @me_path.join('config.json')
28
+ @project_config_path = @base_path.join('config', 'project.json')
29
+ @config_path = @me_path.join('config.json')
41
30
  @stacks_path = @base_path.join('stacks')
42
31
  @status_path = @base_path.join('state')
43
- @kube_path=@me_path.join('kube')
44
- @kube_config_path=@kube_path.join('config')
45
- @kind_config_path=@me_path.join("kind.yaml")
46
-
47
- # @project_minfrarc_path = @base_path.join("config",'minfrarc.rb')
48
- # require @project_minfrarc_path if @project_minfrarc_path.exist?
49
- # @me_minfrarc_path = @me_path.join('minfrarc.rb')
50
- # require @me_minfrarc_path if @me_minfrarc_path.exist?
32
+ @kube_path = @me_path.join('kube')
33
+ @kube_config_path = @kube_path.join('config')
34
+ @kind_config_path = @me_path.join('kind.yaml')
51
35
 
52
36
  if config_path.exist?
53
- @config = Hashie::Mash.new(JSON.parse(Minfra::Cli::Templater.render(File.read(config_path),{})))
37
+ @config = Hashie::Mash.new(JSON.parse(Minfra::Cli::Templater.render(File.read(config_path), {})))
54
38
  else
55
39
  warn("personal minfra configuration file '#{config_path}' not found, you might have to run 'minfra setup dev'")
56
40
  @config = Hashie::Mash.new({})
57
41
  end
58
- @project = Hashie::Mash.new(JSON.parse(Minfra::Cli::Templater.render(File.read(@project_config_path),{})))
59
- @project= @project.
60
- deep_merge(@config)
61
- # deep_merge(@project.environments[@orch_env]).
62
- # deep_merge(@orch_env_config)
63
-
64
- end
65
-
66
- def load(orch_env)
67
- return self if defined?(@orch_env)
68
- @orch_env = orch_env
69
- @orch_env_config=Hashie::Mash.new
70
- @orch_env_config['env']=@orch_env
71
- self
42
+ @project = Hashie::Mash.new(JSON.parse(Minfra::Cli::Templater.render(File.read(@project_config_path), {})))
43
+ @project = @project
44
+ .deep_merge(@config)
72
45
  end
73
46
 
74
47
  def name
75
48
  @project.name
76
49
  end
77
50
 
78
- def describe(environment)
79
- {
80
- env: {
81
- minfra_name: ENV["MINFRA_NAME"],
82
- minfra_path: ENV["MINFRA_PATH"],
83
- },
84
- base_path: base_path.to_s,
85
- me_path: me_path.to_s,
86
- kube_path: kube_path.to_s,
87
- config_path: config_path.to_s,
88
- config: @config.to_h,
89
- env_config: @orch_env_config.to_h,
90
- project: @project
91
- }
51
+ def describe(_environment)
52
+ {
53
+ env: {
54
+ minfra_name: ENV.fetch('MINFRA_NAME', nil),
55
+ minfra_path: ENV.fetch('MINFRA_PATH', nil)
56
+ },
57
+ base_path: base_path.to_s,
58
+ me_path: me_path.to_s,
59
+ kube_path: kube_path.to_s,
60
+ config_path: config_path.to_s,
61
+ config: @config.to_h,
62
+ project: @project
63
+ }
92
64
  end
65
+
93
66
  def dev?
94
- @orch_env=='dev'
67
+ @orch_env == 'dev'
95
68
  end
96
69
 
97
70
  def email
@@ -103,8 +76,8 @@ module Minfra
103
76
  end
104
77
 
105
78
  def endpoint(name)
106
- Hashie::Mash.new({"api_key": api_key}).deep_merge(@project.endpoints[name])
107
- rescue
79
+ Hashie::Mash.new({ api_key: }).deep_merge(@project.endpoints[name])
80
+ rescue StandardError
108
81
  raise("endpoint #{name} is undefinded please add <env>:endpoints:#{name} to you #{config_path} file ")
109
82
  end
110
83
  end
@@ -0,0 +1,7 @@
1
+ # this is for ruby 3.2
2
+
3
+ class File
4
+ def self.exists?(file)
5
+ exist?(file)
6
+ end
7
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Minfra
2
4
  module Cli
3
5
  class Document
@@ -9,9 +11,10 @@ module Minfra
9
11
  @config = config
10
12
  end
11
13
 
12
- def document(message)
14
+ def document(_message)
13
15
  return true if @config.dev?
14
- puts "TBD: calling documentation hooks"
16
+
17
+ puts 'TBD: calling documentation hooks'
15
18
  true
16
19
  end
17
20
  end
@@ -0,0 +1,24 @@
1
+ module Minfra
2
+ module Cli
3
+ class Env
4
+ attr_reader :name, :hiera
5
+ def initialize(name:, hiera_root:, hiera_env_path:)
6
+ @name = name
7
+ @hiera = HieraLooker.new(
8
+ root: hiera_root,
9
+ env_name: name,
10
+ env_path: hiera_env_path
11
+ )
12
+ end
13
+
14
+ def l(key, value = nil)
15
+ @hiera.l(key,value)
16
+ end
17
+
18
+ def l!(key, value = nil)
19
+ @hiera.l!(key, value)
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Minfra
4
+ module Cli
5
+ module Errors
6
+ class ExitError < StandardError
7
+ end
8
+ end
9
+ end
10
+ end
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Minfra
2
4
  module Cli
3
5
  class HelmRunner < Runner
4
6
  def initialize(cmd, **args)
5
- insecure_flag = l("infra::allow_insecure_k8s_connections") ? "--kube-insecure-skip-tls-verify" : ""
7
+ insecure_flag = l('infra::allow_insecure_k8s_connections') ? '--kube-insecure-skip-tls-verify' : ''
6
8
  cmd = "helm #{insecure_flag} #{cmd}"
7
9
  super(cmd, **args)
8
10
  end