Sha256: f1feedfeafc4c5361a14a20362c2f062f35d112670754a70bae99a7636518808

Contents?: true

Size: 1.05 KB

Versions: 15

Compression:

Stored size: 1.05 KB

Contents

class KuberKit::Core::Service
  AttributeNotSet = Class.new(Indocker::Error)

  attr_reader :name, :template_name, :tags, :images, :attributes, :deployer_strategy

  Contract KeywordArgs[
    name:               Symbol,
    template_name:      Maybe[Symbol],
    tags:               ArrayOf[Symbol],
    images:             ArrayOf[Symbol],
    attributes:         HashOf[Symbol => Any],
    deployer_strategy:  Maybe[Symbol]
  ] => Any
  def initialize(name:, template_name:, tags:, images:, attributes:, deployer_strategy:)
    @name = name
    @template_name = template_name
    @tags = tags
    @images = images
    @attributes = attributes
    @deployer_strategy = deployer_strategy
  end

  def uri
    name.to_s.gsub("_", "-")
  end

  def attribute(attribute_name, default: nil)
    if !attributes.has_key?(attribute_name.to_sym) && default.nil?
      raise AttributeNotSet, "attribute #{attribute_name} was not set"
    end

    if !attributes.has_key?(attribute_name.to_sym) && !default.nil?
      return default
    end

    attributes[attribute_name.to_sym]
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
kuber_kit-0.5.1 lib/kuber_kit/core/service.rb
kuber_kit-0.5.0 lib/kuber_kit/core/service.rb
kuber_kit-0.4.9 lib/kuber_kit/core/service.rb
kuber_kit-0.4.8 lib/kuber_kit/core/service.rb
kuber_kit-0.4.7 lib/kuber_kit/core/service.rb
kuber_kit-0.4.6 lib/kuber_kit/core/service.rb
kuber_kit-0.4.5 lib/kuber_kit/core/service.rb
kuber_kit-0.4.4 lib/kuber_kit/core/service.rb
kuber_kit-0.4.3 lib/kuber_kit/core/service.rb
kuber_kit-0.4.2 lib/kuber_kit/core/service.rb
kuber_kit-0.4.1 lib/kuber_kit/core/service.rb
kuber_kit-0.4.0 lib/kuber_kit/core/service.rb
kuber_kit-0.3.11 lib/kuber_kit/core/service.rb
kuber_kit-0.3.10 lib/kuber_kit/core/service.rb
kuber_kit-0.3.9 lib/kuber_kit/core/service.rb