Class: Kubes::Compiler::Decorator::Hashable
- Includes:
- Util::YamlDump
- Defined in:
- lib/kubes/compiler/decorator/hashable.rb,
lib/kubes/compiler/decorator/hashable/field.rb,
lib/kubes/compiler/decorator/hashable/storage.rb
Defined Under Namespace
Modules: Storage Classes: Field
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods included from Util::YamlDump
Methods inherited from Base
Constructor Details
This class inherits a constructor from Kubes::Compiler::Decorator::Base
Instance Method Details
#md5(data) ⇒ Object
19 20 21 22 |
# File 'lib/kubes/compiler/decorator/hashable.rb', line 19 def md5(data) content = yaml_dump(data) Digest::MD5.hexdigest(content)[0..9] end |
#store ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/kubes/compiler/decorator/hashable.rb', line 7 def store # even though name is required, will allow logic to get the kubectl apply and kubectl to surface the required name error name = @data.dig('metadata','name') return @data unless name # scope Kind so Secret and ConfigMap can have same name md5 = md5(@data) @data['metadata']['name'] = "#{name}-#{md5}" Storage.store(@data['kind'], name, md5) @data end |