Sha256: 653ea4fd485797d56c4194dd72a07cc9789cf183bb8049cb23303e0cda4e6fb5

Contents?: true

Size: 937 Bytes

Versions: 7

Compression:

Stored size: 937 Bytes

Contents

# frozen_string_literal: true

module Kubec
  class Kubernetes
    # :nodoc:
    class Template < Hash
      extend Forwardable

      def_delegators :metadata, :labels, :label

      def initialize
        self[:metadata] = Metadata.new
        self[:spec] = {}
      end

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

      def volume(name, &block)
        spec[:volumes] ||= []
        spec[:volumes].push Volume.new(name, &block)
      end

      def metadata(&block)
        return self[:metadata] unless block_given?
        self[:metadata].instance_eval(&block)
      end

      def spec
        self[:spec]
      end

      def container(name, &block)
        spec[:containers] ||= []
        spec[:containers].push Container.new(name, &block)
      end

      def restart(policy)
        spec[:restartPolicy] = policy.to_s.capitalize
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

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