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.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cli/base_handler.rb +194 -0
  3. data/lib/cli/base_serializer.rb +120 -0
  4. data/lib/cli/config_handler.rb +51 -0
  5. data/lib/cli/entry_serializers.rb +99 -0
  6. data/lib/cli/project_handler.rb +2 -2
  7. data/lib/cli/release_handler.rb +41 -0
  8. data/lib/cli/release_serializer.rb +46 -0
  9. data/lib/cli/root_handler.rb +34 -13
  10. data/lib/cli/state_handler.rb +88 -0
  11. data/lib/cli/values_handler.rb +4 -3
  12. data/{boilerplate → lib/code-gen/new-project}/Gemfile.erb +0 -0
  13. data/lib/code-gen/new-project/kerbifile.rb.erb +9 -0
  14. data/lib/code-gen/new-project/values.yaml.erb +1 -0
  15. data/lib/config/cli_schema.rb +343 -28
  16. data/lib/config/config_file.rb +60 -0
  17. data/lib/config/globals.rb +4 -0
  18. data/lib/config/run_opts.rb +162 -0
  19. data/lib/config/state_consts.rb +11 -0
  20. data/lib/kerbi.rb +35 -10
  21. data/lib/main/code_gen.rb +1 -1
  22. data/lib/main/errors.rb +115 -0
  23. data/lib/main/mixer.rb +20 -10
  24. data/lib/mixins/cli_state_helpers.rb +108 -0
  25. data/lib/mixins/cm_backend_testing.rb +109 -0
  26. data/lib/mixins/entry_tag_logic.rb +183 -0
  27. data/lib/state/base_backend.rb +93 -0
  28. data/lib/state/config_map_backend.rb +173 -0
  29. data/lib/state/entry.rb +173 -0
  30. data/lib/state/entry_set.rb +137 -0
  31. data/lib/state/metadata.yaml.erb +11 -0
  32. data/lib/state/mixers.rb +23 -0
  33. data/lib/state/resources.yaml.erb +17 -0
  34. data/lib/utils/cli.rb +108 -9
  35. data/lib/utils/helm.rb +10 -12
  36. data/lib/utils/k8s_auth.rb +87 -0
  37. data/lib/utils/misc.rb +36 -1
  38. data/lib/utils/mixing.rb +1 -1
  39. data/lib/utils/values.rb +13 -22
  40. data/spec/cli/config_handler_spec.rb +38 -0
  41. data/spec/cli/release_handler_spec.rb +127 -0
  42. data/spec/cli/root_handler_spec.rb +100 -0
  43. data/spec/cli/state_handler_spec.rb +108 -0
  44. data/spec/cli/values_handler_spec.rb +17 -0
  45. data/spec/fixtures/expectations/common/bad-tag.txt +1 -0
  46. data/spec/fixtures/expectations/config/bad-set.txt +1 -0
  47. data/spec/fixtures/expectations/config/set.txt +1 -0
  48. data/spec/fixtures/expectations/config/show-default.yaml +6 -0
  49. data/spec/fixtures/expectations/release/delete.txt +1 -0
  50. data/spec/fixtures/expectations/release/init-already-existed.txt +2 -0
  51. data/spec/fixtures/expectations/release/init-both-created.txt +2 -0
  52. data/spec/fixtures/expectations/release/list.txt +5 -0
  53. data/spec/fixtures/expectations/release/status-all-working.txt +5 -0
  54. data/spec/fixtures/expectations/release/status-data-unreadable.txt +5 -0
  55. data/spec/fixtures/expectations/release/status-not-provisioned.txt +5 -0
  56. data/spec/fixtures/expectations/root/template-inlines.yaml +31 -0
  57. data/spec/fixtures/expectations/root/template-production.yaml +31 -0
  58. data/spec/fixtures/expectations/root/template-read-inlines.yaml +31 -0
  59. data/spec/fixtures/expectations/root/template-read.yaml +31 -0
  60. data/spec/fixtures/expectations/root/template-write.yaml +31 -0
  61. data/spec/fixtures/expectations/root/template.yaml +31 -0
  62. data/spec/fixtures/expectations/root/values.json +28 -0
  63. data/spec/fixtures/expectations/state/delete.txt +1 -0
  64. data/spec/fixtures/expectations/state/demote.txt +1 -0
  65. data/spec/fixtures/expectations/state/list.json +51 -0
  66. data/spec/fixtures/expectations/state/list.txt +6 -0
  67. data/spec/fixtures/expectations/state/list.yaml +35 -0
  68. data/spec/fixtures/expectations/state/promote.txt +1 -0
  69. data/spec/fixtures/expectations/state/prune-candidates.txt +1 -0
  70. data/spec/fixtures/expectations/state/retag.txt +1 -0
  71. data/spec/fixtures/expectations/state/set.txt +1 -0
  72. data/spec/fixtures/expectations/state/show.json +13 -0
  73. data/spec/fixtures/expectations/state/show.txt +13 -0
  74. data/spec/fixtures/expectations/state/show.yaml +8 -0
  75. data/spec/fixtures/expectations/values/order-of-precedence.yaml +4 -0
  76. data/spec/main/configmap_backend_spec.rb +110 -0
  77. data/spec/main/project_code_gen_spec.rb +8 -2
  78. data/spec/main/state_entry_set_spec.rb +112 -0
  79. data/spec/main/state_entry_spec.rb +109 -0
  80. data/spec/mini-projects/hello-kerbi/common/metadata.yaml.erb +5 -0
  81. data/spec/mini-projects/hello-kerbi/consts.rb +5 -0
  82. data/spec/mini-projects/hello-kerbi/helpers.rb +8 -0
  83. data/spec/mini-projects/hello-kerbi/kerbifile.rb +18 -0
  84. data/spec/mini-projects/hello-kerbi/pod-and-service.yaml.erb +23 -0
  85. data/spec/mini-projects/hello-kerbi/values/production.yaml +2 -0
  86. data/spec/mini-projects/hello-kerbi/values/v2.yaml +2 -0
  87. data/spec/mini-projects/hello-kerbi/values/values.yaml +4 -0
  88. data/spec/spec_helper.rb +143 -1
  89. data/spec/utils/helm_spec.rb +89 -109
  90. data/spec/utils/k8s_auth_spec.rb +32 -0
  91. data/spec/utils/misc_utils_spec.rb +9 -0
  92. data/spec/utils/values_utils_spec.rb +12 -19
  93. metadata +143 -16
  94. data/boilerplate/kerbifile.rb.erb +0 -9
  95. data/boilerplate/values.yaml.erb +0 -1
  96. data/lib/cli/base.rb +0 -83
  97. data/lib/config/cli_opts.rb +0 -50
  98. data/lib/config/manager.rb +0 -36
  99. data/lib/main/state_manager.rb +0 -47
  100. data/lib/utils/kubectl.rb +0 -58
  101. data/spec/main/examples_spec.rb +0 -12
  102. data/spec/main/state_manager_spec.rb +0 -84
  103. data/spec/utils/state_utils.rb +0 -15
