kubes 0.3.5 → 0.4.0
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/CHANGELOG.md +14 -0
- data/README.md +6 -5
- data/docs/_docs/config/args.md +10 -0
- data/docs/_docs/config/args/docker.md +19 -0
- data/docs/_docs/config/{kubectl/args.md → args/kubectl.md} +2 -0
- data/docs/_docs/config/docker.md +4 -40
- data/docs/_docs/config/hooks.md +10 -0
- data/docs/_docs/config/hooks/docker.md +70 -0
- data/docs/_docs/config/hooks/kubectl.md +83 -0
- data/docs/_docs/config/hooks/kubes.md +67 -0
- data/docs/_docs/config/hooks/ruby.md +74 -0
- data/docs/_docs/config/kubectl.md +2 -2
- data/docs/_docs/config/reference.md +20 -0
- data/docs/_docs/config/skip.md +58 -0
- data/docs/_docs/dsl/resources.md +1 -1
- data/docs/_docs/intro.md +3 -1
- data/docs/_docs/patterns/migrations.md +121 -0
- data/docs/_includes/config/hooks/options.md +20 -0
- data/docs/_includes/sidebar.html +25 -12
- data/docs/_sass/theme.scss +25 -1
- data/lib/kubes/cli.rb +20 -5
- data/lib/kubes/cli/apply.rb +2 -1
- data/lib/kubes/cli/base.rb +11 -0
- data/lib/kubes/cli/delete.rb +1 -1
- data/lib/kubes/cli/exec.rb +37 -6
- data/lib/kubes/cli/get.rb +1 -1
- data/lib/kubes/cli/logs.rb +27 -3
- data/lib/kubes/cli/prune.rb +95 -0
- data/lib/kubes/compiler.rb +18 -7
- data/lib/kubes/compiler/decorator/base.rb +7 -1
- data/lib/kubes/compiler/decorator/{resources/secret.rb → hashable.rb} +5 -4
- data/lib/kubes/compiler/decorator/hashable/field.rb +53 -0
- data/lib/kubes/compiler/decorator/hashable/storage.rb +19 -0
- data/lib/kubes/compiler/decorator/post.rb +77 -0
- data/lib/kubes/compiler/decorator/pre.rb +12 -0
- data/lib/kubes/compiler/strategy.rb +2 -2
- data/lib/kubes/compiler/strategy/base.rb +1 -1
- data/lib/kubes/compiler/strategy/result.rb +4 -6
- data/lib/kubes/config.rb +16 -11
- data/lib/kubes/docker/strategy/build/docker.rb +1 -1
- data/lib/kubes/docker/strategy/build/gcloud.rb +1 -1
- data/lib/kubes/docker/strategy/image_name.rb +1 -1
- data/lib/kubes/docker/strategy/push/docker.rb +1 -1
- data/lib/kubes/docker/strategy/push/gcloud.rb +1 -1
- data/lib/kubes/docker/strategy/utils.rb +1 -1
- data/lib/kubes/hooks/builder.rb +29 -15
- data/lib/kubes/hooks/concern.rb +10 -0
- data/lib/kubes/hooks/dsl.rb +2 -1
- data/lib/kubes/hooks/runner.rb +22 -0
- data/lib/kubes/kubectl.rb +21 -18
- data/lib/kubes/kubectl/batch.rb +8 -5
- data/lib/kubes/kubectl/{decider.rb → dispatcher.rb} +1 -1
- data/lib/kubes/kubectl/fetch/base.rb +12 -9
- data/lib/kubes/kubectl/fetch/deployment.rb +12 -13
- data/lib/kubes/kubectl/fetch/pods.rb +4 -15
- data/lib/kubes/kubectl/kustomize.rb +1 -1
- data/lib/kubes/kubectl/ordering.rb +12 -0
- data/lib/kubes/util/consider.rb +2 -1
- data/lib/kubes/util/sh.rb +1 -1
- data/lib/kubes/version.rb +1 -1
- data/spec/fixtures/decorators/deployment/both/envFrom.yaml +31 -0
- data/spec/fixtures/prune/capture.yaml +57 -0
- data/spec/fixtures/prune/fetch_items.yaml +268 -0
- data/spec/kubes/cli/prune_spec.rb +38 -0
- data/spec/kubes/compiler/decorator/{resources → post}/deployment_spec.rb +25 -6
- data/spec/kubes/compiler/decorator/{resources → post}/pod_spec.rb +2 -11
- metadata +35 -19
- data/docs/_docs/config/kubectl/hooks.md +0 -39
- data/lib/kubes/compiler/decorator.rb +0 -17
- data/lib/kubes/compiler/decorator/compile.rb +0 -12
- data/lib/kubes/compiler/decorator/resources/base.rb +0 -13
- data/lib/kubes/compiler/decorator/resources/container.rb +0 -76
- data/lib/kubes/compiler/decorator/resources/container/mapping.rb +0 -28
- data/lib/kubes/compiler/decorator/resources/deployment.rb +0 -10
- data/lib/kubes/compiler/decorator/resources/pod.rb +0 -10
- data/lib/kubes/compiler/decorator/write.rb +0 -14
- data/lib/kubes/docker/strategy/hooks.rb +0 -9
@@ -1,11 +1,13 @@
|
|
1
|
-
describe Kubes::Compiler::Decorator::
|
1
|
+
describe Kubes::Compiler::Decorator::Post do
|
2
2
|
let(:decorator) { described_class.new(data) }
|
3
3
|
|
4
4
|
def fixture(name)
|
5
5
|
YAML.load_file("spec/fixtures/decorators/deployment/#{name}.yaml")
|
6
6
|
end
|
7
7
|
before(:each) do
|
8
|
-
allow(Kubes::Compiler::Decorator).to receive(:fetch).and_return("fakehash")
|
8
|
+
allow(Kubes::Compiler::Decorator::Hashable::Storage).to receive(:fetch).with("Secret", "demo-secret").and_return("fakehash")
|
9
|
+
allow(Kubes::Compiler::Decorator::Hashable::Storage).to receive(:fetch).with("ConfigMap", "demo-config-map").and_return("fakehash-config")
|
10
|
+
allow(Kubes::Compiler::Decorator::Hashable::Storage).to receive(:fetch).with("ConfigMap", "demo-config-map-2").and_return("fakehash-config2")
|
9
11
|
end
|
10
12
|
|
11
13
|
context "secret" do
|
@@ -56,7 +58,7 @@ describe Kubes::Compiler::Decorator::Resources::Deployment do
|
|
56
58
|
decorator.run
|
57
59
|
data = decorator.data
|
58
60
|
name = data['spec']['template']['spec']['containers'][0]['envFrom'][0]['configMapRef']['name']
|
59
|
-
expect(name).to eq("demo-config-map-fakehash")
|
61
|
+
expect(name).to eq("demo-config-map-fakehash-config")
|
60
62
|
end
|
61
63
|
end
|
62
64
|
|
@@ -66,7 +68,7 @@ describe Kubes::Compiler::Decorator::Resources::Deployment do
|
|
66
68
|
decorator.run
|
67
69
|
data = decorator.data
|
68
70
|
name = data['spec']['template']['spec']['containers'][0]['env'][0]['valueFrom']['configMapKeyRef']['name']
|
69
|
-
expect(name).to eq("demo-config-map-fakehash")
|
71
|
+
expect(name).to eq("demo-config-map-fakehash-config")
|
70
72
|
end
|
71
73
|
end
|
72
74
|
|
@@ -76,7 +78,7 @@ describe Kubes::Compiler::Decorator::Resources::Deployment do
|
|
76
78
|
decorator.run
|
77
79
|
data = decorator.data
|
78
80
|
name = data['spec']['template']['spec']['volumes'][0]['configMap']['name']
|
79
|
-
expect(name).to eq("demo-config-map-fakehash")
|
81
|
+
expect(name).to eq("demo-config-map-fakehash-config")
|
80
82
|
end
|
81
83
|
end
|
82
84
|
|
@@ -85,7 +87,24 @@ describe Kubes::Compiler::Decorator::Resources::Deployment do
|
|
85
87
|
it "data" do
|
86
88
|
decorator.run
|
87
89
|
name = data['spec']['template']['spec']['containers'][0]['envFrom'][0]['configMapRef']['name']
|
88
|
-
expect(name).to eq("demo-config-map-fakehash")
|
90
|
+
expect(name).to eq("demo-config-map-fakehash-config")
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context "both" do
|
96
|
+
describe "envFrom" do
|
97
|
+
let(:data) { fixture("both/envFrom") }
|
98
|
+
it "run" do
|
99
|
+
decorator.run
|
100
|
+
data = decorator.data
|
101
|
+
envFrom = data['spec']['template']['spec']['containers'][0]['envFrom']
|
102
|
+
name = envFrom[0]['secretRef']['name']
|
103
|
+
expect(name).to eq("demo-secret-fakehash")
|
104
|
+
name = envFrom[1]['configMapRef']['name']
|
105
|
+
expect(name).to eq("demo-config-map-fakehash-config")
|
106
|
+
name = envFrom[2]['configMapRef']['name']
|
107
|
+
expect(name).to eq("demo-config-map-2-fakehash-config2")
|
89
108
|
end
|
90
109
|
end
|
91
110
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
describe Kubes::Compiler::Decorator::
|
1
|
+
describe Kubes::Compiler::Decorator::Post do
|
2
2
|
let(:decorator) { described_class.new(data) }
|
3
3
|
|
4
4
|
def fixture(name)
|
5
5
|
YAML.load_file("spec/fixtures/decorators/pod/#{name}.yaml")
|
6
6
|
end
|
7
7
|
before(:each) do
|
8
|
-
allow(Kubes::Compiler::Decorator).to receive(:fetch).and_return("fakehash")
|
8
|
+
allow(Kubes::Compiler::Decorator::Hashable::Storage).to receive(:fetch).and_return("fakehash")
|
9
9
|
end
|
10
10
|
|
11
11
|
context("secret") do
|
@@ -38,15 +38,6 @@ describe Kubes::Compiler::Decorator::Resources::Pod do
|
|
38
38
|
expect(name).to eq("demo-secret-fakehash")
|
39
39
|
end
|
40
40
|
end
|
41
|
-
|
42
|
-
describe "run" do
|
43
|
-
let(:data) { fixture("secret/envFrom") }
|
44
|
-
it "data" do
|
45
|
-
decorator.run
|
46
|
-
name = data['spec']['containers'][0]['envFrom'][0]['secretRef']['name']
|
47
|
-
expect(name).to eq("demo-secret-fakehash")
|
48
|
-
end
|
49
|
-
end
|
50
41
|
end
|
51
42
|
|
52
43
|
context "configMap" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kubes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -234,12 +234,20 @@ files:
|
|
234
234
|
- docs/_config.yml
|
235
235
|
- docs/_docs/ci/cloudbuild.md
|
236
236
|
- docs/_docs/config.md
|
237
|
+
- docs/_docs/config/args.md
|
238
|
+
- docs/_docs/config/args/docker.md
|
239
|
+
- docs/_docs/config/args/kubectl.md
|
237
240
|
- docs/_docs/config/builder.md
|
238
241
|
- docs/_docs/config/docker.md
|
239
242
|
- docs/_docs/config/env.md
|
243
|
+
- docs/_docs/config/hooks.md
|
244
|
+
- docs/_docs/config/hooks/docker.md
|
245
|
+
- docs/_docs/config/hooks/kubectl.md
|
246
|
+
- docs/_docs/config/hooks/kubes.md
|
247
|
+
- docs/_docs/config/hooks/ruby.md
|
240
248
|
- docs/_docs/config/kubectl.md
|
241
|
-
- docs/_docs/config/
|
242
|
-
- docs/_docs/config/
|
249
|
+
- docs/_docs/config/reference.md
|
250
|
+
- docs/_docs/config/skip.md
|
243
251
|
- docs/_docs/contributing.md
|
244
252
|
- docs/_docs/dsl.md
|
245
253
|
- docs/_docs/dsl/multiple-resources.md
|
@@ -300,12 +308,14 @@ files:
|
|
300
308
|
- docs/_docs/next-steps.md
|
301
309
|
- docs/_docs/patterns.md
|
302
310
|
- docs/_docs/patterns/clock-web-worker.md
|
311
|
+
- docs/_docs/patterns/migrations.md
|
303
312
|
- docs/_docs/resources.md
|
304
313
|
- docs/_docs/resources/base.md
|
305
314
|
- docs/_docs/resources/role.md
|
306
315
|
- docs/_docs/resources/shared.md
|
307
316
|
- docs/_docs/yaml.md
|
308
317
|
- docs/_includes/commands.html
|
318
|
+
- docs/_includes/config/hooks/options.md
|
309
319
|
- docs/_includes/content.html
|
310
320
|
- docs/_includes/dsl/methods.md
|
311
321
|
- docs/_includes/dsl/rolling_deployment.md
|
@@ -476,19 +486,16 @@ files:
|
|
476
486
|
- lib/kubes/cli/help/exec.md
|
477
487
|
- lib/kubes/cli/init.rb
|
478
488
|
- lib/kubes/cli/logs.rb
|
489
|
+
- lib/kubes/cli/prune.rb
|
479
490
|
- lib/kubes/cli/sequence.rb
|
480
491
|
- lib/kubes/command.rb
|
481
492
|
- lib/kubes/compiler.rb
|
482
|
-
- lib/kubes/compiler/decorator.rb
|
483
493
|
- lib/kubes/compiler/decorator/base.rb
|
484
|
-
- lib/kubes/compiler/decorator/
|
485
|
-
- lib/kubes/compiler/decorator/
|
486
|
-
- lib/kubes/compiler/decorator/
|
487
|
-
- lib/kubes/compiler/decorator/
|
488
|
-
- lib/kubes/compiler/decorator/
|
489
|
-
- lib/kubes/compiler/decorator/resources/pod.rb
|
490
|
-
- lib/kubes/compiler/decorator/resources/secret.rb
|
491
|
-
- lib/kubes/compiler/decorator/write.rb
|
494
|
+
- lib/kubes/compiler/decorator/hashable.rb
|
495
|
+
- lib/kubes/compiler/decorator/hashable/field.rb
|
496
|
+
- lib/kubes/compiler/decorator/hashable/storage.rb
|
497
|
+
- lib/kubes/compiler/decorator/post.rb
|
498
|
+
- lib/kubes/compiler/decorator/pre.rb
|
492
499
|
- lib/kubes/compiler/dsl/core/base.rb
|
493
500
|
- lib/kubes/compiler/dsl/core/blocks.rb
|
494
501
|
- lib/kubes/compiler/dsl/core/fields.rb
|
@@ -532,20 +539,21 @@ files:
|
|
532
539
|
- lib/kubes/docker/strategy/build/base.rb
|
533
540
|
- lib/kubes/docker/strategy/build/docker.rb
|
534
541
|
- lib/kubes/docker/strategy/build/gcloud.rb
|
535
|
-
- lib/kubes/docker/strategy/hooks.rb
|
536
542
|
- lib/kubes/docker/strategy/image_name.rb
|
537
543
|
- lib/kubes/docker/strategy/push/base.rb
|
538
544
|
- lib/kubes/docker/strategy/push/docker.rb
|
539
545
|
- lib/kubes/docker/strategy/push/gcloud.rb
|
540
546
|
- lib/kubes/docker/strategy/utils.rb
|
541
547
|
- lib/kubes/hooks/builder.rb
|
548
|
+
- lib/kubes/hooks/concern.rb
|
542
549
|
- lib/kubes/hooks/dsl.rb
|
550
|
+
- lib/kubes/hooks/runner.rb
|
543
551
|
- lib/kubes/kubectl.rb
|
544
552
|
- lib/kubes/kubectl/args/base.rb
|
545
553
|
- lib/kubes/kubectl/args/kustomize.rb
|
546
554
|
- lib/kubes/kubectl/args/standard.rb
|
547
555
|
- lib/kubes/kubectl/batch.rb
|
548
|
-
- lib/kubes/kubectl/
|
556
|
+
- lib/kubes/kubectl/dispatcher.rb
|
549
557
|
- lib/kubes/kubectl/fetch/base.rb
|
550
558
|
- lib/kubes/kubectl/fetch/deployment.rb
|
551
559
|
- lib/kubes/kubectl/fetch/pods.rb
|
@@ -579,6 +587,7 @@ files:
|
|
579
587
|
- spec/fixtures/artifacts/demo-web/deployment.yaml
|
580
588
|
- spec/fixtures/artifacts/demo-web/service.yaml
|
581
589
|
- spec/fixtures/blocks/deployments.rb
|
590
|
+
- spec/fixtures/decorators/deployment/both/envFrom.yaml
|
582
591
|
- spec/fixtures/decorators/deployment/configMap/envFrom.yaml
|
583
592
|
- spec/fixtures/decorators/deployment/configMap/valueFrom.yaml
|
584
593
|
- spec/fixtures/decorators/deployment/configMap/volumes.yaml
|
@@ -604,11 +613,14 @@ files:
|
|
604
613
|
- spec/fixtures/project/.kubes/resources/deployment.rb
|
605
614
|
- spec/fixtures/project/.kubes/resources/foobar.rb
|
606
615
|
- spec/fixtures/project/.kubes/resources/service.rb
|
616
|
+
- spec/fixtures/prune/capture.yaml
|
617
|
+
- spec/fixtures/prune/fetch_items.yaml
|
607
618
|
- spec/fixtures/services/minimum.rb
|
608
619
|
- spec/fixtures/syntax/network_policy.rb
|
609
620
|
- spec/fixtures/syntax/pod.rb
|
610
|
-
- spec/kubes/
|
611
|
-
- spec/kubes/compiler/decorator/
|
621
|
+
- spec/kubes/cli/prune_spec.rb
|
622
|
+
- spec/kubes/compiler/decorator/post/deployment_spec.rb
|
623
|
+
- spec/kubes/compiler/decorator/post/pod_spec.rb
|
612
624
|
- spec/kubes/compiler/strategy/dsl_spec.rb
|
613
625
|
- spec/kubes/compiler_spec.rb
|
614
626
|
- spec/kubes/dsl/daemon_set.rb
|
@@ -648,6 +660,7 @@ test_files:
|
|
648
660
|
- spec/fixtures/artifacts/demo-web/deployment.yaml
|
649
661
|
- spec/fixtures/artifacts/demo-web/service.yaml
|
650
662
|
- spec/fixtures/blocks/deployments.rb
|
663
|
+
- spec/fixtures/decorators/deployment/both/envFrom.yaml
|
651
664
|
- spec/fixtures/decorators/deployment/configMap/envFrom.yaml
|
652
665
|
- spec/fixtures/decorators/deployment/configMap/valueFrom.yaml
|
653
666
|
- spec/fixtures/decorators/deployment/configMap/volumes.yaml
|
@@ -673,11 +686,14 @@ test_files:
|
|
673
686
|
- spec/fixtures/project/.kubes/resources/deployment.rb
|
674
687
|
- spec/fixtures/project/.kubes/resources/foobar.rb
|
675
688
|
- spec/fixtures/project/.kubes/resources/service.rb
|
689
|
+
- spec/fixtures/prune/capture.yaml
|
690
|
+
- spec/fixtures/prune/fetch_items.yaml
|
676
691
|
- spec/fixtures/services/minimum.rb
|
677
692
|
- spec/fixtures/syntax/network_policy.rb
|
678
693
|
- spec/fixtures/syntax/pod.rb
|
679
|
-
- spec/kubes/
|
680
|
-
- spec/kubes/compiler/decorator/
|
694
|
+
- spec/kubes/cli/prune_spec.rb
|
695
|
+
- spec/kubes/compiler/decorator/post/deployment_spec.rb
|
696
|
+
- spec/kubes/compiler/decorator/post/pod_spec.rb
|
681
697
|
- spec/kubes/compiler/strategy/dsl_spec.rb
|
682
698
|
- spec/kubes/compiler_spec.rb
|
683
699
|
- spec/kubes/dsl/daemon_set.rb
|
@@ -1,39 +0,0 @@
|
|
1
|
-
---
|
2
|
-
title: Kubectl Hooks
|
3
|
-
---
|
4
|
-
|
5
|
-
Here are some examples of running custom hooks before and after the kubectl commands.
|
6
|
-
|
7
|
-
.kubes/config/kubectl/hooks.rb
|
8
|
-
|
9
|
-
```ruby
|
10
|
-
before("apply",
|
11
|
-
execute: "kubectl apply -f .kubes/shared/namespace.yaml",
|
12
|
-
)
|
13
|
-
|
14
|
-
after("delete",
|
15
|
-
execute: "echo 'delete hook',
|
16
|
-
)
|
17
|
-
```
|
18
|
-
|
19
|
-
You can use hooks to do things that may not make sense to do in the `.kubes/resources` definition. Here's an example of automatically creating the namespace.
|
20
|
-
|
21
|
-
.kubes/shared/namespace.yaml
|
22
|
-
|
23
|
-
```yaml
|
24
|
-
apiVersion: v1
|
25
|
-
kind: Namespace
|
26
|
-
metadata:
|
27
|
-
name: demo
|
28
|
-
```
|
29
|
-
|
30
|
-
### exit on fail
|
31
|
-
|
32
|
-
By default, if the hook commands fail, then terraspace will exit with the original hook error code. You can change this behavior with the `exit_on_fail` option.
|
33
|
-
|
34
|
-
```ruby
|
35
|
-
before("apply"
|
36
|
-
execute: "/command/will/fail/but/will/continue",
|
37
|
-
exit_on_fail: false,
|
38
|
-
)
|
39
|
-
```
|
@@ -1,76 +0,0 @@
|
|
1
|
-
module Kubes::Compiler::Decorator::Resources
|
2
|
-
class Container
|
3
|
-
include Mapping
|
4
|
-
|
5
|
-
def initialize(data, kind:, fields_for:)
|
6
|
-
@data = data
|
7
|
-
# These methods are defined in Mapping
|
8
|
-
kind == "Deployment" ? deployment_keys : pod_keys
|
9
|
-
fields_for == "Secret" ? secrets_fields : configMaps_fields
|
10
|
-
end
|
11
|
-
|
12
|
-
def run
|
13
|
-
envFrom!
|
14
|
-
valueFrom!
|
15
|
-
volumes!
|
16
|
-
@data
|
17
|
-
end
|
18
|
-
|
19
|
-
# spec.envFrom.configMapRef
|
20
|
-
# spec.envFrom.secretRef
|
21
|
-
def envFrom!
|
22
|
-
return @data unless containers
|
23
|
-
|
24
|
-
containers.each do |container|
|
25
|
-
next unless envFrom_list = container.dig('envFrom') # intentional assignment
|
26
|
-
|
27
|
-
envFrom_list.each do |envFrom|
|
28
|
-
next unless name = envFrom.dig(@envFrom_field, 'name') # intentional assignment
|
29
|
-
|
30
|
-
md5 = Kubes::Compiler::Decorator.fetch(name)
|
31
|
-
envFrom[@envFrom_field]['name'] = [name, md5].compact.join('-')
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# spec.valueFrom.configMapKeyRef
|
37
|
-
# spec.valueFrom.secretKeyRef
|
38
|
-
def valueFrom!
|
39
|
-
return @data unless containers
|
40
|
-
|
41
|
-
containers.each do |container|
|
42
|
-
next unless env_list = container.dig('env') # intentional assignment
|
43
|
-
|
44
|
-
env_list.each do |env|
|
45
|
-
next unless name = env.dig('valueFrom',@valueFrom_field,'name') # intentional assignment
|
46
|
-
|
47
|
-
md5 = Kubes::Compiler::Decorator.fetch(name)
|
48
|
-
env['valueFrom'][@valueFrom_field]['name'] = [name, md5].compact.join('-')
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
# spec.volumes.configMap.name
|
54
|
-
# spec.volumes.secret.secretName
|
55
|
-
def volumes!
|
56
|
-
volumes = @data.dig(*@volumes_key.split('.'))
|
57
|
-
return @data unless volumes
|
58
|
-
|
59
|
-
volumes.each do |volume|
|
60
|
-
# Example:
|
61
|
-
# next unless field = volume.dig('secret') # intentional assignment
|
62
|
-
# next unless name = field['secretName'] # intentional assignment
|
63
|
-
next unless field = volume.dig(@volume_field) # intentional assignment
|
64
|
-
next unless name = field[@volume_field_name] # intentional assignment
|
65
|
-
|
66
|
-
md5 = Kubes::Compiler::Decorator.fetch(name)
|
67
|
-
field[@volume_field_name] = [name, md5].compact.join('-')
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
private
|
72
|
-
def containers
|
73
|
-
@data.dig(*@containers_key.split('.'))
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
class Kubes::Compiler::Decorator::Resources::Container
|
2
|
-
# Nice to group the mapping logic in ones spot, making a pattern of this is not worth it.
|
3
|
-
module Mapping
|
4
|
-
def deployment_keys
|
5
|
-
@containers_key = 'spec.template.spec.containers'
|
6
|
-
@volumes_key = 'spec.template.spec.volumes'
|
7
|
-
end
|
8
|
-
|
9
|
-
def pod_keys
|
10
|
-
@containers_key = 'spec.containers'
|
11
|
-
@volumes_key = 'spec.volumes'
|
12
|
-
end
|
13
|
-
|
14
|
-
def configMaps_fields
|
15
|
-
@envFrom_field = 'configMapRef'
|
16
|
-
@valueFrom_field = 'configMapKeyRef'
|
17
|
-
@volume_field = 'configMap'
|
18
|
-
@volume_field_name = 'name'
|
19
|
-
end
|
20
|
-
|
21
|
-
def secrets_fields
|
22
|
-
@envFrom_field = 'secretRef'
|
23
|
-
@valueFrom_field = 'secretKeyRef'
|
24
|
-
@volume_field = 'secret'
|
25
|
-
@volume_field_name = 'secretName'
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
module Kubes::Compiler::Decorator::Resources
|
2
|
-
class Deployment < Base
|
3
|
-
def perform
|
4
|
-
container = Container.new(@data, kind: "Deployment", fields_for: "Secret")
|
5
|
-
@data = container.run
|
6
|
-
container = Container.new(@data, kind: "Deployment", fields_for: "ConfigMap")
|
7
|
-
@data = container.run
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|