Class: KuberKit::ServiceDeployer::Deployer
- Defined in:
- lib/kuber_kit/service_deployer/deployer.rb
Constant Summary collapse
- StrategyNotFoundError =
Class.new(KuberKit::NotFoundError)
Instance Method Summary collapse
- #deploy(shell, service, strategy_name) ⇒ Object
-
#initialize(**injected_deps) ⇒ Deployer
constructor
A new instance of Deployer.
- #register_strategy(strategy_name, strategy) ⇒ Object
- #reset! ⇒ Object
Constructor Details
#initialize(**injected_deps) ⇒ Deployer
Returns a new instance of Deployer.
10 11 12 13 |
# File 'lib/kuber_kit/service_deployer/deployer.rb', line 10 def initialize(**injected_deps) super(injected_deps) add_default_strategies end |
Instance Method Details
#deploy(shell, service, strategy_name) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/kuber_kit/service_deployer/deployer.rb', line 26 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
15 16 17 18 19 20 21 22 23 |
# File 'lib/kuber_kit/service_deployer/deployer.rb', line 15 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 |
#reset! ⇒ Object
34 35 36 |
# File 'lib/kuber_kit/service_deployer/deployer.rb', line 34 def reset! @@strategies = {} end |