Class: KuberKit::ServiceDeployer::Deployer

Inherits:
Object
  • Object
show all
Defined in:
lib/kuber_kit/service_deployer/deployer.rb

Constant Summary collapse

StrategyNotFoundError =
Class.new(KuberKit::NotFoundError)

Instance Method Summary collapse

Instance Method Details

#deploy(shell, service, strategy_name) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/kuber_kit/service_deployer/deployer.rb', line 19

def deploy(shell, service, strategy_name)
  deployer = @@strategies[strategy_name]

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

  deployer.deploy(shell, service)
end

#register_strategy(strategy_name, strategy) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/kuber_kit/service_deployer/deployer.rb', line 8

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