Class: KuberKit::ArtifactsSync::ArtifactUpdater
- Defined in:
- lib/kuber_kit/artifacts_sync/artifact_updater.rb
Constant Summary collapse
- StrategyNotFoundError =
Class.new(KuberKit::NotFoundError)
Instance Method Summary collapse
- #cleanup(shell, artifact) ⇒ Object
- #update(shell, artifact) ⇒ Object
- #use_strategy(strategy, artifact_class:) ⇒ Object
Instance Method Details
#cleanup(shell, artifact) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/kuber_kit/artifacts_sync/artifact_updater.rb', line 28 def cleanup(shell, artifact) strategy = @@strategies[artifact.class] ui.print_debug "ArtifactUpdater", "Cleaning artifact #{artifact.name.to_s.green}" raise StrategyNotFoundError, "Can't find strategy for artifact #{artifact}" if strategy.nil? strategy.cleanup(shell, artifact) end |
#update(shell, artifact) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/kuber_kit/artifacts_sync/artifact_updater.rb', line 18 def update(shell, artifact) strategy = @@strategies[artifact.class] ui.print_debug "ArtifactUpdater", "Updating artifact #{artifact.name.to_s.green}" raise StrategyNotFoundError, "Can't find strategy for artifact #{artifact}" if strategy.nil? strategy.update(shell, artifact) end |
#use_strategy(strategy, artifact_class:) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/kuber_kit/artifacts_sync/artifact_updater.rb', line 8 def use_strategy(strategy, artifact_class:) @@strategies ||= {} if !strategy.is_a?(KuberKit::ArtifactsSync::Strategies::Abstract) raise ArgumentError.new("should be an instance of KuberKit::ArtifactsSync::Strategies::Abstract, got: #{strategy.inspect}") end @@strategies[artifact_class] = strategy end |