minfra-cli 1.0.1 → 1.1.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 +6 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +87 -0
- data/README.md +36 -0
- data/lib/minfra/cli/commands/kube.rb +6 -2
- data/lib/minfra/cli/commands/stack/kube_stack_template.rb +10 -29
- data/lib/minfra/cli/config.rb +2 -0
- data/lib/minfra/cli/logging.rb +3 -3
- data/lib/minfra/cli/version.rb +1 -1
- data/lib/minfra/cli.rb +0 -1
- data/lib/orchparty/kubernetes_application.rb +10 -8
- data/lib/orchparty.rb +11 -2
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ad8c40bad784c7d620305dd1f0b352e96c51d21a985017cbf98550b110d8ee6d
|
|
4
|
+
data.tar.gz: 7f5895eeaf923585c2e7072d09b3bac513228662c09761c89af81ec442a374d2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 599880ad0ff8161584e13abdd479371c793cc551ef6f788d556bd5ae5f4e742399539a150ca896f84781a9796ac91e7c0134172d53e952106cb9067c7cd0d91c
|
|
7
|
+
data.tar.gz: 1cf840dac8f60258804e20ffeee65b3c41e6c6248ff9a08b187000ad145bd498ca540b0be090739e12b135f8a68a5b443f662be6d684e087316dc667a9772351
|
data/CHANGELOG.md
CHANGED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
minfra-cli (1.0.1)
|
|
5
|
+
activesupport (~> 6.1)
|
|
6
|
+
erubis (~> 2.7)
|
|
7
|
+
hashie (~> 3.5)
|
|
8
|
+
hiera (= 3.9.0)
|
|
9
|
+
hiera-eyaml (= 3.3.0)
|
|
10
|
+
hiera-eyaml-gpg (= 0.7.4)
|
|
11
|
+
rest-client (~> 2.0)
|
|
12
|
+
table_print (= 1.5.6)
|
|
13
|
+
thor (~> 1.0, >= 1.0.0)
|
|
14
|
+
|
|
15
|
+
GEM
|
|
16
|
+
remote: https://rubygems.org/
|
|
17
|
+
specs:
|
|
18
|
+
activesupport (6.1.7)
|
|
19
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
20
|
+
i18n (>= 1.6, < 2)
|
|
21
|
+
minitest (>= 5.1)
|
|
22
|
+
tzinfo (~> 2.0)
|
|
23
|
+
zeitwerk (~> 2.3)
|
|
24
|
+
concurrent-ruby (1.1.10)
|
|
25
|
+
diff-lcs (1.5.0)
|
|
26
|
+
domain_name (0.5.20190701)
|
|
27
|
+
unf (>= 0.0.5, < 1.0.0)
|
|
28
|
+
erubis (2.7.0)
|
|
29
|
+
hashie (3.6.0)
|
|
30
|
+
hiera (3.9.0)
|
|
31
|
+
hiera-eyaml (3.3.0)
|
|
32
|
+
highline
|
|
33
|
+
optimist
|
|
34
|
+
hiera-eyaml-gpg (0.7.4)
|
|
35
|
+
hiera-eyaml (>= 1.3.8)
|
|
36
|
+
highline (2.0.3)
|
|
37
|
+
http-accept (1.7.0)
|
|
38
|
+
http-cookie (1.0.5)
|
|
39
|
+
domain_name (~> 0.5)
|
|
40
|
+
i18n (1.12.0)
|
|
41
|
+
concurrent-ruby (~> 1.0)
|
|
42
|
+
mime-types (3.4.1)
|
|
43
|
+
mime-types-data (~> 3.2015)
|
|
44
|
+
mime-types-data (3.2022.0105)
|
|
45
|
+
minitest (5.16.3)
|
|
46
|
+
netrc (0.11.0)
|
|
47
|
+
optimist (3.0.1)
|
|
48
|
+
rake (12.3.3)
|
|
49
|
+
rest-client (2.1.0)
|
|
50
|
+
http-accept (>= 1.7.0, < 2.0)
|
|
51
|
+
http-cookie (>= 1.0.2, < 2.0)
|
|
52
|
+
mime-types (>= 1.16, < 4.0)
|
|
53
|
+
netrc (~> 0.8)
|
|
54
|
+
rspec (3.11.0)
|
|
55
|
+
rspec-core (~> 3.11.0)
|
|
56
|
+
rspec-expectations (~> 3.11.0)
|
|
57
|
+
rspec-mocks (~> 3.11.0)
|
|
58
|
+
rspec-core (3.11.0)
|
|
59
|
+
rspec-support (~> 3.11.0)
|
|
60
|
+
rspec-expectations (3.11.1)
|
|
61
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
62
|
+
rspec-support (~> 3.11.0)
|
|
63
|
+
rspec-mocks (3.11.1)
|
|
64
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
65
|
+
rspec-support (~> 3.11.0)
|
|
66
|
+
rspec-support (3.11.1)
|
|
67
|
+
table_print (1.5.6)
|
|
68
|
+
thor (1.2.1)
|
|
69
|
+
timecop (0.9.5)
|
|
70
|
+
tzinfo (2.0.5)
|
|
71
|
+
concurrent-ruby (~> 1.0)
|
|
72
|
+
unf (0.1.4)
|
|
73
|
+
unf_ext
|
|
74
|
+
unf_ext (0.0.8.2)
|
|
75
|
+
zeitwerk (2.6.0)
|
|
76
|
+
|
|
77
|
+
PLATFORMS
|
|
78
|
+
ruby
|
|
79
|
+
|
|
80
|
+
DEPENDENCIES
|
|
81
|
+
minfra-cli!
|
|
82
|
+
rake (~> 12.0)
|
|
83
|
+
rspec (~> 3.0)
|
|
84
|
+
timecop (~> 0.9.5)
|
|
85
|
+
|
|
86
|
+
BUNDLED WITH
|
|
87
|
+
2.1.4
|
data/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# minfra-cli
|
|
2
|
+
|
|
3
|
+
Is a KIND (k8s in docker) based development environment.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## Expected hiera data
|
|
8
|
+
|
|
9
|
+
* l("cluster").id: the k8s name of the cluster
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# Orchparty
|
|
25
|
+
|
|
26
|
+
It's a fork of the original orchparty. TBD: see
|
|
27
|
+
|
|
28
|
+
The base is an application
|
|
29
|
+
|
|
30
|
+
an application can have
|
|
31
|
+
* services
|
|
32
|
+
* apply
|
|
33
|
+
* environment
|
|
34
|
+
* variables
|
|
35
|
+
* configurations
|
|
36
|
+
* secrets
|
|
@@ -86,18 +86,21 @@ module Minfra
|
|
|
86
86
|
cluster = stack.cluster_name
|
|
87
87
|
|
|
88
88
|
method = options["install"] ? "install" : "upgrade"
|
|
89
|
-
|
|
89
|
+
|
|
90
|
+
stack.release_path.mkpath
|
|
91
|
+
|
|
92
|
+
File.open(stack.compose_path,"w") do |f|
|
|
90
93
|
Orchparty::App.new(cluster_name: cluster,
|
|
91
94
|
application_name: stack.name,
|
|
92
95
|
force_variable_definition: false,
|
|
93
96
|
file_name: stack.stack_rb_path.to_s,
|
|
97
|
+
status_dir: stack.release_path,
|
|
94
98
|
options: options
|
|
95
99
|
).
|
|
96
100
|
print( method: method, out_io: f)
|
|
97
101
|
end
|
|
98
102
|
#run_cmd(generate_cmd, :bash)
|
|
99
103
|
bash_cmd = ["cd #{stack.release_path}"]
|
|
100
|
-
bash_cmd << "cp #{stack.compose_path(blank: true)} #{stack.compose_path}"
|
|
101
104
|
run_cmd(bash_cmd, :bash)
|
|
102
105
|
|
|
103
106
|
|
|
@@ -132,6 +135,7 @@ module Minfra
|
|
|
132
135
|
application_name: stack.name,
|
|
133
136
|
force_variable_definition: false,
|
|
134
137
|
file_name: stack.stack_rb_path.to_s,
|
|
138
|
+
status_dir: stack.release_path,
|
|
135
139
|
options: options
|
|
136
140
|
)
|
|
137
141
|
orch.send(method)
|
|
@@ -5,27 +5,21 @@ module Minfra
|
|
|
5
5
|
class KubeStackTemplate
|
|
6
6
|
include ::Minfra::Cli::Logging
|
|
7
7
|
|
|
8
|
-
attr_reader :name, :env, :deployment
|
|
8
|
+
attr_reader :name, :env, :deployment, :config_path
|
|
9
9
|
def initialize(name, config, deployment: '', cluster:)
|
|
10
10
|
@name = name
|
|
11
|
-
@
|
|
11
|
+
@config_path = config.stacks_path.join(name)
|
|
12
12
|
@errors = []
|
|
13
13
|
@config = config
|
|
14
14
|
@env = config.orch_env
|
|
15
15
|
@deployment = deployment.freeze
|
|
16
|
-
@cluster = cluster.freeze
|
|
17
|
-
|
|
16
|
+
@cluster = cluster.freeze || l!("cluster").id
|
|
17
|
+
@result_path = config.status_path.join('stacks', @cluster, name)
|
|
18
|
+
puts "Stack selection: #{@name}, #{@config_path}, #{@cluster}, #{@result_path}"
|
|
18
19
|
end
|
|
19
20
|
|
|
20
21
|
def cluster_name
|
|
21
|
-
|
|
22
|
-
@cluster_name = @cluster
|
|
23
|
-
@cluster_name ||= "kind-#{@config.name}" if @config.dev?
|
|
24
|
-
if cluster_path.exist? && (@cluster_name.nil? || @cluster_name.empty?)
|
|
25
|
-
@cluster_name = YAML.load(File.read(cluster_path))[env.to_s]
|
|
26
|
-
end
|
|
27
|
-
@cluster_name ||= env
|
|
28
|
-
@cluster_name
|
|
22
|
+
@cluster
|
|
29
23
|
end
|
|
30
24
|
|
|
31
25
|
def mixin_env
|
|
@@ -33,8 +27,8 @@ module Minfra
|
|
|
33
27
|
end
|
|
34
28
|
|
|
35
29
|
def valid?
|
|
36
|
-
unless @
|
|
37
|
-
@errors << "stack path #{@
|
|
30
|
+
unless @config_path.exist?
|
|
31
|
+
@errors << "stack path #{@config_path} doesn't exist"
|
|
38
32
|
end
|
|
39
33
|
|
|
40
34
|
unless stack_rb_path.exist?
|
|
@@ -44,11 +38,7 @@ module Minfra
|
|
|
44
38
|
end
|
|
45
39
|
|
|
46
40
|
def stack_rb_path
|
|
47
|
-
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def cluster_path
|
|
51
|
-
release_path.join("cluster.yaml")
|
|
41
|
+
config_path.join('stack.rb')
|
|
52
42
|
end
|
|
53
43
|
|
|
54
44
|
def compose_path(blank: false)
|
|
@@ -65,17 +55,8 @@ module Minfra
|
|
|
65
55
|
@errors.join(";\n")
|
|
66
56
|
end
|
|
67
57
|
|
|
68
|
-
# we use a special file to flag the this stack is releasable to an environment
|
|
69
|
-
def releasable?
|
|
70
|
-
switch_path.exist?
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def switch_path
|
|
74
|
-
release_path.join("#{@env}_#{rancher_stack_name}.sh")
|
|
75
|
-
end
|
|
76
|
-
|
|
77
58
|
def release_path
|
|
78
|
-
@
|
|
59
|
+
@result_path
|
|
79
60
|
end
|
|
80
61
|
|
|
81
62
|
|
data/lib/minfra/cli/config.rb
CHANGED
|
@@ -16,6 +16,7 @@ module Minfra
|
|
|
16
16
|
attr_reader :base_path
|
|
17
17
|
attr_reader :config_path
|
|
18
18
|
attr_reader :stacks_path
|
|
19
|
+
attr_reader :status_path
|
|
19
20
|
attr_reader :me_path
|
|
20
21
|
attr_reader :kube_path
|
|
21
22
|
attr_reader :kube_config_path
|
|
@@ -41,6 +42,7 @@ module Minfra
|
|
|
41
42
|
@project_config_path=@base_path.join("config","project.json")
|
|
42
43
|
@config_path = @me_path.join('config.json')
|
|
43
44
|
@stacks_path = @base_path.join('stacks')
|
|
45
|
+
@status_path = @base_path.join('state')
|
|
44
46
|
@kube_path=@me_path.join('kube')
|
|
45
47
|
@kube_config_path=@kube_path.join('config')
|
|
46
48
|
@kind_config_path=@me_path.join("kind.yaml.erb")
|
data/lib/minfra/cli/logging.rb
CHANGED
|
@@ -11,15 +11,15 @@ module Minfra
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def info(str)
|
|
14
|
-
|
|
14
|
+
STDERR.puts str
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def debug(str)
|
|
18
|
-
|
|
18
|
+
STDERR.puts "Debug: #{str}"
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def deprecated(comment)
|
|
22
|
-
puts "DEPRECATED: #{comment}"
|
|
22
|
+
STDERR.puts "DEPRECATED: #{comment}"
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
end
|
data/lib/minfra/cli/version.rb
CHANGED
data/lib/minfra/cli.rb
CHANGED
|
@@ -16,11 +16,12 @@ module Orchparty
|
|
|
16
16
|
attr_accessor :app_config
|
|
17
17
|
attr_accessor :options
|
|
18
18
|
|
|
19
|
-
def initialize(cluster_name: , namespace:, file_path: , app_config:, out_io: STDOUT)
|
|
19
|
+
def initialize(cluster_name: , namespace:, file_path: , app_config:, out_io: STDOUT, app: )
|
|
20
20
|
self.cluster_name = cluster_name
|
|
21
21
|
self.namespace = namespace
|
|
22
22
|
self.dir_path = file_path
|
|
23
23
|
self.app_config = app_config
|
|
24
|
+
@app = app
|
|
24
25
|
@out_io = out_io
|
|
25
26
|
self.options=options
|
|
26
27
|
end
|
|
@@ -158,14 +159,13 @@ module Orchparty
|
|
|
158
159
|
|
|
159
160
|
def build_chart(chart)
|
|
160
161
|
params = chart._services.map {|s| app_config.services[s.to_sym] }.map{|s| [s.name, s]}.to_h
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
162
|
+
dir = @app.status_dir.join('helm')
|
|
163
|
+
dir.mkpath
|
|
164
|
+
run(templates_path: File.expand_path(chart.template, self.dir_path), params: params, output_chart_path: dir, chart: chart)
|
|
165
|
+
yield dir
|
|
165
166
|
end
|
|
166
167
|
|
|
167
168
|
def run(templates_path:, params:, output_chart_path:, chart: )
|
|
168
|
-
system("mkdir -p #{output_chart_path}")
|
|
169
169
|
system("mkdir -p #{File.join(output_chart_path, 'templates')}")
|
|
170
170
|
|
|
171
171
|
system("cp #{File.join(templates_path, 'values.yaml')} #{File.join(output_chart_path, 'values.yaml')}")
|
|
@@ -256,12 +256,14 @@ class KubernetesApplication
|
|
|
256
256
|
attr_accessor :file_path
|
|
257
257
|
attr_accessor :namespace
|
|
258
258
|
attr_accessor :app_config
|
|
259
|
+
attr_reader :status_dir
|
|
259
260
|
|
|
260
|
-
def initialize(app_config: [], namespace:, cluster_name:, file_name:, out_io: STDOUT)
|
|
261
|
+
def initialize(app_config: [], namespace:, cluster_name:, file_name:, status_dir:, out_io: STDOUT)
|
|
261
262
|
self.file_path = Pathname.new(file_name).parent.expand_path
|
|
262
263
|
self.cluster_name = cluster_name
|
|
263
264
|
self.namespace = namespace
|
|
264
265
|
self.app_config = app_config
|
|
266
|
+
@status_dir = status_dir
|
|
265
267
|
@out_io= out_io
|
|
266
268
|
end
|
|
267
269
|
|
|
@@ -295,7 +297,7 @@ class KubernetesApplication
|
|
|
295
297
|
services.each do |name|
|
|
296
298
|
service = app_config[:services][name]
|
|
297
299
|
puts "Service: #{name}(#{service._type}) #{method}"
|
|
298
|
-
"::Orchparty::Services::#{service._type.classify}".constantize.new(cluster_name: cluster_name, namespace: namespace, file_path: file_path, app_config: app_config, out_io: @out_io).send(method, service)
|
|
300
|
+
"::Orchparty::Services::#{service._type.classify}".constantize.new(cluster_name: cluster_name, namespace: namespace, file_path: file_path, app_config: app_config, out_io: @out_io, app: self).send(method, service)
|
|
299
301
|
end
|
|
300
302
|
end
|
|
301
303
|
end
|
data/lib/orchparty.rb
CHANGED
|
@@ -23,12 +23,14 @@ module Orchparty
|
|
|
23
23
|
class App
|
|
24
24
|
attr_reader :options
|
|
25
25
|
|
|
26
|
-
def initialize(cluster_name:, application_name:, force_variable_definition:, file_name:, options: {})
|
|
26
|
+
def initialize(cluster_name:, application_name:, force_variable_definition:, file_name:, status_dir:, options: {})
|
|
27
27
|
@cluster_name = cluster_name
|
|
28
28
|
@application_name = application_name
|
|
29
29
|
@force_variable_definiton = force_variable_definition
|
|
30
30
|
@file_name = file_name
|
|
31
|
+
@status_dir = status_dir
|
|
31
32
|
@options = options
|
|
33
|
+
|
|
32
34
|
Orchparty.options=options
|
|
33
35
|
|
|
34
36
|
load_plugins
|
|
@@ -55,7 +57,14 @@ module Orchparty
|
|
|
55
57
|
def app(out_io: STDOUT)
|
|
56
58
|
parsed = Orchparty::Kubernetes::DSLParser.new(@file_name).parse
|
|
57
59
|
app_config = Transformations.transform_kubernetes(parsed, force_variable_definition: @force_variable_definition).applications[@application_name]
|
|
58
|
-
KubernetesApplication.new(
|
|
60
|
+
KubernetesApplication.new(
|
|
61
|
+
app_config: app_config,
|
|
62
|
+
namespace: @application_name,
|
|
63
|
+
cluster_name: @cluster_name,
|
|
64
|
+
file_name: @file_name,
|
|
65
|
+
status_dir: @status_dir,
|
|
66
|
+
out_io: out_io
|
|
67
|
+
)
|
|
59
68
|
end
|
|
60
69
|
|
|
61
70
|
def generate(plugin_name, options, plugin_options)
|
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: 1.0
|
|
4
|
+
version: 1.1.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: 2022-
|
|
11
|
+
date: 2022-10-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: thor
|
|
@@ -154,6 +154,9 @@ files:
|
|
|
154
154
|
- ".gitignore"
|
|
155
155
|
- CHANGELOG.md
|
|
156
156
|
- Dockerfile
|
|
157
|
+
- Gemfile
|
|
158
|
+
- Gemfile.lock
|
|
159
|
+
- README.md
|
|
157
160
|
- bin/build
|
|
158
161
|
- bin/console
|
|
159
162
|
- bin/container_exec
|