Class: Algo::Cli::ServiceUpdator
- Inherits:
-
Object
- Object
- Algo::Cli::ServiceUpdator
- Defined in:
- lib/algo/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(srv_spec, options) ⇒ ServiceUpdator
constructor
A new instance of ServiceUpdator.
- #update ⇒ Object
Constructor Details
#initialize(srv_spec, options) ⇒ ServiceUpdator
Returns a new instance of ServiceUpdator.
38 39 40 41 |
# File 'lib/algo/cli.rb', line 38 def initialize srv_spec, @srv_spec = srv_spec @options = end |
Class Method Details
.update(srv_spec, dryrun = false) ⇒ Object
58 59 60 |
# File 'lib/algo/cli.rb', line 58 def self.update srv_spec, dryrun=false new(srv_spec, {dryrun: dryrun}).update end |
Instance Method Details
#update ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/algo/cli.rb', line 43 def update begin srv = Algo::Docker::Service.find(@srv_spec['Name']) if srv.raw_spec == @srv_spec puts "service: #{@srv_spec['Name']}, status: ok" return end srv.update @srv_spec unless dryrun? puts "service: #{@srv_spec['Name']}, status: changed" rescue Algo::Docker::Error::NotFoundError Algo::Docker::Service.create(@srv_spec) unless dryrun? puts "service: #{@srv_spec['Name']}, status: created" end end |