kubes 0.7.7 → 0.8.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.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +17 -0
  3. data/README.md +4 -4
  4. data/docs/.gitignore +1 -0
  5. data/docs/Gemfile +2 -0
  6. data/docs/_config.yml +8 -0
  7. data/docs/_docs/config/app-overrides.md +7 -0
  8. data/docs/_docs/config/boot.md +46 -0
  9. data/docs/_docs/config/env.md +29 -2
  10. data/docs/_docs/config/hooks/docker.md +2 -0
  11. data/docs/_docs/config/hooks/generator.md +16 -0
  12. data/docs/_docs/config/hooks/kubectl.md +2 -0
  13. data/docs/_docs/config/hooks/kubes.md +2 -0
  14. data/docs/_docs/config/reference.md +2 -2
  15. data/docs/_docs/config/skip.md +22 -0
  16. data/docs/_docs/dsl/resources.md +1 -1
  17. data/docs/_docs/dsl.md +2 -2
  18. data/docs/_docs/helpers/aws/iam-role.md +1 -0
  19. data/docs/_docs/helpers/google/gke.md +1 -1
  20. data/docs/_docs/install/dependencies.md +18 -0
  21. data/docs/_docs/install/gem.md +6 -0
  22. data/docs/_docs/install/standalone/centos.md +70 -0
  23. data/docs/_docs/install/standalone/details/permissions.md +44 -0
  24. data/docs/_docs/install/standalone/details/uninstall.md +16 -0
  25. data/docs/_docs/install/standalone/details.md +20 -0
  26. data/docs/_docs/install/standalone/macosx.md +45 -0
  27. data/docs/_docs/install/standalone/ubuntu.md +48 -0
  28. data/docs/_docs/install/standalone.md +43 -0
  29. data/docs/_docs/install.md +8 -0
  30. data/docs/_docs/learn/dsl/install.md +1 -1
  31. data/docs/_docs/learn/yaml/install.md +1 -1
  32. data/docs/_docs/patterns/central-deployer.md +36 -0
  33. data/docs/_docs/variables/advanced.md +32 -1
  34. data/docs/_docs/variables/basic.md +1 -0
  35. data/docs/_docs/vs/custom.md +2 -0
  36. data/docs/_docs/vs/helm.md +2 -0
  37. data/docs/_docs/vs/kustomize.md +3 -1
  38. data/docs/_docs/vs.md +2 -0
  39. data/docs/_docs/yaml/erb-comment.md +89 -0
  40. data/docs/_includes/banner/foot.html +2 -0
  41. data/docs/_includes/banner/head.html +5 -0
  42. data/docs/_includes/config/app-overrides-cheatsheet.md +44 -0
  43. data/docs/_includes/config/hooks/generator.md +6 -0
  44. data/docs/_includes/content.html +1 -1
  45. data/docs/_includes/install/gem.md +7 -0
  46. data/docs/_includes/install/wrapper.md +9 -0
  47. data/docs/_includes/layering/layers.md +3 -0
  48. data/docs/_includes/learn/next-steps.md +11 -0
  49. data/docs/_includes/sidebar.html +28 -3
  50. data/docs/_includes/videos/learn/vs.md +4 -0
  51. data/docs/_includes/videos/learn.md +12 -0
  52. data/docs/_includes/videos/youtube.md +1 -0
  53. data/docs/_layouts/default.html +3 -0
  54. data/docs/_reference/kubes-new-hook.md +30 -0
  55. data/docs/_reference/kubes-new-variable.md +7 -0
  56. data/docs/_reference/kubes-new.md +1 -0
  57. data/docs/_sass/theme.scss +11 -0
  58. data/docs/bin/web +1 -1
  59. data/docs/js/scripts.js +7 -0
  60. data/kubes.gemspec +1 -0
  61. data/lib/kubes/booter.rb +26 -0
  62. data/lib/kubes/cli/help/new/hook.md +9 -0
  63. data/lib/kubes/cli/help/new/variable.md +6 -0
  64. data/lib/kubes/cli/init.rb +0 -1
  65. data/lib/kubes/cli/new/hook.rb +18 -0
  66. data/lib/kubes/cli/new.rb +4 -0
  67. data/lib/kubes/compiler/decorator/hashable/field.rb +41 -22
  68. data/lib/kubes/compiler/decorator/hashable.rb +1 -1
  69. data/lib/kubes/compiler/decorator/post.rb +12 -12
  70. data/lib/kubes/compiler/layering.rb +9 -0
  71. data/lib/kubes/compiler/shared/runtime_helpers.rb +8 -1
  72. data/lib/kubes/compiler/strategy/erb/comment.rb +46 -0
  73. data/lib/kubes/compiler/strategy/erb.rb +4 -0
  74. data/lib/kubes/compiler/strategy/result.rb +13 -1
  75. data/lib/kubes/compiler.rb +2 -0
  76. data/lib/kubes/config.rb +6 -2
  77. data/lib/kubes/core.rb +4 -0
  78. data/lib/kubes/kubectl/ordering.rb +9 -6
  79. data/lib/kubes/version.rb +1 -1
  80. data/lib/kubes.rb +3 -0
  81. data/lib/templates/new/hooks/docker.rb +9 -0
  82. data/lib/templates/new/hooks/kubectl.rb +11 -0
  83. data/lib/templates/new/hooks/kubes.rb +9 -0
  84. data/lib/templates/yaml/.kubes/resources/base/deployment.yaml.tt +2 -0
  85. data/spec/fixtures/decorators/deployment/configMap/volumes-name-first.yaml +14 -0
  86. data/spec/fixtures/decorators/deployment/configMap/volumes-name-second.yaml +14 -0
  87. data/spec/fixtures/decorators/ingress/tls.yaml +12 -0
  88. data/spec/kubes/compiler/decorator/post/deployment_spec.rb +25 -0
  89. data/spec/kubes/compiler/decorator/post/ingress_spec.rb +22 -0
  90. metadata +59 -5
  91. data/docs/_docs/intro/install.md +0 -6
  92. data/docs/_includes/intro/install.md +0 -19
