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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +21 -0
- data/lib/minfra/cli/cli_starter.rb +1 -2
- data/lib/minfra/cli/commands/plugin.rb +1 -4
- data/lib/minfra/cli/commands/project/tag.rb +8 -31
- data/lib/minfra/cli/commands/project.rb +24 -8
- data/lib/minfra/cli/commands/tag.rb +2 -1
- data/lib/minfra/cli/plugin.rb +12 -55
- data/lib/minfra/cli/plugins.rb +3 -14
- data/lib/minfra/cli/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cb4250a44a0505fb93907ee8271ded65daa44bb0e2fc146384b89ef24b83dc40
|
|
4
|
+
data.tar.gz: 5bc3dcf010537de7ee9dc2f5e8811992dd9413ed12ecd11b05f31ef7da63c777
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3bc9d6f86b09feabb50d4e2e322ae92dce6c24473f0d9fbc4f0746984de6242e9e947311727d6d4e30f9f79d0ae52efff35f3ba34d7e83dc5d89e9a1f081a996
|
|
7
|
+
data.tar.gz: a8fb7b4720877e13e96fe200cb61399afbc3491bba423df07a6af9310bb0c7e2e321c91cdc579f1fdc063ee2994f3574d62a7e79fba0eac769a9335ef90ee750
|
data/CHANGELOG.md
CHANGED
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
|
+
|
|
@@ -3,37 +3,14 @@
|
|
|
3
3
|
module Minfra
|
|
4
4
|
module Cli
|
|
5
5
|
class Project < Command
|
|
6
|
-
class
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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',
|
|
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
|
-
|
|
64
|
-
|
|
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
|
-
|
|
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)
|
data/lib/minfra/cli/plugin.rb
CHANGED
|
@@ -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
|
|
11
|
-
@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
|
|
25
|
-
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
data/lib/minfra/cli/plugins.rb
CHANGED
|
@@ -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
|
|
19
|
+
def self.load
|
|
24
20
|
found = []
|
|
25
|
-
|
|
26
|
-
|
|
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
|
data/lib/minfra/cli/version.rb
CHANGED
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
|
+
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:
|
|
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.
|
|
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.
|