kerbi 0.0.1
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 +7 -0
- data/bin/kerbi +3 -0
- data/boilerplate/Gemfile.erb +6 -0
- data/boilerplate/kerbifile.rb.erb +9 -0
- data/boilerplate/values.yaml.erb +1 -0
- data/lib/cli/base.rb +83 -0
- data/lib/cli/project_handler.rb +17 -0
- data/lib/cli/root_handler.rb +47 -0
- data/lib/cli/values_handler.rb +11 -0
- data/lib/config/cli_opts.rb +50 -0
- data/lib/config/cli_schema.rb +104 -0
- data/lib/config/globals.rb +7 -0
- data/lib/config/manager.rb +36 -0
- data/lib/kerbi.rb +43 -0
- data/lib/main/code_gen.rb +131 -0
- data/lib/main/mixer.rb +235 -0
- data/lib/main/state_manager.rb +47 -0
- data/lib/mixins/mixer.rb +79 -0
- data/lib/utils/cli.rb +59 -0
- data/lib/utils/helm.rb +64 -0
- data/lib/utils/kubectl.rb +58 -0
- data/lib/utils/misc.rb +41 -0
- data/lib/utils/mixing.rb +181 -0
- data/lib/utils/values.rb +133 -0
- data/spec/fixtures/embedding.yaml.erb +3 -0
- data/spec/main/examples_spec.rb +12 -0
- data/spec/main/mixer_spec.rb +126 -0
- data/spec/main/project_code_gen_spec.rb +25 -0
- data/spec/main/state_manager_spec.rb +84 -0
- data/spec/mixins/mixer_mixin_spec.rb +55 -0
- data/spec/spec_helper.rb +39 -0
- data/spec/utils/helm_spec.rb +114 -0
- data/spec/utils/misc_utils_spec.rb +22 -0
- data/spec/utils/mixing_utils_spec.rb +209 -0
- data/spec/utils/state_utils.rb +15 -0
- data/spec/utils/values_utils_spec.rb +146 -0
- metadata +170 -0
@@ -0,0 +1,114 @@
|
|
1
|
+
require_relative './../spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Kerbi::Utils::Helm do
|
4
|
+
|
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
|
+
let :config do
|
14
|
+
Kerbi::Config::Manager
|
15
|
+
end
|
16
|
+
|
17
|
+
before(:each) do
|
18
|
+
# config.helm_exec = 'helm'
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '.template' do
|
22
|
+
let(:repo_org) { "jetstack" }
|
23
|
+
let(:repo_url) { "https://charts.jetstack.io" }
|
24
|
+
let(:chart) { "#{repo_org}/cert-manager" }
|
25
|
+
let :values do
|
26
|
+
{
|
27
|
+
cainjector: {
|
28
|
+
serviceAccount: {
|
29
|
+
automountServiceAccountToken: "foo"
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
before :each do
|
36
|
+
system("helm repo add #{repo_org} #{repo_url}")
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'with existing chart' do
|
40
|
+
it 'returns the templated yaml string' do
|
41
|
+
res_dicts = subject.template('kerbi', chart, values: values)
|
42
|
+
expect(res_dicts.class).to eq(Array)
|
43
|
+
expect(res_dicts.count).to be_within(40).of(40)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'cleans up' do
|
48
|
+
subject.template('kerbi', chart)
|
49
|
+
expect(File.exists?(config.tmp_helm_values_path)).to be_falsey
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '.encode_inline_assigns' do
|
54
|
+
context 'when assignments are flat' do
|
55
|
+
it 'returns the right string' do
|
56
|
+
#noinspection SpellCheckingInspection
|
57
|
+
actual = subject.encode_inline_assigns(
|
58
|
+
'bar': 'bar',
|
59
|
+
'foo.bar': 'foo.bar'
|
60
|
+
)
|
61
|
+
expected = "--set bar=bar --set foo.bar=foo.bar"
|
62
|
+
expect(actual).to eq(expected)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'when values are nested' do
|
67
|
+
it 'raises an runtime error' do
|
68
|
+
expect do
|
69
|
+
subject.encode_inline_assigns('bar': { foo: 'bar'})
|
70
|
+
end.to raise_error("Assignments must be flat")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe ".make_tmp_values_file" do
|
76
|
+
it 'creates the tmp file with yaml and returns the path' do
|
77
|
+
path = subject.make_tmp_values_file(foo: 'bar')
|
78
|
+
expect(YAML.load_file(path)).to eq('foo' => 'bar')
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe '.del_tmp_values_file' do
|
83
|
+
context 'when the file exists' do
|
84
|
+
it 'delete the file' do
|
85
|
+
path = subject.make_tmp_values_file(foo: 'bar')
|
86
|
+
expect(File.exists?(path)).to be_truthy
|
87
|
+
subject.del_tmp_values_file
|
88
|
+
expect(File.exists?(path)).to be_falsey
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context 'when the file does not exist' do
|
93
|
+
it 'does not raise an error' do
|
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
|
114
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative './../spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Kerbi::Utils::Misc do
|
4
|
+
|
5
|
+
subject { Kerbi::Utils::Misc }
|
6
|
+
|
7
|
+
describe ".flatten_hash" do
|
8
|
+
context 'with an already flat hash' do
|
9
|
+
it 'returns the same hash' do
|
10
|
+
actual = subject.flatten_hash({foo: 'bar'})
|
11
|
+
expect(actual).to eq({foo: 'bar'})
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'with a deep hash' do
|
16
|
+
it 'returns a flat hash with deep keys' do
|
17
|
+
actual = subject.flatten_hash({foo: { bar: 'baz' }})
|
18
|
+
expect(actual).to eq({'foo.bar': 'baz'})
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,209 @@
|
|
1
|
+
require_relative './../spec_helper'
|
2
|
+
|
3
|
+
class TestObj
|
4
|
+
def get_binding
|
5
|
+
binding
|
6
|
+
end
|
7
|
+
|
8
|
+
def values
|
9
|
+
{k1: "baz"}
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
RSpec.describe Kerbi::Utils::Mixing do
|
14
|
+
|
15
|
+
subject { Kerbi::Utils::Mixing }
|
16
|
+
|
17
|
+
describe ".erb_str_to_dicts" do
|
18
|
+
describe 'logic unrelated to filtering' do
|
19
|
+
let(:yaml_str) { "k1: <%=extras[:k1]%>\n---\nk1: bar" }
|
20
|
+
it 'returns the correct list of hashes' do
|
21
|
+
actual = subject.yaml_str_to_dicts(
|
22
|
+
yaml_str,
|
23
|
+
extras: {k1: "foo"}
|
24
|
+
)
|
25
|
+
expect(actual).to match_array([{k1: 'foo'}, {k1: 'bar'}])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '.erb_file_to_dicts' do
|
31
|
+
context "with well formatted files" do
|
32
|
+
let(:fname) { "foo.yaml.erb" }
|
33
|
+
|
34
|
+
before(:each) do
|
35
|
+
Kerbi::Testing.reset_test_yamls_dir
|
36
|
+
Kerbi::Testing.make_yaml(fname, "k: <%= extras[:foo] %>")
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'outputs the correct list of hashes' do
|
40
|
+
result = subject.yaml_file_to_dicts(
|
41
|
+
Kerbi::Testing.f_fname(fname),
|
42
|
+
extras: { foo: "bar" }
|
43
|
+
)
|
44
|
+
expect(result).to eq([{k: 'bar'}])
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe ".yamls_in_dir_to_dicts" do
|
50
|
+
let(:fname1) { "a.yaml.erb" }
|
51
|
+
let(:fname2) { "b.yaml" }
|
52
|
+
let(:pwd) { Kerbi::Testing::TEST_YAMLS_DIR }
|
53
|
+
let(:expected) { [{bar: "car"}, {foo: "bar"}, {bar: "baz"}] }
|
54
|
+
|
55
|
+
before :each do
|
56
|
+
Kerbi::Testing::reset_test_yamls_dir
|
57
|
+
Kerbi::Testing.make_yaml(fname1, "foo: bar\n---\nbar: <%= extras[:a] %>")
|
58
|
+
Kerbi::Testing.make_yaml(fname2, "bar: car")
|
59
|
+
end
|
60
|
+
|
61
|
+
context "without a subdirectory" do
|
62
|
+
it "works" do
|
63
|
+
result = subject.yamls_in_dir_to_dicts(
|
64
|
+
pwd,
|
65
|
+
nil,
|
66
|
+
extras: { a: "baz" }
|
67
|
+
)
|
68
|
+
expect(result).to match_array(expected)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe ".interpolate_erb_string" do
|
74
|
+
context "passing a nil source binding" do
|
75
|
+
|
76
|
+
let(:yaml_str) { "\nfoo: \"<%=extras[:k1]%>\"\n---\nbar: \"bar\"\n" }
|
77
|
+
let(:exp_yaml_str) { "\nfoo: \"foo\"\n---\nbar: \"bar\"\n" }
|
78
|
+
|
79
|
+
context "correctly referencing variables" do
|
80
|
+
it "works normally" do
|
81
|
+
result = subject.interpolate_erb_string(
|
82
|
+
yaml_str,
|
83
|
+
extras: {k1: "foo"}
|
84
|
+
)
|
85
|
+
expect(result).to eq(exp_yaml_str)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context "mistakenly referencing unavailable variables" do
|
90
|
+
let(:yaml_str) { "k1: <%=dne%>\n---\nk1: bar" }
|
91
|
+
it "raises a normal NameError" do
|
92
|
+
expect do
|
93
|
+
subject.interpolate_erb_string(yaml_str)
|
94
|
+
end.to raise_error(NameError)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
context "passing a non-nil source binding" do
|
100
|
+
let(:yaml_str) { "k1: \"<%=values[:k1]%>\"\n---\nk1: bar" }
|
101
|
+
let(:exp_result) { "k1: \"baz\"\n---\nk1: bar" }
|
102
|
+
it "uses the binding correctly" do
|
103
|
+
result = subject.interpolate_erb_string(
|
104
|
+
yaml_str,
|
105
|
+
src_binding: TestObj.new.get_binding,
|
106
|
+
)
|
107
|
+
expect(result).to eq(exp_result)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe ".yamls_in_dir_to_dicts" do
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
describe ".str_cmp" do
|
117
|
+
context "when it should be true" do
|
118
|
+
it "returns true" do
|
119
|
+
expect(subject.str_cmp("Pod", "Pod")).to eq(true)
|
120
|
+
expect(subject.str_cmp("Po.*", "Pod")).to eq(true)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
context "when it should be false" do
|
124
|
+
it "returns false" do
|
125
|
+
expect(subject.str_cmp("Pods", "Pod")).to eq(false)
|
126
|
+
expect(subject.str_cmp("Po", "Pod")).to eq(false)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
describe ".res_dict_matches_rule?" do
|
133
|
+
let :res_dict do
|
134
|
+
{kind: "Pod", metadata: {name: "foo"}}
|
135
|
+
end
|
136
|
+
|
137
|
+
context "when it should be true" do
|
138
|
+
it "returns true" do
|
139
|
+
func = -> (*args) { subject.res_dict_matches_rule?(*args) }
|
140
|
+
expect(func[res_dict, {kind: "Pod"}]).to be_truthy
|
141
|
+
expect(func[res_dict, {kind: "Po.*"}]).to be_truthy
|
142
|
+
expect(func[res_dict, {kind: ".*"}]).to be_truthy
|
143
|
+
|
144
|
+
expect(func[res_dict, {name: "foo"}]).to be_truthy
|
145
|
+
expect(func[res_dict, {name: "fo[o|a]"}]).to be_truthy
|
146
|
+
|
147
|
+
expect(func[res_dict, {kind: "Pod", name: ""}]).to be_truthy
|
148
|
+
expect(func[res_dict, {kind: ".*", name: "foo"}]).to be_truthy
|
149
|
+
expect(func[res_dict, {kind: "P.*", name: "fo[o|a]"}]).to be_truthy
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
context "when it should be false" do
|
154
|
+
it "returns false" do
|
155
|
+
func = -> (*args) { subject.res_dict_matches_rule?(*args) }
|
156
|
+
expect(func[res_dict, {kind: "Pods"}]).to be_falsey
|
157
|
+
expect(func[res_dict, {kind: "Po"}]).to be_falsey
|
158
|
+
expect(func[res_dict, {kind: "Pod", name: "bar"}]).to be_falsey
|
159
|
+
expect(func[res_dict, {kind: ".*", name: "fo[b|a]"}]).to be_falsey
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
let :dirty_res_dicts do
|
165
|
+
[
|
166
|
+
{kind: "PersistentVolume", metadata: { name: "pv" }},
|
167
|
+
{kind: "PersistentVolumeClaim", metadata: { name: "pvc" }},
|
168
|
+
{kind: "Pod", metadata: { name: "pod" }}
|
169
|
+
].map(&:stringify_keys)
|
170
|
+
end
|
171
|
+
|
172
|
+
let(:clean_res_dicts) { dirty_res_dicts.map(&:deep_symbolize_keys) }
|
173
|
+
let(:white_rules) { [{kind: "PersistentVolume.*"}] }
|
174
|
+
let(:black_rules) { [{name: "pvc"}] }
|
175
|
+
|
176
|
+
describe ".select_res_dicts_blacklist" do
|
177
|
+
it "excludes the res dicts that match the rule" do
|
178
|
+
result = subject.select_res_dicts_blacklist(dirty_res_dicts, black_rules)
|
179
|
+
expect(result).to match_array([clean_res_dicts[0], clean_res_dicts[2]])
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
describe ".select_res_dicts_blacklist" do
|
184
|
+
it "excludes the res dicts that do not match the rule" do
|
185
|
+
result = subject.select_res_dicts_whitelist(dirty_res_dicts, white_rules)
|
186
|
+
expect(result).to eq(clean_res_dicts[0..1])
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
describe ".clean_and_filter_hashes" do
|
191
|
+
context "without any filtering" do
|
192
|
+
it "returns the res_dicts unchanged and symbolized" do
|
193
|
+
result = subject.clean_and_filter_dicts(dirty_res_dicts)
|
194
|
+
expect(result).to eq(clean_res_dicts)
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
context "with white and black rules" do
|
199
|
+
it "returns the res_dicts filtered and symbolized" do
|
200
|
+
result = subject.clean_and_filter_dicts(
|
201
|
+
dirty_res_dicts,
|
202
|
+
white_rules: white_rules,
|
203
|
+
black_rules: black_rules
|
204
|
+
)
|
205
|
+
expect(result).to eq(clean_res_dicts[0..0])
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Kerbi
|
2
|
+
module Utils
|
3
|
+
module State
|
4
|
+
def self.kubectl_get_cm(res_name, opts={})
|
5
|
+
kmd = "get configmap #{res_name} #{opts[:kubectl_args]}"
|
6
|
+
Utils::Kubectl.jkmd(kmd, **opts)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.read_cm_data(configmap)
|
10
|
+
json_enc_vars = configmap.dig(:data, :variables) || '{}'
|
11
|
+
JSON.parse(json_enc_vars).deep_symbolize_keys
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
require_relative './../spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe Kerbi::Utils::Values do
|
4
|
+
|
5
|
+
subject { Kerbi::Utils::Values }
|
6
|
+
let(:root) { Kerbi::Testing::TEST_YAMLS_DIR }
|
7
|
+
before(:each) { Kerbi::Testing.reset_test_yamls_dir }
|
8
|
+
|
9
|
+
describe ".resolve_fname_expr" do
|
10
|
+
def func(*args, **kwargs)
|
11
|
+
subject.resolve_fname_expr(*args, **kwargs, root: root)
|
12
|
+
end
|
13
|
+
|
14
|
+
context "when the expression can be resolved" do
|
15
|
+
context "when the filename is an exact match" do
|
16
|
+
before :each do
|
17
|
+
Kerbi::Testing.make_yaml("x", "n/a")
|
18
|
+
Kerbi::Testing.make_yaml("x.yaml", "n/a")
|
19
|
+
Kerbi::Testing.make_yaml("x.yaml.erb", "n/a")
|
20
|
+
end
|
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")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "when the filename is not an exact match" do
|
29
|
+
before :each do
|
30
|
+
Kerbi::Testing.make_yaml("y.yaml", "n/a")
|
31
|
+
Kerbi::Testing.make_yaml("y.yaml.erb", "n/a")
|
32
|
+
end
|
33
|
+
|
34
|
+
it "returns the closes match" do
|
35
|
+
expect(func("y")).to eq("#{root}/y.yaml")
|
36
|
+
Kerbi::Testing.del_testfile("y.yaml")
|
37
|
+
expect(func("y")).to eq("#{root}/y.yaml.erb")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context "when the expression cannot be resolved" do
|
43
|
+
it "returns nil" do
|
44
|
+
expect(func("dne")).to be_nil
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe ".resolve_fname_exprs" do
|
50
|
+
|
51
|
+
def func(*args, **kwargs)
|
52
|
+
subject.resolve_fname_exprs(*args, **kwargs, root: root)
|
53
|
+
end
|
54
|
+
|
55
|
+
before :each do
|
56
|
+
Kerbi::Testing.make_yaml("x.yaml", "n/a")
|
57
|
+
Kerbi::Testing.make_yaml("y.yaml", "n/a")
|
58
|
+
end
|
59
|
+
|
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
|
+
context "with no missing file other than 'values'" do
|
70
|
+
it "returns the expect list of final paths" do
|
71
|
+
expect(func(["x.yaml"])).to eq(["#{root}/x.yaml"])
|
72
|
+
expect(func(%w[x.yaml x])).to eq(["#{root}/x.yaml"])
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context "with a missing file other than 'values'" do
|
77
|
+
it "raises an exception" do
|
78
|
+
expect{ func(["dne"]) }.to raise_exception(Exception)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe ".parse_inline_assignment" do
|
84
|
+
def func(expr)
|
85
|
+
subject.parse_inline_assignment(expr)
|
86
|
+
end
|
87
|
+
|
88
|
+
context "a malformed expression" do
|
89
|
+
it "raises an exception" do
|
90
|
+
expect { func("foo=") }.to raise_error(Exception)
|
91
|
+
expect { func("foo:bar") }.to raise_error(Exception)
|
92
|
+
expect { func("=bar") }.to raise_error(Exception)
|
93
|
+
expect { func("=") }.to raise_error(Exception)
|
94
|
+
expect { func("none") }.to raise_error(Exception)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
context "a well formed expression" do
|
99
|
+
it "outputs a symbol-keyed dict" do
|
100
|
+
expect(func("foo=bar")).to eq({foo: "bar"})
|
101
|
+
expect(func("foo.bar=baz")).to eq({foo: { bar: "baz" }})
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe ".from_inlines" do
|
107
|
+
def func(*args, **kwargs)
|
108
|
+
subject.from_inlines(*args, **kwargs)
|
109
|
+
end
|
110
|
+
|
111
|
+
it "parses and deep merges the expressions" do
|
112
|
+
result = func(%w[foo=bar foo.bar=baz bar=foo])
|
113
|
+
expect(result).to eq({foo: {bar: "baz"}, bar: "foo"})
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe ".load_yaml_files" do
|
118
|
+
|
119
|
+
def func(*args, **kwargs)
|
120
|
+
subject.load_yaml_files(*args, **kwargs)
|
121
|
+
end
|
122
|
+
|
123
|
+
before :each do
|
124
|
+
Kerbi::Testing.make_yaml("x.yaml", "x: y")
|
125
|
+
Kerbi::Testing.make_yaml("y.yaml", "y: z")
|
126
|
+
end
|
127
|
+
|
128
|
+
it "loads and merges the values from the given files" do
|
129
|
+
result = func(%W[#{root}/x.yaml #{root}/y.yaml])
|
130
|
+
expect(result).to eq(x: 'y', y: 'z')
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe ".load_yaml_file" do
|
135
|
+
context "with a valid yaml ERB file" do
|
136
|
+
let(:yaml_content) { "foo: <%=b64enc('foo') %>" }
|
137
|
+
it "loads, interpolates, and outputs an array of dicts" do
|
138
|
+
fname = Kerbi::Testing.make_yaml("x.yaml", yaml_content)
|
139
|
+
expect(subject.load_yaml_file(fname)).to eq(foo: "Zm9v")
|
140
|
+
end
|
141
|
+
end
|
142
|
+
context "with an invalid yaml ERB file" do
|
143
|
+
let(:yaml_content) { "foo: <%=b64enc('foo') %>\n---\nfoo: bar" }
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
metadata
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kerbi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Xavier Millot
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-03-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: http
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.4'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 4.4.1
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '4.4'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 4.4.1
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: activesupport
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '6.0'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 6.0.3.2
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '6.0'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 6.0.3.2
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: thor
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 1.1.0
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '1.1'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.1.0
|
70
|
+
- - "~>"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '1.1'
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: colorize
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - "~>"
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0.8'
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.8.1
|
83
|
+
type: :runtime
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.8'
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 0.8.1
|
93
|
+
description: Kerbi is a multi-strategy Kubernetes manifest templating engine.
|
94
|
+
email: xavier@nmachine.io
|
95
|
+
executables:
|
96
|
+
- kerbi
|
97
|
+
extensions: []
|
98
|
+
extra_rdoc_files: []
|
99
|
+
files:
|
100
|
+
- bin/kerbi
|
101
|
+
- boilerplate/Gemfile.erb
|
102
|
+
- boilerplate/kerbifile.rb.erb
|
103
|
+
- boilerplate/values.yaml.erb
|
104
|
+
- lib/cli/base.rb
|
105
|
+
- lib/cli/project_handler.rb
|
106
|
+
- lib/cli/root_handler.rb
|
107
|
+
- lib/cli/values_handler.rb
|
108
|
+
- lib/config/cli_opts.rb
|
109
|
+
- lib/config/cli_schema.rb
|
110
|
+
- lib/config/globals.rb
|
111
|
+
- lib/config/manager.rb
|
112
|
+
- lib/kerbi.rb
|
113
|
+
- lib/main/code_gen.rb
|
114
|
+
- lib/main/mixer.rb
|
115
|
+
- lib/main/state_manager.rb
|
116
|
+
- lib/mixins/mixer.rb
|
117
|
+
- lib/utils/cli.rb
|
118
|
+
- lib/utils/helm.rb
|
119
|
+
- lib/utils/kubectl.rb
|
120
|
+
- lib/utils/misc.rb
|
121
|
+
- lib/utils/mixing.rb
|
122
|
+
- lib/utils/values.rb
|
123
|
+
- spec/fixtures/embedding.yaml.erb
|
124
|
+
- spec/main/examples_spec.rb
|
125
|
+
- spec/main/mixer_spec.rb
|
126
|
+
- spec/main/project_code_gen_spec.rb
|
127
|
+
- spec/main/state_manager_spec.rb
|
128
|
+
- spec/mixins/mixer_mixin_spec.rb
|
129
|
+
- spec/spec_helper.rb
|
130
|
+
- spec/utils/helm_spec.rb
|
131
|
+
- spec/utils/misc_utils_spec.rb
|
132
|
+
- spec/utils/mixing_utils_spec.rb
|
133
|
+
- spec/utils/state_utils.rb
|
134
|
+
- spec/utils/values_utils_spec.rb
|
135
|
+
homepage: https://nmachine-io.github.io/kerbi
|
136
|
+
licenses:
|
137
|
+
- MIT
|
138
|
+
metadata: {}
|
139
|
+
post_install_message:
|
140
|
+
rdoc_options: []
|
141
|
+
require_paths:
|
142
|
+
- lib
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: 2.6.3
|
148
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
requirements: []
|
154
|
+
rubygems_version: 3.0.3
|
155
|
+
signing_key:
|
156
|
+
specification_version: 4
|
157
|
+
summary: Multi-strategy Kubernetes manifest templating engine.
|
158
|
+
test_files:
|
159
|
+
- spec/spec_helper.rb
|
160
|
+
- spec/mixins/mixer_mixin_spec.rb
|
161
|
+
- spec/main/mixer_spec.rb
|
162
|
+
- spec/main/project_code_gen_spec.rb
|
163
|
+
- spec/main/state_manager_spec.rb
|
164
|
+
- spec/main/examples_spec.rb
|
165
|
+
- spec/fixtures/embedding.yaml.erb
|
166
|
+
- spec/utils/helm_spec.rb
|
167
|
+
- spec/utils/state_utils.rb
|
168
|
+
- spec/utils/values_utils_spec.rb
|
169
|
+
- spec/utils/mixing_utils_spec.rb
|
170
|
+
- spec/utils/misc_utils_spec.rb
|