data/lib/kubes/cli/new.rb CHANGED
@@ -11,5 +11,9 @@ class Kubes::CLI
11
11
  long_desc Help.text("new/variable")
12
12
  Variable.options.each { |args| option(*args) }
13
13
  register(Variable, "variable", "variable", "Generates kubes variable file.")
14
+
15
+ long_desc Help.text("new/hook")
16
+ Hook.options.each { |args| option(*args) }
17
+ register(Hook, "hook", "hook", "Generates kubes hook file.")
14
18
  end
15
19
  end
@@ -1,53 +1,72 @@
1
1
  class Kubes::Compiler::Decorator::Hashable
2
2
  class Field
3
- # item is full wrapper structure
3
+ # item is full structure
4
4
  #
5
- # secretRef: <--- wrapper
6
- # name: demo-secret
5
+ # secretRef: <--- wrapper_key
6
+ # name: demo-secret <--- target_key is 'name' from wrapper_map[wrapper_key]
7
7
  #
8
+ attr_reader :item # for debugging
8
9
  def initialize(item)
9
10
  @item = item
10
11
  end
11
12
 
12
13
  def hashable?
13
- x = @item.keys & map.keys
14
+ x = @item.keys & wrapper_map.keys
14
15
  !x.empty?
15
16
  end
16
17
 
17
18
  def kind
18
- wrapper =~ /configMap/ ? "ConfigMap" : "Secret"
19
+ wrapper_key =~ /configMap/ ? "ConfigMap" : "Secret"
19
20
  end
20
21
 
21
- # The key of the hashable value.
22
+ # The target key of the hashable value is that key used for find value to add hash
22
23
  #
23
24
  # envFrom:
24
- # - secretRef:
25
- # name: demo-secret <--- wrapper is 'name'
25
+ # - secretRef: <--- wrapper_key
26
+ # name: demo-secret <--- target_key is 'name' from wrapper_map[wrapper_key]
26
27
  #
27
- def key
28
- map[wrapper]
28
+ def target_key
29
+ wrapper_map[wrapper_key]
29
30
  end
30
31
 
31
32
  # The wrapper field is nested right above the item with the hashable value.
33
+ # Simple example:
32
34
  #
33
35
  # envFrom:
34
- # - secretRef: <--- wrapper
35
- # name: demo-secret
36
+ # - secretRef: <--- wrapper_key
37
+ # name: demo-secret <--- target_key is 'name' from wrapper_map[wrapper_key]
36
38
  #
