minfra-cli 1.0.2 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -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 +11 -6
- data/lib/minfra/cli/commands/tag.rb +4 -4
- 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/orchparty/kubernetes_application.rb +10 -8
- data/lib/orchparty.rb +11 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce377c35c375bead26c389cb71f133d00c34943e2501b31f2857faa79fb6db80
|
4
|
+
data.tar.gz: 79f36a7b3687605752d7993cb74f2cc03a959ff50d49e55363c419333533c846
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95da7b04165f9447658c333185d97e7d200d9b19baf00477f8c10012df1b6248099437b57cd0507dbc860cc7912a93ba65ccdd1bd9800207077d382345b47ea9
|
7
|
+
data.tar.gz: 3a69224f2098e83977dbbd111a124e0f1238b055e3326627456f3b17cfdcd3297f0ec535cd029936d2d05efe4e5e5a9285b68907529690b9af3dd17aaa31ff5e
|
data/CHANGELOG.md
CHANGED
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,16 +5,17 @@ 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
16
|
@cluster = cluster.freeze || l!("cluster").id
|
17
|
-
|
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
|
@@ -26,8 +27,8 @@ module Minfra
|
|
26
27
|
end
|
27
28
|
|
28
29
|
def valid?
|
29
|
-
unless @
|
30
|
-
@errors << "stack path #{@
|
30
|
+
unless @config_path.exist?
|
31
|
+
@errors << "stack path #{@config_path} doesn't exist"
|
31
32
|
end
|
32
33
|
|
33
34
|
unless stack_rb_path.exist?
|
@@ -37,7 +38,11 @@ module Minfra
|
|
37
38
|
end
|
38
39
|
|
39
40
|
def stack_rb_path
|
41
|
+
<<<<<<< HEAD
|
40
42
|
release_path.join('stack.rb')
|
43
|
+
=======
|
44
|
+
config_path.join('stack.rb')
|
45
|
+
>>>>>>> 105dc30122db54328cdf1707f5d3d10d4d8792c3
|
41
46
|
end
|
42
47
|
|
43
48
|
def compose_path(blank: false)
|
@@ -55,7 +60,7 @@ module Minfra
|
|
55
60
|
end
|
56
61
|
|
57
62
|
def release_path
|
58
|
-
@
|
63
|
+
@result_path
|
59
64
|
end
|
60
65
|
|
61
66
|
|
@@ -17,11 +17,11 @@ module Minfra
|
|
17
17
|
info 'Creating tag.'
|
18
18
|
debug "Using .tags folder..."
|
19
19
|
write_tag_folder_file(message)
|
20
|
-
run_cmd(cmd_add_tag_info("#{@tags_folder}/#{tag_name}"), :system)
|
21
|
-
run_cmd(cmd_create_tag_commit, :system)
|
20
|
+
#run_cmd(cmd_add_tag_info("#{@tags_folder}/#{tag_name}"), :system)
|
21
|
+
#run_cmd(cmd_create_tag_commit, :system)
|
22
22
|
run_cmd(cmd_tag_commit(message), :system)
|
23
|
-
info 'Pushing tag to remote.'
|
24
|
-
run_cmd(cmd_push, :system)
|
23
|
+
# info 'Pushing tag to remote.'
|
24
|
+
# run_cmd(cmd_push, :system)
|
25
25
|
run_cmd(cmd_push_tag, :system)
|
26
26
|
end
|
27
27
|
|
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
@@ -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.2.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-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -156,6 +156,7 @@ files:
|
|
156
156
|
- Dockerfile
|
157
157
|
- Gemfile
|
158
158
|
- Gemfile.lock
|
159
|
+
- README.md
|
159
160
|
- bin/build
|
160
161
|
- bin/console
|
161
162
|
- bin/container_exec
|