class Kubes::Compiler::Decorator::Hashable

Public Instance Methods

md5(data) click to toggle source
# File lib/kubes/compiler/decorator/hashable.rb, line 19
def md5(data)
  content = yaml_dump(data)
  Digest::MD5.hexdigest(content)[0..9]
end
store() click to toggle source
# 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

  # puts "name #{name}" # TODO: scope Kind so Secret and ConfigMap can have the same name...
  md5 = md5(@data)
  @data['metadata']['name'] = "#{name}-#{md5}"
  Storage.store(@data['kind'], name, md5)
  @data
end