Sha256: 057e50cd17a186e427df1798114692d69c1846d22c62701b735dee2922fa9744

Contents?: true

Size: 760 Bytes

Versions: 2

Compression:

Stored size: 760 Bytes

Contents

require 'droplet_kit'
require 'yaml'

module DigitalOcean
  CONFIG_FILE = "#{Ops::PROVIDERS_DIR}/digitalocean.yml"

  def self.client
    begin
      config = YAML.load_file CONFIG_FILE
    rescue
      raise "Please, create '#{CONFIG_FILE}' file with token value"
    end
    DropletKit::Client.new(access_token: config["token"])
  end

  def self.build_droplet(host_name)
    begin
      params = YAML.load_file "#{Ops::HOSTS_DIR}/#{host_name}.yml"
      params["name"]= host_name
    rescue
      raise "Please, create '#{CONFIG_FILE}' file with token value"
    end
    DropletKit::Droplet.new params
  end
end

module DropletKit
  class Client
    def find_droplet_by_name(host_name)
      self.droplets.all.find{|d| d.name == host_name}
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
open-dock-0.0.12 lib/open-dock/digitalocean.rb
open-dock-0.0.11 lib/open-dock/digitalocean.rb