dpl 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,9 @@ module DPL
5
5
  class Provider
6
6
  include FileUtils
7
7
 
8
- autoload :Heroku, 'dpl/provider/heroku'
8
+ autoload :Heroku, 'dpl/provider/heroku'
9
+ autoload :EngineYard, 'dpl/provider/engine_yard'
10
+ autoload :DotCloud, 'dpl/provider/dot_cloud'
9
11
 
10
12
  def self.new(context, options)
11
13
  return super if self < Provider
@@ -23,6 +25,10 @@ module DPL
23
25
  require name
24
26
  end
25
27
 
28
+ def self.pip(name, command = name)
29
+ system "pip install #{name}" if `which #{command}`.chop.empty?
30
+ end
31
+
26
32
  attr_reader :context, :options
27
33
 
28
34
  def initialize(context, options)
@@ -55,11 +61,13 @@ module DPL
55
61
  remove_key if needs_key?
56
62
  end
57
63
 
58
-
59
64
  def needs_key?
60
65
  true
61
66
  end
62
67
 
68
+ def check_app
69
+ end
70
+
63
71
  def create_key(file)
64
72
  system "ssh-keygen -t rsa -N \"\" -C #{option(:key_name)} -f #{file}"
65
73
  end
@@ -0,0 +1,24 @@
1
+ module DPL
2
+ class Provider
3
+ class DotCloud < Provider
4
+ pip 'dotcloud'
5
+
6
+ def check_auth
7
+ system "echo #{option(:api_key)} | dotcloud setup --api-key"
8
+ end
9
+
10
+ def needs_key?
11
+ false
12
+ end
13
+
14
+ def push_app
15
+ `dotcloud push #{option(:app)}`
16
+ end
17
+
18
+ def run(command)
19
+ service = option[:instance] || option[:service] || 'www'
20
+ `dotcloud -A #{option(:app)} #{service} #{command}`
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,67 @@
1
+ module DPL
2
+ class Provider
3
+ class EngineYard < Provider
4
+ requires 'engineyard'
5
+ requires 'engineyard-cloud-client'
6
+
7
+ def token
8
+ options[:api_key] ||= if options[:email] and options[:password]
9
+ EY::CloudClient.authenticate(options[:email], options[:password])
10
+ else
11
+ option(:api_key) # will raise
12
+ end
13
+ end
14
+
15
+ def api
16
+ @api ||= EY::CloudClient.new(token, EY::CLI::UI.new)
17
+ end
18
+
19
+ def check_auth
20
+ log "authenticated as %s" % api.current_user.email
21
+ end
22
+
23
+ def check_app
24
+ @app = EY::CloudClient::App.all(api).detect do |app|
25
+ app.name == option(:app)
26
+ end
27
+ end
28
+
29
+ def setup_key(file)
30
+ @key = EY::CloudClient::Keypair.create(api, {
31
+ "name" => option(:key_name),
32
+ "public_key" => File.read(file)
33
+ })
34
+ end
35
+
36
+ def remove_key
37
+ @key.destroy if @key
38
+ end
39
+
40
+ def push_app
41
+ fail
42
+ EY::CloudClient::Deployment.deploy(api, option(:environment), deploy_args)
43
+ end
44
+
45
+ def deploy_args
46
+ deploy_args = { :ref => `git log --format="%H" -1`.chop }
47
+ if options[:run]
48
+ deploy_args[:migrate] = true
49
+ deploy_args[:migrate_command] = Array(options[:run]).map { |c| "(#{c})" }.join(" && ")
50
+ elsif options.include? :migrate
51
+ deploy_args[:migrate] = options[:migrate]
52
+ end
53
+ deploy_args
54
+ end
55
+
56
+ def run(command)
57
+ # commands run by deployment
58
+ end
59
+
60
+ def deploy
61
+ super
62
+ rescue EY::Error => error
63
+ raise Error, error.message, error.backtrace
64
+ end
65
+ end
66
+ end
67
+ end
@@ -1,3 +1,3 @@
1
1
  module DPL
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dpl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-27 00:00:00.000000000 Z
12
+ date: 2013-06-03 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: deploy tool abstraction for clients
15
15
  email: konstantin.mailinglists@googlemail.com
@@ -26,6 +26,8 @@ files:
26
26
  - lib/dpl/cli.rb
27
27
  - lib/dpl/error.rb
28
28
  - lib/dpl/provider.rb
29
+ - lib/dpl/provider/dot_cloud.rb
30
+ - lib/dpl/provider/engine_yard.rb
29
31
  - lib/dpl/provider/heroku.rb
30
32
  - lib/dpl/version.rb
31
33
  homepage: https://github.com/rkh/dpl