minfra-cli 4.5.0 → 5.0.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: 07b87ef33ed2dc996e44d256b5a7261ddc450bdb9ec62ff4cf14ee75100fe54d
4
- data.tar.gz: affd2f04ae229524d2aca2f27186cc788385071b91d31af715f9852869aafed5
3
+ metadata.gz: cb4250a44a0505fb93907ee8271ded65daa44bb0e2fc146384b89ef24b83dc40
4
+ data.tar.gz: 5bc3dcf010537de7ee9dc2f5e8811992dd9413ed12ecd11b05f31ef7da63c777
5
5
  SHA512:
6
- metadata.gz: 93eeee98335ef70bab22772027c2c9d760d3fbb8e8bc0c6bfb84da675df0e5d04913db030012469f3c1092558dbc5b4b642042d5830953b976c4d5cc0b27e419
7
- data.tar.gz: 291c28620311e16e4770a0db2a1d8e18a88529c5cf13e87b52dced59fc5e877533d00008d1561ba64713d2c566754e77d2724a62f7b55e054ff2d587dd2e2457
6
+ metadata.gz: 3bc9d6f86b09feabb50d4e2e322ae92dce6c24473f0d9fbc4f0746984de6242e9e947311727d6d4e30f9f79d0ae52efff35f3ba34d7e83dc5d89e9a1f081a996
7
+ data.tar.gz: a8fb7b4720877e13e96fe200cb61399afbc3491bba423df07a6af9310bb0c7e2e321c91cdc579f1fdc063ee2994f3574d62a7e79fba0eac769a9335ef90ee750
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 5.0.0
2
+ * plugins install removed
3
+ * minfra uses a usual gemfile
4
+ * minfra binary has to be in your path in your project see README
5
+ # 4.6.0
6
+ * loosening dependency versions
1
7
  # 4.5.0
2
8
  * removing the env.roles dependency so it's env.stacks only
3
9
  # 4.4.0
data/README.md CHANGED
@@ -36,3 +36,24 @@ an application can have
36
36
  * variables
37
37
  * configurations
38
38
  * secrets
39
+
40
+ # Upgrades
41
+
42
+ ## 4. to 5.
43
+
44
+ Create a Gemfile and Gemfile.lock in your $MINFRA_PATH with minfra-cli AND
45
+ your plugins.
46
+
47
+ Create a "minfra" executable in your $PATH with the content
48
+ ```
49
+ #!/usr/bin/env ruby
50
+ path = File.expand_path('Gemfile', ENV['MINFRA_PATH'])
51
+ ENV["BUNDLE_GEMFILE"] ||= path
52
+ require "bundler/setup"
53
+ require 'minfra/cli'
54
+
55
+ exit Minfra::Cli.exec(ARGV)
56
+ ```
57
+
58
+ remove the files config/minfra_plugins.json
59
+
@@ -120,8 +120,7 @@ module Minfra
120
120
  end
121
121
 
122
122
  def init_plugins
123
- @plugins = Minfra::Cli::Plugins.load(@base_path)
124
- @plugins.prepare
123
+ @plugins = Minfra::Cli::Plugins.load
125
124
  end
126
125
 
127
126
  def init_logger
@@ -11,10 +11,7 @@ module Minfra
11
11
  end
12
12
  desc 'install', 'install plugins'
13
13
  def install
14
- Minfra::Cli.cli.plugins.each do |plugin|
15
- puts "setup: #{plugin.name}"
16
- plugin.install
17
- end
14
+ puts "deprecated, use bundle install"
18
15
  end
19
16
  end
20
17
  end
@@ -3,37 +3,14 @@
3
3
  module Minfra
4
4
  module Cli
5
5
  class Project < Command
6
- class Tag < Command
7
- desc 'update', 'update stack tag file'
8
- option 'environment', aliases: ['-e'], required: true
9
- def update(domain, new_tag)
10
- tags = JSON.parse(File.read(tags_path))
11
-
12
- raise ArgumentError, "#{path} doesn't contain #{domain}" unless tags[options[:environment]].key?(domain)
13
-
14
- tags[options[:environment]][domain] = new_tag
15
- pretty_tags = JSON.pretty_unparse(tags)
16
- File.write(tags_path, "#{pretty_tags}\n")
17
- puts "#{tags_path} - UPDATED"
18
- puts pretty_tags
19
- end
20
-
21
- private
22
-
23
- def tags_path
24
- apps_path.join('stacks', stack_name, 'tags.json')
25
- end
26
-
27
- def apps_path
28
- minfra_config.base_path
29
- end
30
-
31
- def stack_name
32
- current_directory.split('/').last.gsub('_', '-')
33
- end
34
-
35
- def current_directory
36
- Dir.getwd
6
+ class TagCli < Command
7
+ default_command :create
8
+ # tbd: move this to project
9
+ desc 'create', 'tag current commit for deployment - triggers CI'
10
+ option :message, default: 'release', aliases: ['-m']
11
+ option :format, required: false, aliases: ['-f']
12
+ def create
13
+ puts Tag.new.tag_current_commit_for_deploy(options[:message], options[:format])
37
14
  end