@@ -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
- 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
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
@@ -19,4 +19,13 @@ RSpec.describe Kerbi::Utils::Misc do
19
19
  end
20
20
  end
21
21
  end
22
+
23
+ describe ".deep_hash_diff" do
24
+ it "works" do
25
+ result = subject.deep_hash_diff(
26
+ {a: "a"},
27
+ {a: "b"}
28
+ )
29
+ end
30
+ end
22
31
  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(*args, **kwargs)
11
- subject.resolve_fname_expr(*args, **kwargs, root: root)
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 "returns nil" do
44
- expect(func("dne")).to be_nil
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.1
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-03-29 00:00:00.000000000 Z
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
- - boilerplate/Gemfile.erb
102
- - boilerplate/kerbifile.rb.erb
103
- - boilerplate/values.yaml.erb
104
- - lib/cli/base.rb
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/config/cli_opts.rb
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/manager.rb
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/main/state_manager.rb
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/kubectl.rb
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/main/examples_spec.rb
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/state_manager_spec.rb
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/state_manager_spec.rb
164
- - spec/main/examples_spec.rb
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
@@ -1,9 +0,0 @@
1
- module <%= (module_name = data[:user_module_name]) %>
2
- class RootMixer < Kerbi::Mixer
3
- def mix
4
- push dict(hello: values[:message])
5
- end
6
- end
7
- end
8
-
9
- Kerbi::Globals.mixers << <%= module_name %>::RootMixer
@@ -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