Class: DPL::Provider::EngineYard

Inherits:
DPL::Provider show all
Defined in:
lib/dpl/provider/engine_yard.rb

Instance Attribute Summary

Attributes inherited from DPL::Provider

#context, #options

Instance Method Summary collapse

Methods inherited from DPL::Provider

#cleanup, context, #create_key, #error, experimental, #initialize, #log, #needs_key?, new, npm_g, #option, pip, requires, #setup_git_ssh, #sha, shell

Constructor Details

This class inherits a constructor from DPL::Provider

Instance Method Details

#apiObject



17
18
19
# File 'lib/dpl/provider/engine_yard.rb', line 17

def api
  @api ||= EY::CloudClient.new(token, EY::CLI::UI.new)
end

#check_appObject



25
26
27
28
29
# File 'lib/dpl/provider/engine_yard.rb', line 25

def check_app
  @app = EY::CloudClient::App.all(api).detect do |app|
    app.name == option(:app)
  end
end

#check_authObject



21
22
23
# File 'lib/dpl/provider/engine_yard.rb', line 21

def check_auth
  log "authenticated as %s" % api.current_user.email
end

#deployObject



62
63
64
65
66
# File 'lib/dpl/provider/engine_yard.rb', line 62

def deploy
  super
rescue EY::Error => error
  raise Error, error.message, error.backtrace
end

#deploy_argsObject



47
48
49
50
51
52
53
54
55
56
# File 'lib/dpl/provider/engine_yard.rb', line 47

def deploy_args
  deploy_args = { :ref => `git log --format="%H" -1`.chop }
  if options[:run]
    deploy_args[:migrate]         = true
    deploy_args[:migrate_command] = Array(options[:run]).map { |c| "(#{c})" }.join(" && ")
  elsif options.include? :migrate
    deploy_args[:migrate]         = options[:migrate]
  end
  deploy_args
end

#push_appObject



42
43
44
45
# File 'lib/dpl/provider/engine_yard.rb', line 42

def push_app
  fail
  EY::CloudClient::Deployment.deploy(api, option(:environment), deploy_args)
end

#remove_keyObject



38
39
40
# File 'lib/dpl/provider/engine_yard.rb', line 38

def remove_key
  @key.destroy if @key
end

#run(command) ⇒ Object



58
59
60
# File 'lib/dpl/provider/engine_yard.rb', line 58

def run(command)
  # commands run by deployment
end

#setup_key(file) ⇒ Object



31
32
33
34
35
36
# File 'lib/dpl/provider/engine_yard.rb', line 31

def setup_key(file)
  @key = EY::CloudClient::Keypair.create(api, {
    "name"       => option(:key_name),
    "public_key" => File.read(file)
  })
end

#tokenObject



9
10
11
12
13
14
15
# File 'lib/dpl/provider/engine_yard.rb', line 9

def token
  options[:api_key] ||= if options[:email] and options[:password]
    EY::CloudClient.authenticate(options[:email], options[:password])
  else
    option(:api_key) # will raise
  end
end