minfra-cli 0.2.2 → 1.0.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/exe/minfra +3 -1
- data/lib/minfra/cli/config.rb +7 -9
- data/lib/minfra/cli/version.rb +1 -1
- data/lib/minfra/cli.rb +65 -8
- data/lib/orchparty/kubernetes_application.rb +2 -2
- data/minfra-cli.gemspec +3 -0
- metadata +45 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a6dedf2d900fb64c7e8b58684942c15e67199910499d8a9afc9c20459deda7d
|
4
|
+
data.tar.gz: c7f6d2b107c53169ac51830e7962c2b433f5a533d624c0ea18b23eba9eb159e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e17628bc18b689e5033226b6cdc262dc0738423663110dcdd8ab5747c17fddcb04f486ae885b767f7b356ec10aa996a2382694ab897eaf4d945e89a4a5d91e31
|
7
|
+
data.tar.gz: 60b5b1f9055d47386232d8ce7b980f8818e1a028b51673ff9a820c92970457fc587c9b427fa5d439973cfdd5e8dbc766065eb50cf3e25052eda9fc47ef9fdd54
|
data/CHANGELOG.md
CHANGED
data/exe/minfra
CHANGED
data/lib/minfra/cli/config.rb
CHANGED
@@ -44,10 +44,12 @@ module Minfra
|
|
44
44
|
@kube_path=@me_path.join('kube')
|
45
45
|
@kube_config_path=@kube_path.join('config')
|
46
46
|
@kind_config_path=@me_path.join("kind.yaml.erb")
|
47
|
-
|
48
|
-
|
49
|
-
@
|
50
|
-
|
47
|
+
|
48
|
+
# @project_minfrarc_path = @base_path.join("config",'minfrarc.rb')
|
49
|
+
# require @project_minfrarc_path if @project_minfrarc_path.exist?
|
50
|
+
# @me_minfrarc_path = @me_path.join('minfrarc.rb')
|
51
|
+
# require @me_minfrarc_path if @me_minfrarc_path.exist?
|
52
|
+
|
51
53
|
if config_path.exist?
|
52
54
|
@config = Hashie::Mash.new(JSON.parse(Minfra::Cli::Templater.render(File.read(config_path),{})))
|
53
55
|
else
|
@@ -61,11 +63,7 @@ module Minfra
|
|
61
63
|
debug( "loading config env: #{orch_env} #{@orch_env}" )
|
62
64
|
return self if defined?(@orch_env)
|
63
65
|
@orch_env = orch_env
|
64
|
-
@orch_env_config
|
65
|
-
@project= @project.
|
66
|
-
deep_merge(@project.environments[@orch_env]).
|
67
|
-
deep_merge(@config).
|
68
|
-
deep_merge(@orch_env_config)
|
66
|
+
@orch_env_config=Hashie::Mash.new
|
69
67
|
@orch_env_config['env']=@orch_env
|
70
68
|
self
|
71
69
|
end
|
data/lib/minfra/cli/version.rb
CHANGED
data/lib/minfra/cli.rb
CHANGED
@@ -3,6 +3,7 @@ require 'open3'
|
|
3
3
|
require 'json'
|
4
4
|
require 'ostruct'
|
5
5
|
require 'orchparty'
|
6
|
+
require 'hiera'
|
6
7
|
|
7
8
|
require_relative 'cli/logging'
|
8
9
|
require_relative 'cli/config'
|
@@ -25,12 +26,75 @@ module Minfra
|
|
25
26
|
module Cli
|
26
27
|
extend Minfra::Cli::Logging
|
27
28
|
|
29
|
+
|
30
|
+
def self.init(argv)
|
31
|
+
@argv = argv
|
32
|
+
# we'll set the context very early!
|
33
|
+
|
34
|
+
if idx=@argv.index("-e")
|
35
|
+
@config = Config.load(@argv[idx+1])
|
36
|
+
@argv.delete_at(idx)
|
37
|
+
@argv.delete_at(idx)
|
38
|
+
else
|
39
|
+
@config = Config.load('dev')
|
40
|
+
end
|
41
|
+
|
42
|
+
hiera_init
|
43
|
+
|
44
|
+
Minfra::Cli::Plugins.load
|
45
|
+
Minfra::Cli.scan
|
46
|
+
require_relative 'cli/main_command'
|
47
|
+
Minfra::Cli.resolve
|
48
|
+
|
49
|
+
project_minfrarc_path = @config.base_path.join("config",'minfrarc.rb')
|
50
|
+
require project_minfrarc_path if project_minfrarc_path.exist?
|
51
|
+
me_minfrarc_path = @config.me_path.join('minfrarc.rb')
|
52
|
+
require @me_minfrarc_path if me_minfrarc_path.exist?
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.run
|
57
|
+
Minfra::Cli::Main.start(@argv)
|
58
|
+
end
|
59
|
+
|
28
60
|
def self.root_path
|
29
61
|
Pathname.new(File.expand_path(File.join(__FILE__, '../../../')))
|
30
62
|
end
|
31
63
|
|
64
|
+
def self.hiera_init
|
65
|
+
@hiera_root = Pathname.new("#{ENV["MINFRA_PATH"]}/hiera")
|
66
|
+
hiera = Hiera.new(:config => @hiera_root.join('hiera.yaml').to_s)
|
67
|
+
Hiera.logger=:noop
|
68
|
+
env= @config.orch_env
|
69
|
+
raise("unknown environment #{env}, I expact a file at hiera/hieradata/environments/#{env}.eyaml") unless @hiera_root.join("hieradata/environments/#{env}.eyaml").exist?
|
70
|
+
|
71
|
+
|
72
|
+
scope={ "hieraroot" => @hiera_root.to_s, "env" => env}
|
73
|
+
special_lookups=hiera.lookup("lookup_options", {}, scope, nil, :priority)
|
74
|
+
|
75
|
+
node_scope=hiera.lookup("env", {}, scope, nil, :deeper)
|
76
|
+
scope=scope.merge(node_scope)
|
77
|
+
cache={}
|
78
|
+
|
79
|
+
Kernel.define_method(:l) do |value,default=nil|
|
80
|
+
return cache[value] if cache.has_key?(value)
|
81
|
+
|
82
|
+
if special_lookups[value]
|
83
|
+
lookup_type={ merge_behavior: special_lookups[value]["merge"].to_sym }
|
84
|
+
else
|
85
|
+
lookup_type=:native #priority
|
86
|
+
end
|
87
|
+
|
88
|
+
result=hiera.lookup(value, default, scope, nil, lookup_type)
|
89
|
+
result=Hashie::Mash.new(result) if result.kind_of?(Hash)
|
90
|
+
cache[value] = result
|
91
|
+
result
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
|
32
96
|
def self.config
|
33
|
-
@config
|
97
|
+
@config
|
34
98
|
end
|
35
99
|
def self.scan
|
36
100
|
root_path.join("lib/minfra/cli/commands").each_child do |command_path|
|
@@ -71,10 +135,3 @@ module Minfra
|
|
71
135
|
end
|
72
136
|
end
|
73
137
|
end
|
74
|
-
|
75
|
-
Minfra::Cli::Plugins.load
|
76
|
-
Minfra::Cli.scan
|
77
|
-
require_relative 'cli/main_command'
|
78
|
-
Minfra::Cli.resolve
|
79
|
-
|
80
|
-
|
@@ -158,7 +158,7 @@ module Orchparty
|
|
158
158
|
|
159
159
|
def build_chart(chart)
|
160
160
|
params = chart._services.map {|s| app_config.services[s.to_sym] }.map{|s| [s.name, s]}.to_h
|
161
|
-
Dir.mktmpdir do |dir|
|
161
|
+
Dir.mktmpdir("#{chart.name}-") do |dir|
|
162
162
|
run(templates_path: File.expand_path(chart.template, self.dir_path), params: params, output_chart_path: dir, chart: chart)
|
163
163
|
yield dir
|
164
164
|
end
|
@@ -294,7 +294,7 @@ class KubernetesApplication
|
|
294
294
|
services = combine_charts(app_config)
|
295
295
|
services.each do |name|
|
296
296
|
service = app_config[:services][name]
|
297
|
-
puts "Service: #{name} #{method}"
|
297
|
+
puts "Service: #{name}(#{service._type}) #{method}"
|
298
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)
|
299
299
|
end
|
300
300
|
end
|
data/minfra-cli.gemspec
CHANGED
@@ -33,4 +33,7 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_runtime_dependency "hashie", "~>3.5"
|
34
34
|
spec.add_runtime_dependency "activesupport", "~> 6.1"
|
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"
|
36
39
|
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: 0.
|
4
|
+
version: 1.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: 2022-
|
11
|
+
date: 2022-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -100,6 +100,48 @@ dependencies:
|
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '2.7'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: hiera
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - '='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 3.9.0
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - '='
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 3.9.0
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: hiera-eyaml
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - '='
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: 3.3.0
|
124
|
+
type: :runtime
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - '='
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: 3.3.0
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: hiera-eyaml-gpg
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - '='
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: 0.7.4
|
138
|
+
type: :runtime
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - '='
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: 0.7.4
|
103
145
|
description: A cli framework for k8s based development and deployment.
|
104
146
|
email:
|
105
147
|
- peter.schrammel@gmx.de
|
@@ -188,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
230
|
- !ruby/object:Gem::Version
|
189
231
|
version: '0'
|
190
232
|
requirements: []
|
191
|
-
rubygems_version: 3.1.
|
233
|
+
rubygems_version: 3.1.6
|
192
234
|
signing_key:
|
193
235
|
specification_version: 4
|
194
236
|
summary: A cli framework for k8s based development and deployment.
|