kerbi 0.0.1 → 0.0.5
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/lib/cli/base_handler.rb +194 -0
- data/lib/cli/base_serializer.rb +120 -0
- data/lib/cli/config_handler.rb +51 -0
- data/lib/cli/entry_serializers.rb +99 -0
- data/lib/cli/project_handler.rb +2 -2
- data/lib/cli/release_handler.rb +41 -0
- data/lib/cli/release_serializer.rb +46 -0
- data/lib/cli/root_handler.rb +34 -13
- data/lib/cli/state_handler.rb +88 -0
- data/lib/cli/values_handler.rb +4 -3
- data/{boilerplate → lib/code-gen/new-project}/Gemfile.erb +0 -0
- data/lib/code-gen/new-project/kerbifile.rb.erb +9 -0
- data/lib/code-gen/new-project/values.yaml.erb +1 -0
- data/lib/config/cli_schema.rb +343 -28
- data/lib/config/config_file.rb +60 -0
- data/lib/config/globals.rb +4 -0
- data/lib/config/run_opts.rb +162 -0
- data/lib/config/state_consts.rb +11 -0
- data/lib/kerbi.rb +35 -10
- data/lib/main/code_gen.rb +1 -1
- data/lib/main/errors.rb +115 -0
- data/lib/main/mixer.rb +20 -10
- data/lib/mixins/cli_state_helpers.rb +108 -0
- data/lib/mixins/cm_backend_testing.rb +109 -0
- data/lib/mixins/entry_tag_logic.rb +183 -0
- data/lib/state/base_backend.rb +93 -0
- data/lib/state/config_map_backend.rb +173 -0
- data/lib/state/entry.rb +173 -0
- data/lib/state/entry_set.rb +137 -0
- data/lib/state/metadata.yaml.erb +11 -0
- data/lib/state/mixers.rb +23 -0
- data/lib/state/resources.yaml.erb +17 -0
- data/lib/utils/cli.rb +108 -9
- data/lib/utils/helm.rb +10 -12
- data/lib/utils/k8s_auth.rb +87 -0
- data/lib/utils/misc.rb +36 -1
- data/lib/utils/mixing.rb +1 -1
- data/lib/utils/values.rb +13 -22
- data/spec/cli/config_handler_spec.rb +38 -0
- data/spec/cli/release_handler_spec.rb +127 -0
- data/spec/cli/root_handler_spec.rb +100 -0
- data/spec/cli/state_handler_spec.rb +108 -0
- data/spec/cli/values_handler_spec.rb +17 -0
- data/spec/fixtures/expectations/common/bad-tag.txt +1 -0
- data/spec/fixtures/expectations/config/bad-set.txt +1 -0
- data/spec/fixtures/expectations/config/set.txt +1 -0
- data/spec/fixtures/expectations/config/show-default.yaml +6 -0
- data/spec/fixtures/expectations/release/delete.txt +1 -0
- data/spec/fixtures/expectations/release/init-already-existed.txt +2 -0
- data/spec/fixtures/expectations/release/init-both-created.txt +2 -0
- data/spec/fixtures/expectations/release/list.txt +5 -0
- data/spec/fixtures/expectations/release/status-all-working.txt +5 -0
- data/spec/fixtures/expectations/release/status-data-unreadable.txt +5 -0
- data/spec/fixtures/expectations/release/status-not-provisioned.txt +5 -0
- data/spec/fixtures/expectations/root/template-inlines.yaml +31 -0
- data/spec/fixtures/expectations/root/template-production.yaml +31 -0
- data/spec/fixtures/expectations/root/template-read-inlines.yaml +31 -0
- data/spec/fixtures/expectations/root/template-read.yaml +31 -0
- data/spec/fixtures/expectations/root/template-write.yaml +31 -0
- data/spec/fixtures/expectations/root/template.yaml +31 -0
- data/spec/fixtures/expectations/root/values.json +28 -0
- data/spec/fixtures/expectations/state/delete.txt +1 -0
- data/spec/fixtures/expectations/state/demote.txt +1 -0
- data/spec/fixtures/expectations/state/list.json +51 -0
- data/spec/fixtures/expectations/state/list.txt +6 -0
- data/spec/fixtures/expectations/state/list.yaml +35 -0
- data/spec/fixtures/expectations/state/promote.txt +1 -0
- data/spec/fixtures/expectations/state/prune-candidates.txt +1 -0
- data/spec/fixtures/expectations/state/retag.txt +1 -0
- data/spec/fixtures/expectations/state/set.txt +1 -0
- data/spec/fixtures/expectations/state/show.json +13 -0
- data/spec/fixtures/expectations/state/show.txt +13 -0
- data/spec/fixtures/expectations/state/show.yaml +8 -0
- data/spec/fixtures/expectations/values/order-of-precedence.yaml +4 -0
- data/spec/main/configmap_backend_spec.rb +110 -0
- data/spec/main/project_code_gen_spec.rb +8 -2
- data/spec/main/state_entry_set_spec.rb +112 -0
- data/spec/main/state_entry_spec.rb +109 -0
- data/spec/mini-projects/hello-kerbi/common/metadata.yaml.erb +5 -0
- data/spec/mini-projects/hello-kerbi/consts.rb +5 -0
- data/spec/mini-projects/hello-kerbi/helpers.rb +8 -0
- data/spec/mini-projects/hello-kerbi/kerbifile.rb +18 -0
- data/spec/mini-projects/hello-kerbi/pod-and-service.yaml.erb +23 -0
- data/spec/mini-projects/hello-kerbi/values/production.yaml +2 -0
- data/spec/mini-projects/hello-kerbi/values/v2.yaml +2 -0
- data/spec/mini-projects/hello-kerbi/values/values.yaml +4 -0
- data/spec/spec_helper.rb +143 -1
- data/spec/utils/helm_spec.rb +89 -109
- data/spec/utils/k8s_auth_spec.rb +32 -0
- data/spec/utils/misc_utils_spec.rb +9 -0
- data/spec/utils/values_utils_spec.rb +12 -19
- metadata +143 -16
- data/boilerplate/kerbifile.rb.erb +0 -9
- data/boilerplate/values.yaml.erb +0 -1
- data/lib/cli/base.rb +0 -83
- data/lib/config/cli_opts.rb +0 -50
- data/lib/config/manager.rb +0 -36
- data/lib/main/state_manager.rb +0 -47
- data/lib/utils/kubectl.rb +0 -58
- data/spec/main/examples_spec.rb +0 -12
- data/spec/main/state_manager_spec.rb +0 -84
- data/spec/utils/state_utils.rb +0 -15
data/spec/utils/helm_spec.rb
CHANGED
@@ -2,113 +2,93 @@ require_relative './../spec_helper'
|
|
2
2
|
|
3
3
|
RSpec.describe Kerbi::Utils::Helm do
|
4
4
|
|
5
|
-
subject { Kerbi::Utils::Helm }
|
6
|
-
|
7
|
-
def find_res(hashes, kind, name)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
subject.del_tmp_values_file
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
describe '#can_exec?' do
|
100
|
-
context 'exec working' do
|
101
|
-
it 'returns true' do
|
102
|
-
config.helm_exec = 'helm'
|
103
|
-
expect(subject.can_exec?).to eq(true)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
context '.exec not working' do
|
108
|
-
it 'returns false' do
|
109
|
-
config.helm_exec = 'not-helm'
|
110
|
-
expect(subject.can_exec?).to eq(false)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
5
|
+
# subject { Kerbi::Utils::Helm }
|
6
|
+
#
|
7
|
+
# def find_res(hashes, kind, name)
|
8
|
+
# hashes.find do |hash|
|
9
|
+
# hash['kind'] == kind && hash['metadata']['name'] == name
|
10
|
+
# end
|
11
|
+
# end
|
12
|
+
#
|
13
|
+
# describe '.template' do
|
14
|
+
# let(:repo_org) { "jetstack" }
|
15
|
+
# let(:repo_url) { "https://charts.jetstack.io" }
|
16
|
+
# let(:chart) { "#{repo_org}/cert-manager" }
|
17
|
+
# let :values do
|
18
|
+
# {
|
19
|
+
# cainjector: {
|
20
|
+
# serviceAccount: {
|
21
|
+
# automountServiceAccountToken: "foo"
|
22
|
+
# }
|
23
|
+
# }
|
24
|
+
# }
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# before :each do
|
28
|
+
# system("helm repo add #{repo_org} #{repo_url}")
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# context 'with existing chart' do
|
32
|
+
# it 'returns the templated yaml string' do
|
33
|
+
# res_dicts = subject.template('kerbi', chart, values: values)
|
34
|
+
# expect(res_dicts.class).to eq(Array)
|
35
|
+
# expect(res_dicts.count).to be_within(40).of(40)
|
36
|
+
# end
|
37
|
+
# end
|
38
|
+
# end
|
39
|
+
#
|
40
|
+
# describe '.encode_inline_assigns' do
|
41
|
+
# context 'when assignments are flat' do
|
42
|
+
# it 'returns the right string' do
|
43
|
+
# #noinspection SpellCheckingInspection
|
44
|
+
# actual = subject.encode_inline_assigns(
|
45
|
+
# 'bar': 'bar',
|
46
|
+
# 'foo.bar': 'foo.bar'
|
47
|
+
# )
|
48
|
+
# expected = "--set bar=bar --set foo.bar=foo.bar"
|
49
|
+
# expect(actual).to eq(expected)
|
50
|
+
# end
|
51
|
+
# end
|
52
|
+
#
|
53
|
+
# context 'when values are nested' do
|
54
|
+
# it 'raises an runtime error' do
|
55
|
+
# expect do
|
56
|
+
# subject.encode_inline_assigns('bar': { foo: 'bar'})
|
57
|
+
# end.to raise_error("Assignments must be flat")
|
58
|
+
# end
|
59
|
+
# end
|
60
|
+
# end
|
61
|
+
#
|
62
|
+
# describe ".make_tmp_values_file" do
|
63
|
+
# it 'creates the tmp file with yaml and returns the path' do
|
64
|
+
# path = subject.make_tmp_values_file(foo: 'bar')
|
65
|
+
# expect(YAML.load_file(path)).to eq('foo' => 'bar')
|
66
|
+
# end
|
67
|
+
# end
|
68
|
+
#
|
69
|
+
# describe '.del_tmp_values_file' do
|
70
|
+
# context 'when the file exists' do
|
71
|
+
# it 'delete the file' do
|
72
|
+
# path = subject.make_tmp_values_file(foo: 'bar')
|
73
|
+
# expect(File.exists?(path)).to be_truthy
|
74
|
+
# subject.del_tmp_values_file
|
75
|
+
# expect(File.exists?(path)).to be_falsey
|
76
|
+
# end
|
77
|
+
# end
|
78
|
+
#
|
79
|
+
# context 'when the file does not exist' do
|
80
|
+
# it 'does not raise an error' do
|
81
|
+
# subject.del_tmp_values_file
|
82
|
+
# end
|
83
|
+
# end
|
84
|
+
# end
|
85
|
+
#
|
86
|
+
# describe '#can_exec?' do
|
87
|
+
# context 'exec working' do
|
88
|
+
# it 'returns true' do
|
89
|
+
# # config.helm_exec = 'helm'
|
90
|
+
# expect(subject.can_exec?).to eq(true)
|
91
|
+
# end
|
92
|
+
# end
|
93
|
+
# end
|
114
94
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative './../spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Kerbi::Utils::K8sAuth do
|
4
|
+
#
|
5
|
+
# def make_client(bundle)
|
6
|
+
# Kubeclient::Client.new(
|
7
|
+
# bundle[:endpoint],
|
8
|
+
# "v1",
|
9
|
+
# **bundle[:options]
|
10
|
+
# )
|
11
|
+
# end
|
12
|
+
#
|
13
|
+
# describe ".kube_config_client" do
|
14
|
+
# context "with valid kube-config options" do
|
15
|
+
# context "using the system default" do
|
16
|
+
# it "returns a working client" do
|
17
|
+
# bundle = subject.kube_config_bundle(path: nil, name: nil)
|
18
|
+
# namespaces = make_client(bundle).get_namespaces
|
19
|
+
# expect(namespaces.any?).to be_truthy
|
20
|
+
# end
|
21
|
+
# end
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# context "with an invalid kube-config options" do
|
25
|
+
# it "returns a working client" do
|
26
|
+
# expect {
|
27
|
+
# subject.kube_config_bundle(path: "bad-path")
|
28
|
+
# }. to raise_exception(Exception)
|
29
|
+
# end
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
end
|
@@ -6,9 +6,9 @@ RSpec.describe Kerbi::Utils::Values do
|
|
6
6
|
let(:root) { Kerbi::Testing::TEST_YAMLS_DIR }
|
7
7
|
before(:each) { Kerbi::Testing.reset_test_yamls_dir }
|
8
8
|
|
9
|
-
describe ".resolve_fname_expr" do
|
10
|
-
def func(
|
11
|
-
subject.
|
9
|
+
describe ".resolve_fname_expr (old)" do
|
10
|
+
def func(fname)
|
11
|
+
subject.resolve_fname_exprs([fname], root: root)
|
12
12
|
end
|
13
13
|
|
14
14
|
context "when the expression can be resolved" do
|
@@ -19,9 +19,9 @@ RSpec.describe Kerbi::Utils::Values do
|
|
19
19
|
Kerbi::Testing.make_yaml("x.yaml.erb", "n/a")
|
20
20
|
end
|
21
21
|
it "returns that file instead over similar ones" do
|
22
|
-
expect(func("x")).to eq("#{root}/x")
|
23
|
-
expect(func("x.yaml")).to eq("#{root}/x.yaml")
|
24
|
-
expect(func("x.yaml.erb")).to eq("#{root}/x.yaml.erb")
|
22
|
+
expect(func("x")).to eq(["#{root}/x"])
|
23
|
+
expect(func("x.yaml")).to eq(["#{root}/x.yaml"])
|
24
|
+
expect(func("x.yaml.erb")).to eq(["#{root}/x.yaml.erb"])
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -32,16 +32,18 @@ RSpec.describe Kerbi::Utils::Values do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it "returns the closes match" do
|
35
|
-
expect(func("y")).to eq("#{root}/y.yaml")
|
35
|
+
expect(func("y")).to eq(["#{root}/y.yaml"])
|
36
36
|
Kerbi::Testing.del_testfile("y.yaml")
|
37
|
-
expect(func("y")).to eq("#{root}/y.yaml.erb")
|
37
|
+
expect(func("y")).to eq(["#{root}/y.yaml.erb"])
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
context "when the expression cannot be resolved" do
|
43
|
-
it "
|
44
|
-
|
43
|
+
it "raises a Kerbi::ValuesFileNotFoundError with the right message" do
|
44
|
+
cls = Kerbi::ValuesFileNotFoundError
|
45
|
+
msg = "Could not resolve values file 'dne' in /tmp/kerbi-yamls"
|
46
|
+
expect { func("dne") }.to raise_error(cls, msg)
|
45
47
|
end
|
46
48
|
end
|
47
49
|
end
|
@@ -57,15 +59,6 @@ RSpec.describe Kerbi::Utils::Values do
|
|
57
59
|
Kerbi::Testing.make_yaml("y.yaml", "n/a")
|
58
60
|
end
|
59
61
|
|
60
|
-
context "with no missing files and values present" do
|
61
|
-
let(:expected) { %W[#{root}/values.yaml #{root}/x.yaml ] }
|
62
|
-
|
63
|
-
it "returns the expect list of final paths" do
|
64
|
-
Kerbi::Testing.make_yaml("values.yaml", "n/a")
|
65
|
-
expect(func(["x.yaml"])).to eq(expected)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
62
|
context "with no missing file other than 'values'" do
|
70
63
|
it "returns the expect list of final paths" do
|
71
64
|
expect(func(["x.yaml"])).to eq(["#{root}/x.yaml"])
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kerbi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xavier Millot
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -90,6 +90,26 @@ dependencies:
|
|
90
90
|
- - ">="
|
91
91
|
- !ruby/object:Gem::Version
|
92
92
|
version: 0.8.1
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: kubeclient
|
95
|
+
requirement: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - "~>"
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '4.9'
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 4.9.1
|
103
|
+
type: :runtime
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '4.9'
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 4.9.1
|
93
113
|
description: Kerbi is a multi-strategy Kubernetes manifest templating engine.
|
94
114
|
email: xavier@nmachine.io
|
95
115
|
executables:
|
@@ -98,39 +118,101 @@ extensions: []
|
|
98
118
|
extra_rdoc_files: []
|
99
119
|
files:
|
100
120
|
- bin/kerbi
|
101
|
-
-
|
102
|
-
-
|
103
|
-
-
|
104
|
-
- lib/cli/
|
121
|
+
- lib/cli/base_handler.rb
|
122
|
+
- lib/cli/base_serializer.rb
|
123
|
+
- lib/cli/config_handler.rb
|
124
|
+
- lib/cli/entry_serializers.rb
|
105
125
|
- lib/cli/project_handler.rb
|
126
|
+
- lib/cli/release_handler.rb
|
127
|
+
- lib/cli/release_serializer.rb
|
106
128
|
- lib/cli/root_handler.rb
|
129
|
+
- lib/cli/state_handler.rb
|
107
130
|
- lib/cli/values_handler.rb
|
108
|
-
- lib/
|
131
|
+
- lib/code-gen/new-project/Gemfile.erb
|
132
|
+
- lib/code-gen/new-project/kerbifile.rb.erb
|
133
|
+
- lib/code-gen/new-project/values.yaml.erb
|
109
134
|
- lib/config/cli_schema.rb
|
135
|
+
- lib/config/config_file.rb
|
110
136
|
- lib/config/globals.rb
|
111
|
-
- lib/config/
|
137
|
+
- lib/config/run_opts.rb
|
138
|
+
- lib/config/state_consts.rb
|
112
139
|
- lib/kerbi.rb
|
113
140
|
- lib/main/code_gen.rb
|
141
|
+
- lib/main/errors.rb
|
114
142
|
- lib/main/mixer.rb
|
115
|
-
- lib/
|
143
|
+
- lib/mixins/cli_state_helpers.rb
|
144
|
+
- lib/mixins/cm_backend_testing.rb
|
145
|
+
- lib/mixins/entry_tag_logic.rb
|
116
146
|
- lib/mixins/mixer.rb
|
147
|
+
- lib/state/base_backend.rb
|
148
|
+
- lib/state/config_map_backend.rb
|
149
|
+
- lib/state/entry.rb
|
150
|
+
- lib/state/entry_set.rb
|
151
|
+
- lib/state/metadata.yaml.erb
|
152
|
+
- lib/state/mixers.rb
|
153
|
+
- lib/state/resources.yaml.erb
|
117
154
|
- lib/utils/cli.rb
|
118
155
|
- lib/utils/helm.rb
|
119
|
-
- lib/utils/
|
156
|
+
- lib/utils/k8s_auth.rb
|
120
157
|
- lib/utils/misc.rb
|
121
158
|
- lib/utils/mixing.rb
|
122
159
|
- lib/utils/values.rb
|
160
|
+
- spec/cli/config_handler_spec.rb
|
161
|
+
- spec/cli/release_handler_spec.rb
|
162
|
+
- spec/cli/root_handler_spec.rb
|
163
|
+
- spec/cli/state_handler_spec.rb
|
164
|
+
- spec/cli/values_handler_spec.rb
|
123
165
|
- spec/fixtures/embedding.yaml.erb
|
124
|
-
- spec/
|
166
|
+
- spec/fixtures/expectations/common/bad-tag.txt
|
167
|
+
- spec/fixtures/expectations/config/bad-set.txt
|
168
|
+
- spec/fixtures/expectations/config/set.txt
|
169
|
+
- spec/fixtures/expectations/config/show-default.yaml
|
170
|
+
- spec/fixtures/expectations/release/delete.txt
|
171
|
+
- spec/fixtures/expectations/release/init-already-existed.txt
|
172
|
+
- spec/fixtures/expectations/release/init-both-created.txt
|
173
|
+
- spec/fixtures/expectations/release/list.txt
|
174
|
+
- spec/fixtures/expectations/release/status-all-working.txt
|
175
|
+
- spec/fixtures/expectations/release/status-data-unreadable.txt
|
176
|
+
- spec/fixtures/expectations/release/status-not-provisioned.txt
|
177
|
+
- spec/fixtures/expectations/root/template-inlines.yaml
|
178
|
+
- spec/fixtures/expectations/root/template-production.yaml
|
179
|
+
- spec/fixtures/expectations/root/template-read-inlines.yaml
|
180
|
+
- spec/fixtures/expectations/root/template-read.yaml
|
181
|
+
- spec/fixtures/expectations/root/template-write.yaml
|
182
|
+
- spec/fixtures/expectations/root/template.yaml
|
183
|
+
- spec/fixtures/expectations/root/values.json
|
184
|
+
- spec/fixtures/expectations/state/delete.txt
|
185
|
+
- spec/fixtures/expectations/state/demote.txt
|
186
|
+
- spec/fixtures/expectations/state/list.json
|
187
|
+
- spec/fixtures/expectations/state/list.txt
|
188
|
+
- spec/fixtures/expectations/state/list.yaml
|
189
|
+
- spec/fixtures/expectations/state/promote.txt
|
190
|
+
- spec/fixtures/expectations/state/prune-candidates.txt
|
191
|
+
- spec/fixtures/expectations/state/retag.txt
|
192
|
+
- spec/fixtures/expectations/state/set.txt
|
193
|
+
- spec/fixtures/expectations/state/show.json
|
194
|
+
- spec/fixtures/expectations/state/show.txt
|
195
|
+
- spec/fixtures/expectations/state/show.yaml
|
196
|
+
- spec/fixtures/expectations/values/order-of-precedence.yaml
|
197
|
+
- spec/main/configmap_backend_spec.rb
|
125
198
|
- spec/main/mixer_spec.rb
|
126
199
|
- spec/main/project_code_gen_spec.rb
|
127
|
-
- spec/main/
|
200
|
+
- spec/main/state_entry_set_spec.rb
|
201
|
+
- spec/main/state_entry_spec.rb
|
202
|
+
- spec/mini-projects/hello-kerbi/common/metadata.yaml.erb
|
203
|
+
- spec/mini-projects/hello-kerbi/consts.rb
|
204
|
+
- spec/mini-projects/hello-kerbi/helpers.rb
|
205
|
+
- spec/mini-projects/hello-kerbi/kerbifile.rb
|
206
|
+
- spec/mini-projects/hello-kerbi/pod-and-service.yaml.erb
|
207
|
+
- spec/mini-projects/hello-kerbi/values/production.yaml
|
208
|
+
- spec/mini-projects/hello-kerbi/values/v2.yaml
|
209
|
+
- spec/mini-projects/hello-kerbi/values/values.yaml
|
128
210
|
- spec/mixins/mixer_mixin_spec.rb
|
129
211
|
- spec/spec_helper.rb
|
130
212
|
- spec/utils/helm_spec.rb
|
213
|
+
- spec/utils/k8s_auth_spec.rb
|
131
214
|
- spec/utils/misc_utils_spec.rb
|
132
215
|
- spec/utils/mixing_utils_spec.rb
|
133
|
-
- spec/utils/state_utils.rb
|
134
216
|
- spec/utils/values_utils_spec.rb
|
135
217
|
homepage: https://nmachine-io.github.io/kerbi
|
136
218
|
licenses:
|
@@ -156,15 +238,60 @@ signing_key:
|
|
156
238
|
specification_version: 4
|
157
239
|
summary: Multi-strategy Kubernetes manifest templating engine.
|
158
240
|
test_files:
|
241
|
+
- spec/mini-projects/hello-kerbi/common/metadata.yaml.erb
|
242
|
+
- spec/mini-projects/hello-kerbi/consts.rb
|
243
|
+
- spec/mini-projects/hello-kerbi/pod-and-service.yaml.erb
|
244
|
+
- spec/mini-projects/hello-kerbi/values/values.yaml
|
245
|
+
- spec/mini-projects/hello-kerbi/values/v2.yaml
|
246
|
+
- spec/mini-projects/hello-kerbi/values/production.yaml
|
247
|
+
- spec/mini-projects/hello-kerbi/helpers.rb
|
248
|
+
- spec/mini-projects/hello-kerbi/kerbifile.rb
|
159
249
|
- spec/spec_helper.rb
|
160
250
|
- spec/mixins/mixer_mixin_spec.rb
|
161
251
|
- spec/main/mixer_spec.rb
|
162
252
|
- spec/main/project_code_gen_spec.rb
|
163
|
-
- spec/main/
|
164
|
-
- spec/main/
|
253
|
+
- spec/main/configmap_backend_spec.rb
|
254
|
+
- spec/main/state_entry_set_spec.rb
|
255
|
+
- spec/main/state_entry_spec.rb
|
256
|
+
- spec/fixtures/expectations/common/bad-tag.txt
|
257
|
+
- spec/fixtures/expectations/root/template-read-inlines.yaml
|
258
|
+
- spec/fixtures/expectations/root/values.json
|
259
|
+
- spec/fixtures/expectations/root/template-write.yaml
|
260
|
+
- spec/fixtures/expectations/root/template-read.yaml
|
261
|
+
- spec/fixtures/expectations/root/template-inlines.yaml
|
262
|
+
- spec/fixtures/expectations/root/template.yaml
|
263
|
+
- spec/fixtures/expectations/root/template-production.yaml
|
264
|
+
- spec/fixtures/expectations/release/list.txt
|
265
|
+
- spec/fixtures/expectations/release/status-all-working.txt
|
266
|
+
- spec/fixtures/expectations/release/init-both-created.txt
|
267
|
+
- spec/fixtures/expectations/release/status-not-provisioned.txt
|
268
|
+
- spec/fixtures/expectations/release/delete.txt
|
269
|
+
- spec/fixtures/expectations/release/init-already-existed.txt
|
270
|
+
- spec/fixtures/expectations/release/status-data-unreadable.txt
|
271
|
+
- spec/fixtures/expectations/values/order-of-precedence.yaml
|
272
|
+
- spec/fixtures/expectations/state/prune-candidates.txt
|
273
|
+
- spec/fixtures/expectations/state/list.txt
|
274
|
+
- spec/fixtures/expectations/state/list.json
|
275
|
+
- spec/fixtures/expectations/state/show.yaml
|
276
|
+
- spec/fixtures/expectations/state/demote.txt
|
277
|
+
- spec/fixtures/expectations/state/delete.txt
|
278
|
+
- spec/fixtures/expectations/state/set.txt
|
279
|
+
- spec/fixtures/expectations/state/show.json
|
280
|
+
- spec/fixtures/expectations/state/list.yaml
|
281
|
+
- spec/fixtures/expectations/state/promote.txt
|
282
|
+
- spec/fixtures/expectations/state/retag.txt
|
283
|
+
- spec/fixtures/expectations/state/show.txt
|
284
|
+
- spec/fixtures/expectations/config/bad-set.txt
|
285
|
+
- spec/fixtures/expectations/config/set.txt
|
286
|
+
- spec/fixtures/expectations/config/show-default.yaml
|
165
287
|
- spec/fixtures/embedding.yaml.erb
|
288
|
+
- spec/utils/k8s_auth_spec.rb
|
166
289
|
- spec/utils/helm_spec.rb
|
167
|
-
- spec/utils/state_utils.rb
|
168
290
|
- spec/utils/values_utils_spec.rb
|
169
291
|
- spec/utils/mixing_utils_spec.rb
|
170
292
|
- spec/utils/misc_utils_spec.rb
|
293
|
+
- spec/cli/values_handler_spec.rb
|
294
|
+
- spec/cli/root_handler_spec.rb
|
295
|
+
- spec/cli/config_handler_spec.rb
|
296
|
+
- spec/cli/state_handler_spec.rb
|
297
|
+
- spec/cli/release_handler_spec.rb
|
data/boilerplate/values.yaml.erb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
message: "default message"
|
data/lib/cli/base.rb
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
module Kerbi
|
2
|
-
module Cli
|
3
|
-
|
4
|
-
##
|
5
|
-
# Superclass for all Thor CLI handlers.
|
6
|
-
class BaseHandler < Thor
|
7
|
-
|
8
|
-
protected
|
9
|
-
|
10
|
-
##
|
11
|
-
# Convenience method for printing dicts as YAML or JSON,
|
12
|
-
# according to the CLI options.
|
13
|
-
# @param [Hash|Array<Hash>] dicts
|
14
|
-
def print_dicts(dicts)
|
15
|
-
if self.cli_opts.outputs_yaml?
|
16
|
-
printable_str = Kerbi::Utils::Cli.dicts_to_yaml(dicts)
|
17
|
-
elsif self.cli_opts.outputs_json?
|
18
|
-
printable_str = Kerbi::Utils::Cli.dicts_to_json(dicts)
|
19
|
-
else
|
20
|
-
raise "Unknown output format '#{cli_opts.output_format}'"
|
21
|
-
end
|
22
|
-
puts printable_str
|
23
|
-
end
|
24
|
-
|
25
|
-
##
|
26
|
-
# Returns single merged dict containing all values given or
|
27
|
-
# pointed to by the CLI args, plus the default values.yaml file.
|
28
|
-
# This includes values from files, inline expressions, and the
|
29
|
-
# state ConfigMap.
|
30
|
-
# @return [Hash] symbol-keyed dict of all loaded values
|
31
|
-
def compile_values
|
32
|
-
utils = Kerbi::Utils::Values
|
33
|
-
file_values = utils.from_files(cli_opts.fname_exprs)
|
34
|
-
inline_values = utils.from_inlines(cli_opts.inline_val_exprs)
|
35
|
-
file_values.deep_merge(inline_values)
|
36
|
-
end
|
37
|
-
|
38
|
-
##
|
39
|
-
# Returns a re-usable instance of the CLI-args
|
40
|
-
# wrapper Kerbi::CliOpts
|
41
|
-
# @return [Kerbi::CliOpts] re-usable instance
|
42
|
-
def cli_opts
|
43
|
-
@_options_obj ||= Kerbi::CliOpts.new(self.options)
|
44
|
-
end
|
45
|
-
|
46
|
-
##
|
47
|
-
# Convenience class method for declaring a Thor subcommand
|
48
|
-
# metadata bundle, in accordance with the schema in
|
49
|
-
# Kerbi::Consts::OptionSchemas.
|
50
|
-
# @param [Hash] _schema a dict from Kerbi::Consts::OptionSchemas
|
51
|
-
# @param [Class<Thor>] handler_cls the handler
|
52
|
-
def self.thor_sub_meta(_schema, handler_cls)
|
53
|
-
schema = _schema.deep_dup
|
54
|
-
desc(schema[:name], schema[:desc])
|
55
|
-
subcommand schema[:name], handler_cls
|
56
|
-
end
|
57
|
-
|
58
|
-
##
|
59
|
-
# Convenience class method for declaring a Thor command
|
60
|
-
# metadata bundle, in accordance with the schema in
|
61
|
-
# Kerbi::Consts::OptionSchemas.
|
62
|
-
# @param [Hash] _schema a dict from Kerbi::Consts::OptionSchemas
|
63
|
-
def self.thor_meta(_schema)
|
64
|
-
schema = _schema.deep_dup
|
65
|
-
desc(schema[:name], schema[:desc])
|
66
|
-
(schema[:options] || []).each do |opt_schema|
|
67
|
-
opt_key = opt_schema.delete(:key).to_sym
|
68
|
-
self.option opt_key, opt_schema
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def self.exit_on_failure?
|
73
|
-
true
|
74
|
-
end
|
75
|
-
|
76
|
-
private
|
77
|
-
|
78
|
-
def utils
|
79
|
-
Kerbi::Utils
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|