Sha256: 233a1d0104ad6b7bdb9c5fd971355b7a7ed0fbfaba608472cb9cd2239bc3aec2

Contents?: true

Size: 1.16 KB

Versions: 25

Compression:

Stored size: 1.16 KB

Contents

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

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

  Contract KeywordArgs[
    name:               Symbol,
    dependencies:       ArrayOf[Symbol],
    template_name:      Maybe[Symbol],
    tags:               ArrayOf[Symbol],
    images:             ArrayOf[Symbol],
    attributes:         HashOf[Symbol => Any],
    deployer_strategy:  Maybe[Symbol]
  ] => Any
  def initialize(name:, dependencies:, template_name:, tags:, images:, attributes:, deployer_strategy:)
    @name = name
    @dependencies = dependencies
    @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

25 entries across 25 versions & 1 rubygems

Version Path
kuber_kit-1.1.5 lib/kuber_kit/core/service.rb
kuber_kit-1.3.1 lib/kuber_kit/core/service.rb
kuber_kit-1.3.0 lib/kuber_kit/core/service.rb
kuber_kit-1.1.4 lib/kuber_kit/core/service.rb
kuber_kit-1.2.7 lib/kuber_kit/core/service.rb
kuber_kit-1.2.6 lib/kuber_kit/core/service.rb
kuber_kit-1.2.5 lib/kuber_kit/core/service.rb
kuber_kit-1.2.4 lib/kuber_kit/core/service.rb
kuber_kit-1.2.2 lib/kuber_kit/core/service.rb
kuber_kit-1.1.2 lib/kuber_kit/core/service.rb
kuber_kit-1.2.1 lib/kuber_kit/core/service.rb
kuber_kit-1.2.0 lib/kuber_kit/core/service.rb
kuber_kit-1.1.1 lib/kuber_kit/core/service.rb
kuber_kit-1.0.1 lib/kuber_kit/core/service.rb
kuber_kit-1.0.0 lib/kuber_kit/core/service.rb
kuber_kit-0.9.9 lib/kuber_kit/core/service.rb
kuber_kit-0.9.8 lib/kuber_kit/core/service.rb
kuber_kit-0.9.7 lib/kuber_kit/core/service.rb
kuber_kit-0.9.6 lib/kuber_kit/core/service.rb
kuber_kit-0.9.5 lib/kuber_kit/core/service.rb