37
- def wrapper
38
- @item.keys.first
39
+ # More complex example where there's a configMap.name key also on the same level.
40
+ #
41
+ # volumes:
42
+ # - name: config-map-volume
43
+ # configMap:
44
+ # name: demo-config-map
45
+ #
46
+ # Note: Wont work for case when there's are 2 matching wrapper_map keys,
47
+ # but don't think Kubernetes allows 2 matching wrapper_map keys.
48
+ # Example: This is invalid Kubernetes YAML.
49
+ #
50
+ # volumes:
51
+ # - name: config-map-volume
52
+ # configMap:
53
+ # name: demo-config-map
54
+ # secretRef:
55
+ # name: demo-seret
56
+ def wrapper_key
57
+ @item.keys.find { |k| wrapper_map.keys.include?(k) } # this key used for map[wrapper_key]
39
58
  end
40
59
 
41
60
  # wrapper element to key that stores the hashable value
42
- def map
61
+ def wrapper_map
43
62
  {
44
- 'configMapRef' => 'name',
45
- 'configMapKeyRef' => 'name',
46
- 'configMap' => 'name',
47
- 'secretRef' => 'name',
48
- 'secretKeyRef' => 'name',
49
- 'secret' => 'secretName',
50
- 'tls' => 'secretName',
63
+ 'configMapRef' => 'name', # containers.env.envFrom.configMapRef.name
64
+ 'configMapKeyRef' => 'name', # containers.env.valueFrom.configMapKeyRef.name
65
+ 'configMap' => 'name', # containers.env.envFrom.configMapRef.name
66
+ 'secretRef' => 'name', # containers.env.envFrom.secretRef.name
67
+ 'secretKeyRef' => 'name', # containers.env.valueFrom.secretKeyRef.name
68
+ 'secret' => 'secretName', # volumes.secret.secretName
69
+ 'tls' => 'secretName', # tls.secretName
51
70
  }
52
71
  end
53
72
  end
@@ -9,7 +9,7 @@ module Kubes::Compiler::Decorator
9
9
  name = @data.dig('metadata','name')
10
10
  return @data unless name
11
11
 
12
- # puts "name #{name}" # TODO: scope Kind so Secret and ConfigMap can have the same name...
12
+ # scope Kind so Secret and ConfigMap can have same name
13
13
  md5 = md5(@data)
14
14
  @data['metadata']['name'] = "#{name}-#{md5}"
15
15
  Storage.store(@data['kind'], name, md5)
@@ -16,12 +16,12 @@ module Kubes::Compiler::Decorator
16
16
  # hashable set from previous stack call
17
17
  if options[:hashable_field] && item.is_a?(Hash)
18
18
  field = options[:hashable_field]
19
- value_without_md5 = item[field.key]
19
+ value_without_md5 = item[field.target_key]
20
20
  @reset_hashable_field = true unless value_without_md5
21
21
  if field.hashable? && value_without_md5
22
22
  md5 = Hashable::Storage.fetch(field.kind, value_without_md5)
23
23
  v = [value_without_md5, md5].compact.join('-')
24
- item[field.key] = v
24
+ item[field.target_key] = v
25
25
  end
26
26
  end
27
27
 
@@ -29,10 +29,10 @@ module Kubes::Compiler::Decorator
29
29
  # Pretty tricky case. Given:
30
30
  #
31
31
  # envFrom:
32
- # - secretRef:
33
- # name: demo-secret
34
- # - configMapRef:
35
- # name: demo-config-map
32
+ # - secretRef: <--- wrapper_key
33
+ # name: demo-secret <--- target_key is 'name' from wrapper_map[wrapper_key]
34
+ # - configMapRef: <--- wrapper_key
35
+ # name: demo-config-map <--- target_key is 'name' from wrapper_map[wrapper_key]
36
36
  #
37
37
  # Need to reset the stored hashable_field in the call stack.
38
38
  # Else the field.kind is cached and the md5 look is incorrect
@@ -52,19 +52,19 @@ module Kubes::Compiler::Decorator
52
52
  #
53
53
  # 1. envFrom example
54
54
  # envFrom:
55
- # - secretRef:
56
- # name: demo-secret
55
+ # - secretRef: <--- wrapper_key
56
+ # name: demo-secret <--- target_key is 'name' from wrapper_map[wrapper_key]
57
57
  #
58
58
  # 2. valueFrom example
59
59
  # valueFrom:
60
- # secretKeyRef:
61
- # name: demo-secret
60
+ # secretKeyRef: <--- wrapper_key
61
+ # name: demo-secret <--- target_key is 'name' from wrapper_map[wrapper_key]
62
62
  # key: password
63
63
  #
64
64
  # 3. volumes example
65
65
  # volumes:
