Sha256: dd9c7736dd252d446efd2452e71290dffc2ac0a3648725ede6253b0a32f30c2a

Contents?: true

Size: 692 Bytes

Versions: 7

Compression:

Stored size: 692 Bytes

Contents

# frozen_string_literal: true

module Kubec
  class Kubernetes
    # :nodoc:
    class Metadata < Hash
      def initialize(name = nil)
        self[:name] = name unless name.nil?
        self[:namespace] = fetch(:stage, :staging)
      end

      # TODO: Refactor this feature
      def fetch(*args)
        Environment.instance.fetch(*args)
      end

      def label(key, value)
        self['labels'] ||= {}
        self['labels'][key] = value
      end

      def labels=(labels = nil)
        self['labels'] ||= {}
        return self['labels'] if labels.nil?
        # TODO: Check labels is valid
        self['labels'] = labels
      end

      alias labels labels=
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
kubec-0.6.1 lib/kubec/kubernetes/metadata.rb
kubec-0.6.0 lib/kubec/kubernetes/metadata.rb
kubec-0.5.0 lib/kubec/kubernetes/metadata.rb
kubec-0.4.1 lib/kubec/kubernetes/metadata.rb
kubec-0.4.0 lib/kubec/kubernetes/metadata.rb
kubec-0.3.6 lib/kubec/kubernetes/metadata.rb
kubec-0.3.5 lib/kubec/kubernetes/metadata.rb