Sha256: 9eaf4c59466a05264c04aef4a82f77b496c02da96ff391ca0aa4065aea8e0c5b

Contents?: true

Size: 1.07 KB

Versions: 26

Compression:

Stored size: 1.07 KB

Contents

class Kubes::Compiler::Decorator::Hashable
  class Field
    # item is full wrapper structure
    #
    #     secretRef:  <--- wrapper
    #       name: demo-secret
    #
    def initialize(item)
      @item = item
    end

    def hashable?
      x = @item.keys & map.keys
      !x.empty?
    end

    def kind
      wrapper =~ /configMap/ ? "ConfigMap" : "Secret"
    end

    # The key of the hashable value.
    #
    #     envFrom:
    #     - secretRef:
    #         name: demo-secret    <--- wrapper is 'name'
    #
    def key
      map[wrapper]
    end

    # The wrapper field is nested right above the item with the hashable value.
    #
    #     envFrom:
    #     - secretRef:  <--- wrapper
    #         name: demo-secret
    #
    def wrapper
      @item.keys.first
    end

    # wrapper element to key that stores the hashable value
    def map
      {
        'configMapRef' => 'name',
        'configMapKeyRef' => 'name',
        'configMap' => 'name',
        'secretRef' => 'name',
        'secretKeyRef' => 'name',
        'secret' => 'secretName',
      }
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
kubes-0.7.6 lib/kubes/compiler/decorator/hashable/field.rb
kubes-0.7.5 lib/kubes/compiler/decorator/hashable/field.rb
kubes-0.7.4 lib/kubes/compiler/decorator/hashable/field.rb
kubes-0.7.3 lib/kubes/compiler/decorator/hashable/field.rb
kubes-0.7.2 lib/kubes/compiler/decorator/hashable/field.rb
kubes-0.7.1 lib/kubes/compiler/decorator/hashable/field.rb
kubes-0.7.0 lib/kubes/compiler/decorator/hashable/field.rb
kubes-0.6.8 lib/kubes/compiler/decorator/hashable/field.rb
kubes-0.6.7 lib/kubes/compiler/decorator/hashable/field.rb
kubes-0.6.6 lib/kubes/compiler/decorator/hashable/field.rb
kubes-0.6.5 lib/kubes/compiler/decorator/hashable/field.rb
kubes-0.6.4 lib/kubes/compiler/decorator/hashable/field.rb
kubes-0.6.3 lib/kubes/compiler/decorator/hashable/field.rb
kubes-0.6.2 lib/kubes/compiler/decorator/hashable/field.rb
kubes-0.6.1 lib/kubes/compiler/decorator/hashable/field.rb
kubes-0.6.0 lib/kubes/compiler/decorator/hashable/field.rb
kubes-0.5.1 lib/kubes/compiler/decorator/hashable/field.rb
kubes-0.5.0 lib/kubes/compiler/decorator/hashable/field.rb
kubes-0.4.7 lib/kubes/compiler/decorator/hashable/field.rb
kubes-0.4.6 lib/kubes/compiler/decorator/hashable/field.rb