38
15
  end
39
16
  end
@@ -39,7 +39,7 @@ module Minfra
39
39
  subcommand 'branch', Branch
40
40
 
41
41
  desc 'tag', 'manage tags'
42
- subcommand 'tag', Tag
42
+ subcommand 'tag', TagCli
43
43
 
44
44
  desc 'test', 'run tests'
45
45
  def test
@@ -60,11 +60,8 @@ module Minfra
60
60
  option 'target', aliases: ['-t']
61
61
  def build
62
62
  p = ProjectInfo.load(Pathname.pwd)
63
- run_pre_repo
64
- target = options[:target] || p.docker.dev_target
65
-
66
- cmd = %(docker build #{"--target #{target}" if target} -t #{p.repo_name}:latest #{p.app_dir})
67
- res = Runner.run(cmd)
63
+ target = options[:target]
64
+ res=docker_build(target)
68
65
  exit(1) if res.error?
69
66
 
70
67
  return if options[:noload]
@@ -83,17 +80,18 @@ module Minfra
83
80
  desc 'push', 'push directly to the repo'
84
81
  option 'tag', aliases: ['-t']
85
82
  option 'registry', aliases: ['-r']
83
+ option 'build', type: :boolean, default: true
86
84
  def push
87
85
  tag = options[:tag] || `date +%Y%m%d%H%M`
88
86
  p = ProjectInfo.load(Pathname.pwd)
89
-
87
+
90
88
  repo_name = if options[:registry]
91
89
  "#{options[:registry]}/#{p.repo_name}"
92
90
  else
93
91
  p.repo_name
94
92
  end
95
93
 
96
- Runner.run(%(docker build -t #{p.repo_name}:latest #{p.app_dir}))
94
+ docker_build(nil) if options[:build]
97
95
  # Runner.run(%{docker push #{p.repo_name}})
98
96
  Runner.run(%(docker tag #{p.repo_name}:latest #{repo_name}:#{tag}))
99
97
  Runner.run(%(docker push #{repo_name}:#{tag}))
@@ -101,6 +99,24 @@ module Minfra
101
99
 
102
100
  private
103
101
 
102
+ def docker_build(target)
103
+ p = ProjectInfo.load(Pathname.pwd)
104
+ run_pre_repo
105
+ args=[]
106
+ if p.build&.args
107
+ p.build&.args.each_pair do |arg, val|
108
+ args << "--build-arg #{arg}=#{l!(val)}"
109
+ end
110
+ end
111
+ if target
112
+ target = "--target #{target}"
113
+ else
114
+ traget = ''
115
+ end
116
+
117
+ Runner.run(%(docker build #{args.join(' ')} #{target} -t #{p.repo_name}:latest #{p.app_dir} ))
118
+ end
119
+
104
120
  def run_pre_repo
105
121
  Runner.run(minfra_config.base_path.join('hooks', 'pre_repo.sh').to_s)
106
122
  end
@@ -17,6 +17,7 @@ module Minfra
17
17
  info 'Creating tag.'
18
18
  run_cmd(cmd_tag_commit(message), :system)
19
19
  run_cmd(cmd_push_tag, :system)
20
+ tag_name
20
21
  end
21
22
 
22
23
  def ensure_commit_is_pushed
@@ -59,7 +60,7 @@ module Minfra
59
60
 
60
61
  # TBD: this should be more flexible
61
62
  def tag_name
62
- "#{git_current_branch}-REL-#{@now.strftime(@format)}"
63
+ @tag_name ||= "#{git_current_branch}-REL-#{@now.strftime(@format)}"
63
64
  end
64
65
 
65
66
  def run_cmd(cmd, _how = :system)
@@ -5,68 +5,25 @@ module Minfra
5
5
  class Plugins
6
6
  class Plugin
7
7
  include Logging
8
- attr_reader :name, :version, :opts, :path
9
8
 
10
- def initialize(name:, version:, opts:, disabled:)
11
- @name = name
12
- @version = version
13
- @opts = opts.merge(require: false)
14
- @disabled = disabled
15
- return unless opts['path']
16
-
17
- @path = Minfra::Cli.config.base_path.join(opts['path'])
18
- end
19
-
20
- def disabled?
21
- @disabled
9
+ def name
10
+ @spec.name
22
11
  end
23
-
24
- def install
25
- if path
26
- system("cd #{path}; bundle install")
27
- else
28
- system("gem install #{name} --version #{version}")
29
- end
12
+
13
+ def version
14
+ @spec.version
30
15
  end
31
16
 
32
- # adds the plugin to the
33
- def prepare
34
- debug("plugin prepare: #{name}, #{version}, disabled: #{disabled?}")
35
- return if disabled?
36
-
37
- if path
38
- begin
39
- lib_path = path.join('lib')
40
- $LOAD_PATH.unshift lib_path
41
- require name
42
- rescue Gem::Requirement::BadRequirementError, LoadError
43
- warn("plugin prepare path: #{name} (#{$ERROR_INFO})")
44
- end
45
- else
46
- begin
47
- @gem_spec = Gem::Specification.find_by_name(name)
48
- gem name, version
49
- rescue Gem::MissingSpecError
50
- warn("plugin prepare gem: #{name}, #{version} (#{$ERROR_INFO})")
51
- end
52
- end
17
+ def initialize(spec)
18
+ @spec = spec
19
+ @minfracs_path = Pathname.new(spec.full_gem_path).join('minfracs', 'init.rb')
20
+ raise "no init.rb file in #{@minfracs_path}" unless @minfracs_path.exist?
53
21
  end
54
22
 
55
23
  def setup
56
- return if disabled?
57
-
58
- if path
59
- minfra_path = Pathname.new(path).join('minfracs', 'init.rb')
60
- if minfra_path.exist?
61
- begin
62
- require minfra_path # this should register the command
63
- rescue LoadError
64
- logger.warn("Minfra plugin detected but dependencies not installed: #{minfra_path} (#{$ERROR_INFO}). TRY: minfra plugin install")
65
- end
66
- end
67
- else
68
- error('Gem based plugins not supported yet')
69
- end
24
+ require @minfracs_path # this should register the command
25
+ rescue LoadError
26
+ logger.warn("Minfra plugin detected but dependencies not installed: #{minfra_path} (#{$ERROR_INFO}). TRY: minfra plugin install")
70
27
  end
71
28
  end
72
29
  end
@@ -8,10 +8,6 @@ module Minfra
8
8
  @plugins = plugins
9
9
  end
10
10
 
11
- def prepare
12
- @plugins.each(&:prepare)
13
- end
14
-
15
11
  def setup
16
12
  @plugins.each(&:setup)
17
13
  end
@@ -20,17 +16,10 @@ module Minfra
20
16
  @plugins.each(&)
21
17
  end
22
18
 
23
- def self.load(base_path)
19
+ def self.load
24
20
  found = []
25
- [base_path.join('config', 'minfra_plugins.json'),
26
- base_path.join('me', 'minfra_plugins.json')].each do |file|
27
- next unless File.exist?(file)
28
-
29
- plugins = JSON.parse(File.read(file))
30
- plugins['plugins'].each do |spec|
31
- found << Plugin.new(name: spec['name'], opts: spec['opts'] || {}, version: spec['version'],
32
- disabled: spec['disabled'])
33
- end
21
+ definition = Bundler.definition.specs.each do |spec|
22
+ found << Plugin.new(spec) if Pathname.new(spec.full_gem_path).join('minfracs').exist?
34
23
  end
35
24
  new(found)
36
25
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Minfra
4
4
  module Cli
5
- VERSION = '4.5.0'
5
+ VERSION = '5.0.0'
6
6
  end
7
7
  end
data/minfra-cli.gemspec CHANGED
@@ -28,14 +28,13 @@ Gem::Specification.new do |spec|
28
28
  spec.require_paths = ["lib"]
29
29
 
30
30
  spec.add_runtime_dependency 'thor', '~> 1.0', '>= 1.0.0'
31
- spec.add_runtime_dependency "table_print", "1.5.6"
31
+ spec.add_runtime_dependency "table_print", "~> 1.5"
32
32
  spec.add_runtime_dependency "rest-client", "~>2.0"
33
33
  spec.add_runtime_dependency "hashie", "~>3.5"
34
- spec.add_runtime_dependency "activesupport", "= 7.0.7.2"
34
+ spec.add_runtime_dependency "activesupport", ">= 7"
35
35
  spec.add_runtime_dependency "erubis", "~> 2.7"
36
- spec.add_runtime_dependency "hiera", "3.9.0"
37
- spec.add_runtime_dependency "hiera-eyaml", "3.3.0"
38
- spec.add_runtime_dependency "hiera-eyaml-gpg", "0.7.4"
39
- spec.add_runtime_dependency "gpgme", "~>2.0.0"
36
+ spec.add_runtime_dependency "hiera", "~> 3.9"
37
+ spec.add_runtime_dependency "hiera-eyaml", "~> 3.3"
38
+ spec.add_runtime_dependency "hiera-eyaml-gpg", "~> 0.7"
39
+ spec.add_runtime_dependency "gpgme", "~>2.0"
40
40
  end
41
-
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.5.0
4
+ version: 5.0.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-06-29 00:00:00.000000000 Z
11
+ date: 2026-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -34,16 +34,16 @@ dependencies:
34
34
  name: table_print
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - '='
37
+ - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 1.5.6
39
+ version: '1.5'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - '='
44
+ - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: 1.5.6
46
+ version: '1.5'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rest-client
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -76,16 +76,16 @@ dependencies:
76
76
  name: activesupport
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - '='
79
+ - - ">="
80
80
  - !ruby/object:Gem::Version
81
- version: 7.0.7.2
81
+ version: '7'
82
82
  type: :runtime
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - '='
86
+ - - ">="
87
87
  - !ruby/object:Gem::Version
88
- version: 7.0.7.2
88
+ version: '7'
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: erubis
91
91
  requirement: !ruby/object:Gem::Requirement
@@ -104,58 +104,58 @@ dependencies:
104
104
  name: hiera
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
- - - '='
107
+ - - "~>"
108
108
  - !ruby/object:Gem::Version
109
- version: 3.9.0
109
+ version: '3.9'
110
110
  type: :runtime
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
- - - '='
114
+ - - "~>"
115
115
  - !ruby/object:Gem::Version
116
- version: 3.9.0
116
+ version: '3.9'
117
117
  - !ruby/object:Gem::Dependency
118
118
  name: hiera-eyaml
119
119
  requirement: !ruby/object:Gem::Requirement
120
120
  requirements:
121
- - - '='
121
+ - - "~>"
122
122
  - !ruby/object:Gem::Version
123
- version: 3.3.0
123
+ version: '3.3'
124
124
  type: :runtime
125
125
  prerelease: false
126
126
  version_requirements: !ruby/object:Gem::Requirement
127
127
  requirements:
128
- - - '='
128
+ - - "~>"
129
129
  - !ruby/object:Gem::Version
130
- version: 3.3.0
130
+ version: '3.3'
131
131
  - !ruby/object:Gem::Dependency
132
132
  name: hiera-eyaml-gpg
133
133
  requirement: !ruby/object:Gem::Requirement
134
134
  requirements:
135
- - - '='
135
+ - - "~>"
136
136
  - !ruby/object:Gem::Version
137
- version: 0.7.4
137
+ version: '0.7'
138
138
  type: :runtime
139
139
  prerelease: false
140
140
  version_requirements: !ruby/object:Gem::Requirement
141
141
  requirements:
142
- - - '='
142
+ - - "~>"
143
143
  - !ruby/object:Gem::Version
144
- version: 0.7.4
144
+ version: '0.7'
145
145
  - !ruby/object:Gem::Dependency
146
146
  name: gpgme
147
147
  requirement: !ruby/object:Gem::Requirement
148
148
  requirements:
149
149
  - - "~>"
150
150
  - !ruby/object:Gem::Version
151
- version: 2.0.0
151
+ version: '2.0'
152
152
  type: :runtime
153
153
  prerelease: false
154
154
  version_requirements: !ruby/object:Gem::Requirement
155
155
  requirements:
156
156
  - - "~>"
157
157
  - !ruby/object:Gem::Version
158
- version: 2.0.0
158
+ version: '2.0'
159
159
  description: A cli framework for k8s based development and deployment.
160
160
  email:
161
161
  - peter.schrammel@gmx.de
@@ -261,7 +261,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
261
261
  - !ruby/object:Gem::Version
262
262
  version: '0'
263
263
  requirements: []
264
- rubygems_version: 3.3.7
264
+ rubygems_version: 3.4.6
265
265
  signing_key:
266
266
  specification_version: 4
267
267
  summary: A cli framework for k8s based development and deployment.