class Kubes::Compiler::Decorator::Hashable::Field

Public Class Methods

new(item) click to toggle source

item is full wrapper structure

secretRef:  <--- wrapper
  name: demo-secret
# File lib/kubes/compiler/decorator/hashable/field.rb, line 8
def initialize(item)
  @item = item
end

Public Instance Methods

hashable?() click to toggle source
# File lib/kubes/compiler/decorator/hashable/field.rb, line 12
def hashable?
  x = @item.keys & map.keys
  !x.empty?
end
key() click to toggle source

The key of the hashable value.

envFrom:
- secretRef:
    name: demo-secret    <--- wrapper is 'name'
# File lib/kubes/compiler/decorator/hashable/field.rb, line 27
def key
  map[wrapper]
end
kind() click to toggle source
# File lib/kubes/compiler/decorator/hashable/field.rb, line 17
def kind
  wrapper =~ /configMap/ ? "ConfigMap" : "Secret"
end
map() click to toggle source

wrapper element to key that stores the hashable value

# File lib/kubes/compiler/decorator/hashable/field.rb, line 42
def map
  {
    'configMapRef' => 'name',
    'configMapKeyRef' => 'name',
    'configMap' => 'name',
    'secretRef' => 'name',
    'secretKeyRef' => 'name',
    'secret' => 'secretName',
  }
end
wrapper() click to toggle source

The wrapper field is nested right above the item with the hashable value.

envFrom:
- secretRef:  <--- wrapper
    name: demo-secret
# File lib/kubes/compiler/decorator/hashable/field.rb, line 37
def wrapper
  @item.keys.first
end