Sha256: 23a1feabb5736c40ee53a17aded6df3c0abfddc42870dddef4d406eb5c36b4eb

Contents?: true

Size: 890 Bytes

Versions: 11

Compression:

Stored size: 890 Bytes

Contents

module Kontena
  module Machine
    module DigitalOcean
      class MasterDestroyer
        include Kontena::Cli::ShellSpinner

        attr_reader :client, :api_client

        # @param [String] token Digital Ocean token
        def initialize(token)
          @client = DropletKit::Client.new(access_token: token)
        end

        def run!(name)
          droplet = client.droplets.all.find{|d| d.name == name}
          if droplet
            spinner "Terminating DigitalOcean droplet #{name.colorize(:cyan)} " do
              result = client.droplets.delete(id: droplet.id)
              if result.is_a?(String)
                abort "Cannot delete droplet #{name.colorize(:cyan)} in DigitalOcean"
              end
            end
          else
            abort "Cannot find droplet #{name.colorize(:cyan)} in DigitalOcean"
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
krates-plugin-digitalocean-0.3.11 lib/kontena/machine/digital_ocean/master_destroyer.rb
krates-plugin-digitalocean-0.3.10 lib/kontena/machine/digital_ocean/master_destroyer.rb
krates-plugin-digitalocean-0.3.9 lib/kontena/machine/digital_ocean/master_destroyer.rb
krates-plugin-digitalocean-0.3.8 lib/kontena/machine/digital_ocean/master_destroyer.rb
staticpages-plugin-digitalocean-0.3.7 lib/kontena/machine/digital_ocean/master_destroyer.rb
staticpages-plugin-digitalocean-0.3.6 lib/kontena/machine/digital_ocean/master_destroyer.rb
staticpages-plugin-digitalocean-0.3.5 lib/kontena/machine/digital_ocean/master_destroyer.rb
kontena-plugin-digitalocean-0.3.3 lib/kontena/machine/digital_ocean/master_destroyer.rb
kontena-plugin-digitalocean-0.3.2 lib/kontena/machine/digital_ocean/master_destroyer.rb
kontena-plugin-digitalocean-0.3.1 lib/kontena/machine/digital_ocean/master_destroyer.rb
kontena-plugin-digitalocean-0.3.1.rc1 lib/kontena/machine/digital_ocean/master_destroyer.rb