minfra-cli 4.6.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: 2ab01fb75afb67c24a5d05059301c1abbf12097d6dd1a2d7e89b83df4e668f92
4
- data.tar.gz: 2c6d61125270a3ebac58beb69d9cfbc56e35be193e09bedc3288d1223bf9184c
3
+ metadata.gz: cb4250a44a0505fb93907ee8271ded65daa44bb0e2fc146384b89ef24b83dc40
4
+ data.tar.gz: 5bc3dcf010537de7ee9dc2f5e8811992dd9413ed12ecd11b05f31ef7da63c777
5
5
  SHA512:
6
- metadata.gz: fa52c1392bc0f9cefc397048b26cecf04f43e5761447d55ba227b714ded397a18900d72a3a300d5b9af4c0fe692bbf8c32275964a5f773e25d497a5514eb8c07
7
- data.tar.gz: 9b33e5b4c8707e92b8ec0c9f3d67d683cc469a4a31a0a0ec1aa9c8190ca64db76947bb7caf772626254ff720eb71a4a52f77f11d9cff01454deaf0257807e74c
6
+ metadata.gz: 3bc9d6f86b09feabb50d4e2e322ae92dce6c24473f0d9fbc4f0746984de6242e9e947311727d6d4e30f9f79d0ae52efff35f3ba34d7e83dc5d89e9a1f081a996
7
+ data.tar.gz: a8fb7b4720877e13e96fe200cb61399afbc3491bba423df07a6af9310bb0c7e2e321c91cdc579f1fdc063ee2994f3574d62a7e79fba0eac769a9335ef90ee750
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
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
1
5
  # 4.6.0
2
6
  * loosening dependency versions
3
7
  # 4.5.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.6.0'
5
+ VERSION = '5.0.0'
6
6
  end
7
7
  end
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.6.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-07-04 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
@@ -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.