66
- # - secret:
67
- # secretName: demo-secret
66
+ # - secret: <--- wrapper_key
67
+ # secretName: demo-secret <--- target_key is 'name' from wrapper_map[wrapper_key]
68
68
  #
69
69
  # This is useful to capture for the next level of the stack call
70
70
  #
@@ -31,6 +31,15 @@ class Kubes::Compiler
31
31
  "base",
32
32
  Kubes.env.to_s
33
33
  ]
34
+
35
+ if Kubes.app
36
+ layers += [
37
+ Kubes.app,
38
+ "#{Kubes.app}/base",
39
+ "#{Kubes.app}/#{Kubes.env}",
40
+ ]
41
+ end
42
+
34
43
  layers = add_exts(layers)
35
44
  layers.map! do |layer|
36
45
  "#{kind_path}/#{layer}"
@@ -3,9 +3,9 @@ module Kubes::Compiler::Shared
3
3
  include Kubes::Compiler::Shared::Helpers
4
4
 
5
5
  def load_runtime_helpers
6
- load_custom_variables # also load custom variables
7
6
  load_plugin_helpers
8
7
  load_custom_helpers
8
+ load_custom_variables # also load custom variables
9
9
  end
10
10
 
11
11
  @@custom_helpers_loaded = false
@@ -68,6 +68,13 @@ module Kubes::Compiler::Shared
68
68
  "#{role}/#{kind}/base.rb",
69
69
  "#{role}/#{kind}/#{Kubes.env}.rb",
70
70
  ]
71
+ if Kubes.app
72
+ app_layers = ["#{Kubes.app}.rb"]
73
+ app_layers += layers.map do |path|
74
+ "#{Kubes.app}/#{path}"
75
+ end
76
+ layers += app_layers
77
+ end
71
78
 
72
79
  layers.each do |layer|
73
80
  path = "#{Kubes.root}/.kubes/variables/#{layer}"
