Sha256: f1368a3827983d0453b4e13dabaea3fbe0c24ddda581a14aaa26c7cf3656ab89

Contents?: true

Size: 1013 Bytes

Versions: 10

Compression:

Stored size: 1013 Bytes

Contents

class KuberKit::ServiceDeployer::Deployer
  StrategyNotFoundError = Class.new(KuberKit::NotFoundError)

  include KuberKit::Import[
    "core.service_store",
    "service_deployer.strategies.kubernetes"
  ]

  def register_strategy(strategy_name, strategy)
    @@strategies ||= {}

    if !strategy.is_a?(KuberKit::ServiceDeployer::Strategies::Abstract)
      raise ArgumentError.new("should be an instance of KuberKit::ServiceDeployer::Strategies::Abstract, got: #{strategy.inspect}")
    end

    @@strategies[strategy_name] = strategy
  end

  Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Service, Symbol => Any
  def deploy(shell, service, strategy_name)
    add_default_strategies

    deployer = @@strategies[strategy_name]

    raise StrategyNotFoundError, "Can't find strategy with name #{strategy_name}" if deployer.nil?

    deployer.deploy(shell, service)
  end

  def add_default_strategies
    register_strategy(:kubernetes, kubernetes)
  end

  def reset!
    @@strategies = {}
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
kuber_kit-0.2.5 lib/kuber_kit/service_deployer/deployer.rb
kuber_kit-0.2.4 lib/kuber_kit/service_deployer/deployer.rb
kuber_kit-0.2.3 lib/kuber_kit/service_deployer/deployer.rb
kuber_kit-0.2.2 lib/kuber_kit/service_deployer/deployer.rb
kuber_kit-0.2.1 lib/kuber_kit/service_deployer/deployer.rb
kuber_kit-0.2.0 lib/kuber_kit/service_deployer/deployer.rb
kuber_kit-0.1.9 lib/kuber_kit/service_deployer/deployer.rb
kuber_kit-0.1.8 lib/kuber_kit/service_deployer/deployer.rb
kuber_kit-0.1.7 lib/kuber_kit/service_deployer/deployer.rb
kuber_kit-0.1.6 lib/kuber_kit/service_deployer/deployer.rb