@@ -0,0 +1,46 @@
1
+ # Processes the ERB files and looks for comments like
2
+ #
3
+ # #ERB if @testvar
4
+ # - "some yaml"
5
+ # #ERB end
6
+ #
7
+ class Kubes::Compiler::Strategy::Erb
8
+ class Comment
9
+ extend Memoist
10
+
11
+ def initialize(path)
12
+ @path = path
13
+ end
14
+
15
+ def lines
16
+ IO.readlines(@path)
17
+ end
18
+ memoize :lines
19
+
20
+ def process?
21
+ !!lines.detect { |l| l.include?('#ERB') }
22
+ end
23
+
24
+ def process
25
+ new_lines = lines.map do |line|
26
+ md = line.match(/(.*)#ERB(.*)/)
27
+ if md
28
+ "#{md[1]}<%#{md[2]} %>\n"
29
+ else
30
+ line
31
+ end
32
+ end
33
+ content = new_lines.join('')
34
+ IO.write(erb_path, content)
35
+ erb_path
36
+ end
37
+
38
+ def clean
39
+ FileUtils.rm_f(erb_path) unless ENV['KUBES_KEEP_ERB']
40
+ end
41
+
42
+ def erb_path
43
+ "#{@path}.erb"
44
+ end
45
+ end
46
+ end
@@ -17,7 +17,11 @@ class Kubes::Compiler::Strategy
17
17
  def render_result(path)
18
18
  return unless File.exist?(path)
19
19
 
20
+ comment = Comment.new(path)
21
+ path = comment.process if comment.process?
20
22
  yaml = RenderMePretty.result(path, context: self)
23
+ comment.clean if comment.process?
24
+
21
25
  result = yaml_load(path, yaml)
22
26
  # in case of blank yaml doc a Boolean false is returned. else Hash or Array is returned
23
27
  %w[Array Hash].include?(result.class.to_s) ? result : {}
@@ -21,8 +21,20 @@ class Kubes::Compiler::Strategy
21
21
  end
22
22
 
23
23
  def content
24
- result = @data.size == 1 ? @data.first : @data
24
+ data = filter_skip(@data)
25
+ return if data.empty?
26
+ result = data.size == 1 ? data.first : data
25
27
  yaml_dump(result)
26
28
  end
29
+
30
+ def skip?
31
+ content.nil?
32
+ end
33
+
34
+ def filter_skip(data)
35
+ data.reject do |item|
36
+ item.dig('kubes', 'skip')
37
+ end
38
+ end
27
39
  end
28
40
  end
@@ -38,6 +38,8 @@ module Kubes
38
38
  end
39
39
 
40
40
  def write(result)
41
+ return if config_skip?(result.filename)
42
+ return if result.skip?
41
43
  result.decorate!(:post)
42
44
  filename, content = result.filename, result.content
43
45
  dest = "#{Kubes.root}/.kubes/output/#{filename}"
data/lib/kubes/config.rb CHANGED
@@ -18,7 +18,7 @@ module Kubes
18
18
  # Auto-switching options
19
19
  config.kubectl = ActiveSupport::OrderedOptions.new
20
20
  config.kubectl.context = nil
21
- config.kubectl.context_keep = true # after switching context keep it
21
+ config.kubectl.context_keep = false # after switching context keep it
22
22
 
23
23
  # whether or not continue if the kubectl command fails
24
24
  config.kubectl.exit_on_fail = ActiveSupport::OrderedOptions.new
@@ -39,7 +39,7 @@ module Kubes
39
39
  config.skip = []
40
40
 
41
41
  config.state = ActiveSupport::OrderedOptions.new
42
- config.state.path = "#{Kubes.root}/.kubes/state/#{Kubes.env}/data.json"
42
+ config.state.path = ["#{Kubes.root}/.kubes/tmp/state", Kubes.app, "#{Kubes.env}/data.json"].compact.join('/')
43
43
 
44
44
  config.suffix_hash = true # append suffix hash to ConfigMap and Secret
45
45
 
@@ -95,6 +95,10 @@ module Kubes
95
95
  def load_configs
96
96
  evaluate_file(".kubes/config.rb")
97
97
  evaluate_file(".kubes/config/env/#{Kubes.env}.rb")
98
+ if Kubes.app
99
+ evaluate_file(".kubes/config/env/#{Kubes.app}.rb")
100
+ evaluate_file(".kubes/config/env/#{Kubes.app}/#{Kubes.env}.rb")
101
+ end
98
102
  Kubes::Plugin.plugins.each do |klass|
99
103
  # klass: IE: KubesAws, KubesGoogle
100
104
  name = klass.to_s.underscore.sub('kubes_','') # kubes_google => google
data/lib/kubes/core.rb CHANGED
@@ -2,6 +2,10 @@ module Kubes
2
2
  module Core
3
3
  extend Memoist
4
4
 
5
+ def app
6
+ ENV['KUBES_APP']
7
+ end
8
+
5
9
  def env
6
10
  ENV['KUBES_ENV'] || "dev"
7
11
  end
@@ -13,20 +13,23 @@ class Kubes::Kubectl
13
13
  "#{role_i}/#{kind_i}"
14
14
  end
15
15
 
16
- sorted = filter_files(sorted)
16
+ sorted = filter_skip(sorted)
17
17
 
18
18
  @name == "delete" ? sorted.reverse : sorted
19
19
  end
20
20
 
21
- def filter_files(sorted)
22
- skip = Kubes.config.skip
23
- skip += ENV['KUBES_SKIP'].split(' ') if ENV['KUBES_SKIP']
24
- return sorted if skip.empty?
21
+ def filter_skip(sorted)
25
22
  sorted.reject do |file|
26
- skip.detect { |text| file.include?(text) }
23
+ config_skip?(file)
27
24
  end
28
25
  end
29
26
 
27
+ def config_skip?(file)
28
+ skip = Kubes.config.skip
29
+ skip += ENV['KUBES_SKIP'].split(' ') if ENV['KUBES_SKIP']
30
+ !!skip.detect { |pattern| file.include?(pattern) }
31
+ end
32
+
30
33
  # type: kinds or roles
31
34
  # value: Examples: kind: deployment, role: web
32
35
  def index_for(type, value)
data/lib/kubes/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kubes
2
- VERSION = "0.7.7"
2
+ VERSION = "0.8.0"
3
3
  end
data/lib/kubes.rb CHANGED
@@ -5,6 +5,7 @@ $:.unshift(File.expand_path("../", __FILE__))
5
5
  require "kubes/autoloader"
6
6
  Kubes::Autoloader.setup
7
7
 
8
+ require "active_support"
8
9
  require "active_support/core_ext/class"
9
10
  require "active_support/core_ext/hash"
10
11
  require "active_support/core_ext/string"
@@ -30,3 +31,5 @@ module Kubes
30
31
  class MissingDockerImage < Error; end
31
32
  extend Core
32
33
  end
34
+
35
+ Kubes::Booter.boot
@@ -0,0 +1,9 @@
1
+ # Docs: https://kubes.guru/docs/config/hooks/docker/
2
+
3
+ before("build",
4
+ execute: "echo 'docker build before hook'",
5
+ )
6
+
7
+ after("build",
8
+ execute: "echo 'docker build after hook'",
9
+ )
@@ -0,0 +1,11 @@
1
+ # Docs: https://kubes.guru/docs/config/hooks/kubectl/
2
+
3
+ before("apply",
4
+ on: "web/deployment",
5
+ execute: "echo 'before apply hook test'",
6
+ )
7
+
8
+ after("delete",
9
+ on: "web/deployment",
10
+ execute: "echo 'after delete hook test'",
11
+ )
@@ -0,0 +1,9 @@
1
+ # Docs: https://kubes.guru/docs/config/hooks/kubes/
2
+
3
+ before("apply",
4
+ execute: "echo 'kubes before apply hook'",
5
+ )
6
+
7
+ after("apply",
8
+ execute: "echo 'kubes after apply hook'",
9
+ )
@@ -2,7 +2,9 @@ spec:
2
2
  selector:
3
3
  matchLabels:
4
4
  app: <%= app %>
5
+ env: <%= Kubes.env %>
5
6
  template:
6
7
  metadata:
7
8
  labels:
8
9
  app: <%= app %>
10
+ env: <%= Kubes.env %>
@@ -0,0 +1,14 @@
1
+ ---
2
+ # apiVersion: apps/v1
3
+ # kind: Deployment
4
+ # spec:
5
+ # template:
6
+ # spec:
7
+ # only including structure needed for spec
8
+ volumes:
9
+ - name: config-map-volume
10
+ configMap:
11
+ name: demo-config-map
12
+ items:
13
+ - key: k1
14
+ path: config-map.conf
@@ -0,0 +1,14 @@
1
+ ---
2
+ # apiVersion: apps/v1
3
+ # kind: Deployment
4
+ # spec:
5
+ # template:
6
+ # spec:
7
+ # only including structure needed for spec
8
+ volumes:
9
+ - configMap:
10
+ name: demo-config-map
11
+ items:
12
+ - key: k1
13
+ path: config-map.conf
14
+ name: config-map-volume
@@ -0,0 +1,12 @@
1
+ apiVersion: networking.k8s.io/v1
2
+ kind: Ingress
3
+ metadata:
4
+ name: web
5
+ spec:
6
+ tls:
7
+ - secretName: tls-secret
8
+ defaultBackend:
9
+ service:
10
+ name: web
11
+ port:
12
+ number: 80
@@ -135,4 +135,29 @@ describe Kubes::Compiler::Decorator::Post do
135
135
  end
136
136
  end
137
137
  end
138
+
139
+ context "order" do
140
+ # spec to fix issue https://github.com/boltops-tools/kubes/issues/49
141
+ describe "name first" do
142
+ let(:data) { fixture("configMap/volumes-name-first") }
143
+ it "run" do
144
+ decorator.run
145
+ data = decorator.data
146
+ volumes = data['volumes']
147
+ name = volumes[0]['configMap']['name']
148
+ expect(name).to eq("demo-config-map-fakehash-config")
149
+ end
150
+ end
151
+
152
+ describe "name second" do
153
+ let(:data) { fixture("configMap/volumes-name-second") }
154
+ it "run" do
155
+ decorator.run
156
+ data = decorator.data
157
+ volumes = data['volumes']
158
+ name = volumes[0]['configMap']['name']
159
+ expect(name).to eq("demo-config-map-fakehash-config")
160
+ end
161
+ end
162
+ end
138
163
  end
@@ -0,0 +1,22 @@
1
+ describe Kubes::Compiler::Decorator::Post do
2
+ let(:decorator) { described_class.new(data) }
3
+
4
+ def fixture(name)
5
+ YAML.load_file("spec/fixtures/decorators/ingress/#{name}.yaml")
6
+ end
7
+ before(:each) do
8
+ allow(Kubes::Compiler::Decorator::Hashable::Storage).to receive(:fetch).and_return("fakehash")
9
+ end
10
+
11
+ context "ingress" do
12
+ describe "tls" do
13
+ let(:data) { fixture("tls") }
14
+ it "run" do
15
+ decorator.run
16
+ data = decorator.data
17
+ name = data['spec']['tls'][0]['secretName']
18
+ expect(name).to eq("tls-secret-fakehash")
19
+ end
20
+ end
21
+ end
22
+ end