engineyard-serverside-adapter 2.0.7 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.travis.yml +6 -3
- data/README.md +2 -2
- data/engineyard-serverside-adapter.gemspec +1 -0
- data/lib/engineyard-serverside-adapter.rb +2 -2
- data/lib/engineyard-serverside-adapter/action.rb +42 -16
- data/lib/engineyard-serverside-adapter/arguments.rb +14 -36
- data/lib/engineyard-serverside-adapter/deploy.rb +21 -8
- data/lib/engineyard-serverside-adapter/option.rb +15 -2
- data/lib/engineyard-serverside-adapter/version.rb +2 -2
- data/spec/adapter_spec.rb +7 -8
- data/spec/deploy_spec.rb +191 -17
- data/spec/disable_maintenance_spec.rb +7 -4
- data/spec/enable_maintenance_spec.rb +7 -4
- data/spec/integrate_spec.rb +7 -4
- data/spec/restart_spec.rb +7 -4
- data/spec/rollback_spec.rb +7 -4
- data/spec/spec_helper.rb +51 -22
- metadata +7 -19
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NzQ0Mzk3ZTIyMjc5NzcyY2YyNTU5MDg4NjI5YzhlNDQyYjRkNjNiOQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MGEzZDk5NzlkZDkzMWRjOTk2YWIwZTVmM2U4NDBmNjFkMWJjNTBhNQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZDM2ODRjOWMwMzdkMGEyMTEzNTI4OGY5YzExMzhhOWQyODIwYjE2ODZmYzNi
|
10
|
+
ZTg3NWZmMzIxOTM5YjA2NmE1NjUzMDc2N2YzYWMyYzMwOWNmYzY0MjdjZjVl
|
11
|
+
YzRkZGJkNWZjY2U1ZjE4MjNhZTMxMTI5MGJiMmM0MDg5OGVjMDc=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YWU5NzM5YzA1Y2ZiYzljYzcyYzk3NmQ3NzhkMmQ5YTNkNzE1Yzk4NTIzOTJk
|
14
|
+
ZDcwOGIzMmI0ODQ0ZDE4OWYwYjRmYzNkNjExNDM0ZThkNjA5ZmM5OWVmMWUx
|
15
|
+
YzAwOGQ1ODYzZTY2YzliMGQzOTFjZGNmY2M1ZjFmYTljMGE0ZGY=
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -27,8 +27,8 @@ This example is adapted from the engineyard gem:
|
|
27
27
|
def adapter(app, verbose)
|
28
28
|
EY::Serverside::Adapter.new("/usr/local/ey_resin/ruby/bin") do |args|
|
29
29
|
args.app = app.name
|
30
|
-
args.
|
31
|
-
args.instances = environment.instances.map { |i| {:hostname => i.public_hostname, :
|
30
|
+
args.git = app.repository_uri
|
31
|
+
args.instances = environment.instances.map { |i| {:hostname => i.public_hostname, :roles => [i.role], :name => i.name} }
|
32
32
|
args.verbose = verbose || ENV['DEBUG']
|
33
33
|
args.stack = environment.stack_name
|
34
34
|
args.framework_env = environment.framework_env
|
@@ -10,6 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.homepage = "http://github.com/engineyard/engineyard-serverside-adapter"
|
11
11
|
s.summary = "Adapter for speaking to engineyard-serverside"
|
12
12
|
s.description = "A separate adapter for speaking the CLI language of the engineyard-serverside gem."
|
13
|
+
s.license = 'MIT'
|
13
14
|
|
14
15
|
s.required_rubygems_version = ">= 1.3.6"
|
15
16
|
s.rubyforge_project = "engineyard-serverside-adapter"
|
@@ -14,11 +14,11 @@ module EY
|
|
14
14
|
autoload :Restart, 'engineyard-serverside-adapter/restart'
|
15
15
|
autoload :Rollback, 'engineyard-serverside-adapter/rollback'
|
16
16
|
|
17
|
-
def initialize(gem_bin_path = "")
|
17
|
+
def initialize(gem_bin_path = "", &block)
|
18
18
|
@gem_bin_path = Pathname.new(gem_bin_path)
|
19
19
|
@arguments = Arguments.new
|
20
20
|
|
21
|
-
|
21
|
+
block.call(@arguments) if block
|
22
22
|
end
|
23
23
|
|
24
24
|
def deploy(&b)
|
@@ -8,6 +8,15 @@ module EY
|
|
8
8
|
class Adapter
|
9
9
|
class Action
|
10
10
|
|
11
|
+
class << self
|
12
|
+
attr_accessor :options
|
13
|
+
|
14
|
+
def option(*args)
|
15
|
+
self.options ||= []
|
16
|
+
options << Option.new(*args)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
11
20
|
GEM_NAME = 'engineyard-serverside'
|
12
21
|
BIN_NAME = GEM_NAME
|
13
22
|
|
@@ -34,16 +43,7 @@ module EY
|
|
34
43
|
end
|
35
44
|
|
36
45
|
def verbose
|
37
|
-
@arguments
|
38
|
-
end
|
39
|
-
|
40
|
-
class << self
|
41
|
-
attr_accessor :options
|
42
|
-
|
43
|
-
def option(*args)
|
44
|
-
self.options ||= []
|
45
|
-
options << Option.new(*args)
|
46
|
-
end
|
46
|
+
@arguments.verbose
|
47
47
|
end
|
48
48
|
|
49
49
|
private
|
@@ -85,19 +85,45 @@ module EY
|
|
85
85
|
@gem_bin_path.join(@serverside_bin_name).to_s
|
86
86
|
end
|
87
87
|
|
88
|
+
# Initialize a command from arguments.
|
89
|
+
#
|
90
|
+
# Returns an instance of Command.
|
88
91
|
def action_command
|
89
92
|
Command.new(serverside_command_path, @serverside_version, *task) do |cmd|
|
90
|
-
|
91
|
-
|
93
|
+
given_applicable_options = given_options & applicable_options
|
94
|
+
given_applicable_options.each do |option|
|
95
|
+
cmd.send("#{option.type}_argument", option.to_switch, @arguments.send(option.name))
|
92
96
|
end
|
93
97
|
end
|
94
98
|
end
|
95
99
|
|
100
|
+
# only options with a value or with `:include` are used as command flags.
|
101
|
+
#
|
102
|
+
# This is not constrained to applicable options because we need to
|
103
|
+
# error if there are duplicate options given even if the version does
|
104
|
+
# not support those options.
|
105
|
+
#
|
106
|
+
# Primarily, this is for :git and :archive. If both are given for a
|
107
|
+
# version that doesn't support it, it's still an error. We don't want
|
108
|
+
# to exclude archive from a older version and then perform a git
|
109
|
+
# deploy, which really we should have errored for receiving both.
|
110
|
+
def given_options
|
111
|
+
@given_options ||= self.class.options.select do |option|
|
112
|
+
@arguments.send(option.name) || option.include?
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def required_options
|
117
|
+
applicable_options.select do |option|
|
118
|
+
option.required_on_version?(@serverside_version)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
96
122
|
def validate!
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
123
|
+
missing = required_options - given_options
|
124
|
+
unless missing.empty?
|
125
|
+
options_s = missing.map{|option| option.name}.join(', ')
|
126
|
+
raise ArgumentError, "Required fields [#{options_s}] not provided."
|
101
127
|
end
|
102
128
|
end
|
103
129
|
|
@@ -3,55 +3,33 @@ module EY
|
|
3
3
|
class Adapter
|
4
4
|
class Arguments
|
5
5
|
|
6
|
-
def self.
|
6
|
+
def self.nonempty_attr_accessor(*names)
|
7
7
|
names.each do |name|
|
8
8
|
define_method(name) do
|
9
|
-
|
9
|
+
instance_variable_get("@#{name}")
|
10
10
|
end
|
11
11
|
|
12
12
|
define_method(:"#{name}=") do |value|
|
13
13
|
if value.nil? || value.to_s.empty?
|
14
14
|
raise ArgumentError, "Value for '#{name}' must be non-empty."
|
15
15
|
end
|
16
|
-
|
16
|
+
instance_variable_set("@#{name}", value)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
def self.
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
define_method(:"#{name}=") do |value|
|
28
|
-
self[name] = value
|
29
|
-
end
|
21
|
+
def self.aliased_attribute(pairs)
|
22
|
+
pairs.each do |from, to|
|
23
|
+
alias_method from, to
|
24
|
+
alias_method :"#{from}=", "#{to}="
|
30
25
|
end
|
31
26
|
end
|
32
27
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
def dup
|
41
|
-
self.class.new(@data.dup)
|
42
|
-
end
|
43
|
-
|
44
|
-
def []=(key, val)
|
45
|
-
@data[key.to_sym] = val
|
46
|
-
end
|
47
|
-
|
48
|
-
def [](key)
|
49
|
-
@data[key.to_sym]
|
50
|
-
end
|
51
|
-
|
52
|
-
def key?(key)
|
53
|
-
@data.key?(key.to_sym)
|
54
|
-
end
|
28
|
+
nonempty_attr_accessor :app, :account_name, :archive, :environment_name
|
29
|
+
nonempty_attr_accessor :framework_env, :git, :ref, :serverside_version, :stack
|
30
|
+
attr_accessor :config, :migrate, :verbose
|
31
|
+
attr_reader :instances
|
32
|
+
alias repo git # for versions where --repo is required, it is accessed via this alias
|
55
33
|
|
56
34
|
def instances=(instances)
|
57
35
|
unless instances.respond_to?(:each)
|
@@ -68,12 +46,12 @@ module EY
|
|
68
46
|
end
|
69
47
|
end
|
70
48
|
|
71
|
-
|
49
|
+
@instances = instances
|
72
50
|
end
|
73
51
|
|
74
52
|
# Uses Gem::Version.create to validate the version string
|
75
53
|
def serverside_version=(value)
|
76
|
-
|
54
|
+
@serverside_version = Gem::Version.create(value.dup) # dup b/c Gem::Version sometimes modifies its argument :(
|
77
55
|
end
|
78
56
|
|
79
57
|
end
|
@@ -4,16 +4,18 @@ module EY
|
|
4
4
|
class Deploy < Action
|
5
5
|
|
6
6
|
option :app, :string, :required => true
|
7
|
-
option :account_name, :string, :required => true,
|
8
|
-
option :
|
9
|
-
option :stack, :string, :required => true
|
10
|
-
option :instances, :instances, :required => true
|
7
|
+
option :account_name, :string, :required => true, :version => '>= 2.0.0'
|
8
|
+
option :archive, :string, :version => '>= 2.3.0'
|
11
9
|
option :config, :json
|
12
|
-
option :
|
10
|
+
option :environment_name, :string, :required => true, :version => '>= 2.0.0'
|
11
|
+
option :git, :string, :version => '>= 2.3.0'
|
13
12
|
option :framework_env, :string, :required => true
|
14
|
-
option :
|
15
|
-
option :
|
16
|
-
option :
|
13
|
+
option :instances, :instances, :required => true
|
14
|
+
option :migrate, :string, :include => true
|
15
|
+
option :ref, :string, :required => '< 2.3.0'
|
16
|
+
option :repo, :string, :required => '< 2.3.0', :version => '< 2.3.0'
|
17
|
+
option :stack, :string, :required => true
|
18
|
+
option :verbose, :boolean
|
17
19
|
|
18
20
|
private
|
19
21
|
|
@@ -21,6 +23,17 @@ module EY
|
|
21
23
|
['deploy']
|
22
24
|
end
|
23
25
|
|
26
|
+
def validate!
|
27
|
+
super
|
28
|
+
given = given_options.map{|opt| opt.name}
|
29
|
+
if given.include?(:archive) && (given.include?(:git) || given.include?(:repo))
|
30
|
+
raise ArgumentError, "Both :git & :archive options given. No precedence order is defined. Specify only one."
|
31
|
+
elsif ([:git,:repo,:archive] & given).empty?
|
32
|
+
raise ArgumentError, "Either :git or :archive options must be given."
|
33
|
+
else
|
34
|
+
# archive xor git
|
35
|
+
end
|
36
|
+
end
|
24
37
|
end
|
25
38
|
end
|
26
39
|
end
|
@@ -18,8 +18,21 @@ module EY
|
|
18
18
|
!@version_requirement or @version_requirement.satisfied_by?(serverside_version)
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
|
21
|
+
# Check if the option should always be included.
|
22
|
+
#
|
23
|
+
# Returns a boolean.
|
24
|
+
def include?
|
25
|
+
@options[:include]
|
26
|
+
end
|
27
|
+
|
28
|
+
def required_on_version?(serverside_version)
|
29
|
+
case @options[:required]
|
30
|
+
when true
|
31
|
+
true
|
32
|
+
when String
|
33
|
+
requirement = Gem::Requirement.create(@options[:required])
|
34
|
+
requirement.satisfied_by?(serverside_version)
|
35
|
+
end
|
23
36
|
end
|
24
37
|
|
25
38
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module EY
|
2
2
|
module Serverside
|
3
3
|
class Adapter
|
4
|
-
VERSION = "2.0
|
4
|
+
VERSION = "2.1.0"
|
5
5
|
# For backwards compatibility, the serverside version default will be maintained until 2.1
|
6
6
|
# It is recommended that you supply a serverside_version to engineyard-serverside-adapter
|
7
7
|
# rather than relying on the default version here. This default will go away soon.
|
8
|
-
ENGINEYARD_SERVERSIDE_VERSION = ENV['ENGINEYARD_SERVERSIDE_VERSION'] || "2.0
|
8
|
+
ENGINEYARD_SERVERSIDE_VERSION = ENV['ENGINEYARD_SERVERSIDE_VERSION'] || "2.3.0"
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
data/spec/adapter_spec.rb
CHANGED
@@ -9,14 +9,14 @@ shared_examples_for "a serverside action" do
|
|
9
9
|
args.instances = [{:hostname => 'localhost', :roles => %w[a b c]}]
|
10
10
|
args.framework_env = 'production'
|
11
11
|
args.ref = 'master'
|
12
|
-
args.
|
12
|
+
args.git = 'git@github.com:engineyard/engineyard-serverside.git'
|
13
13
|
args.stack = 'nginx_unicorn'
|
14
14
|
args
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
it "gives you an Arguments already set up from when you instantiated the adapter" do
|
19
|
-
|
19
|
+
@adapter.send(@method) do |args|
|
20
20
|
args.app.should == 'app-from-adapter-new'
|
21
21
|
end
|
22
22
|
end
|
@@ -56,12 +56,12 @@ shared_examples_for "a serverside action" do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
it "does not let arguments changes propagate back up to the adapter" do
|
59
|
-
|
59
|
+
@adapter.send(@method) do |args|
|
60
60
|
args.app = 'sporkr'
|
61
61
|
end
|
62
62
|
|
63
63
|
@adapter.send(@method) do |args|
|
64
|
-
args
|
64
|
+
args.app.should == 'app-from-adapter-new'
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
@@ -86,7 +86,7 @@ shared_examples_for "a serverside action" do
|
|
86
86
|
args.instances = [{:hostname => 'localhost', :roles => %w[a b c]}]
|
87
87
|
args.framework_env = 'production'
|
88
88
|
args.ref = 'master'
|
89
|
-
args.
|
89
|
+
args.git = 'git@github.com:engineyard/engineyard-serverside.git'
|
90
90
|
args.stack = 'nginx_unicorn'
|
91
91
|
args
|
92
92
|
end
|
@@ -119,7 +119,7 @@ end
|
|
119
119
|
describe EY::Serverside::Adapter do
|
120
120
|
context ".new" do
|
121
121
|
it "lets you access the arguments" do
|
122
|
-
|
122
|
+
described_class.new do |args|
|
123
123
|
args.app = 'myapp'
|
124
124
|
end
|
125
125
|
end
|
@@ -152,9 +152,8 @@ describe EY::Serverside::Adapter do
|
|
152
152
|
args.instances = [{:hostname => 'localhost', :roles => %w[a b c]}]
|
153
153
|
args.framework_env = 'production'
|
154
154
|
args.ref = 'master'
|
155
|
-
args.
|
155
|
+
args.git = 'git@github.com:engineyard/engineyard-serverside.git'
|
156
156
|
args.stack = 'nginx_unicorn'
|
157
|
-
args
|
158
157
|
end
|
159
158
|
end
|
160
159
|
|
data/spec/deploy_spec.rb
CHANGED
@@ -4,33 +4,174 @@ describe EY::Serverside::Adapter::Deploy do
|
|
4
4
|
it_should_behave_like "it installs engineyard-serverside"
|
5
5
|
|
6
6
|
it_should_behave_like "it accepts app"
|
7
|
-
it_should_behave_like "it accepts environment_name"
|
8
7
|
it_should_behave_like "it accepts account_name"
|
8
|
+
it_should_behave_like "it accepts archive"
|
9
|
+
it_should_behave_like "it accepts environment_name"
|
9
10
|
it_should_behave_like "it accepts framework_env"
|
11
|
+
it_should_behave_like "it accepts git"
|
10
12
|
it_should_behave_like "it accepts instances"
|
11
13
|
it_should_behave_like "it accepts migrate"
|
12
14
|
it_should_behave_like "it accepts ref"
|
13
|
-
it_should_behave_like "it accepts repo"
|
14
15
|
it_should_behave_like "it accepts stack"
|
15
16
|
it_should_behave_like "it accepts verbose"
|
16
17
|
it_should_behave_like "it accepts serverside_version"
|
17
18
|
|
18
19
|
it_should_require :app
|
19
|
-
it_should_require :environment_name
|
20
|
-
it_should_require :account_name
|
20
|
+
it_should_require :environment_name, %w[2.0.0 2.1.0 2.2.0 2.3.0]
|
21
|
+
it_should_require :account_name, %w[2.0.0 2.1.0 2.2.0 2.3.0]
|
21
22
|
it_should_require :instances
|
22
23
|
it_should_require :framework_env
|
23
|
-
it_should_require :ref
|
24
|
-
it_should_require :repo
|
25
24
|
it_should_require :stack
|
25
|
+
it_should_require :ref, %w[1.6.4 2.0.0 2.1.0 2.2.0]
|
26
|
+
it_should_require :git, %w[1.6.4 2.0.0 2.1.0 2.2.0]
|
27
|
+
|
28
|
+
it_should_ignore_requirement :environment_name, '1.6.4'
|
29
|
+
it_should_ignore_requirement :account_name, '1.6.4'
|
30
|
+
it_should_ignore_requirement :ref, '2.3.0'
|
26
31
|
|
27
|
-
|
28
|
-
|
32
|
+
it_should_exclude_from_command :environment_name, %w[1.6.4]
|
33
|
+
it_should_exclude_from_command :account_name, %w[1.6.4]
|
34
|
+
it_should_exclude_from_command :repo, %w[2.3.0]
|
35
|
+
it_should_exclude_from_command :git, %w[1.6.4 2.0.0 2.1.0 2.2.0]
|
36
|
+
it_should_exclude_from_command :archive, %w[1.6.4 2.0.0 2.1.0 2.2.0]
|
29
37
|
|
30
38
|
it_should_behave_like "it treats config as optional"
|
31
39
|
it_should_behave_like "it treats migrate as optional"
|
32
40
|
|
33
41
|
context "with valid arguments" do
|
42
|
+
def deploy_command(&block)
|
43
|
+
adapter = described_class.new do |arguments|
|
44
|
+
arguments.app = "rackapp"
|
45
|
+
arguments.environment_name = 'rackapp_production'
|
46
|
+
arguments.account_name = 'ey'
|
47
|
+
arguments.framework_env = 'production'
|
48
|
+
arguments.config = {'a' => 1}
|
49
|
+
arguments.instances = [{:hostname => 'localhost', :roles => %w[han solo], :name => 'chewie'}]
|
50
|
+
arguments.migrate = 'rake db:migrate'
|
51
|
+
arguments.ref = 'master'
|
52
|
+
arguments.git = 'git@github.com:engineyard/engineyard-serverside.git'
|
53
|
+
arguments.stack = "nginx_unicorn"
|
54
|
+
arguments.serverside_version = '2.3.0'
|
55
|
+
block.call arguments if block
|
56
|
+
end
|
57
|
+
last_command(adapter)
|
58
|
+
end
|
59
|
+
|
60
|
+
def archive_deploy_command(&block)
|
61
|
+
adapter = described_class.new do |arguments|
|
62
|
+
arguments.archive = 'https://github.com/engineyard/engineyard-serverside/archive/master.zip'
|
63
|
+
arguments.app = "rackapp"
|
64
|
+
arguments.environment_name = 'rackapp_production'
|
65
|
+
arguments.account_name = 'ey'
|
66
|
+
arguments.framework_env = 'production'
|
67
|
+
arguments.config = {'a' => 1}
|
68
|
+
arguments.instances = [{:hostname => 'localhost', :roles => %w[han solo], :name => 'chewie'}]
|
69
|
+
arguments.migrate = 'rake db:migrate'
|
70
|
+
arguments.stack = "nginx_unicorn"
|
71
|
+
arguments.serverside_version = '2.3.0'
|
72
|
+
block.call arguments if block_given?
|
73
|
+
end
|
74
|
+
last_command(adapter)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "puts the config in the command line as json" do
|
78
|
+
deploy_command.should =~ /--config '#{Regexp.quote '{"a":1}'}'/
|
79
|
+
end
|
80
|
+
|
81
|
+
it "invokes exactly the right command" do
|
82
|
+
deploy_command.should == [
|
83
|
+
"engineyard-serverside",
|
84
|
+
"_#{EY::Serverside::Adapter::ENGINEYARD_SERVERSIDE_VERSION}_",
|
85
|
+
"deploy",
|
86
|
+
"--account-name ey",
|
87
|
+
"--app rackapp",
|
88
|
+
"--config '{\"a\":1}'",
|
89
|
+
"--environment-name rackapp_production",
|
90
|
+
"--framework-env production",
|
91
|
+
"--git git@github.com:engineyard/engineyard-serverside.git",
|
92
|
+
"--instance-names localhost:chewie",
|
93
|
+
"--instance-roles localhost:han,solo",
|
94
|
+
"--instances localhost",
|
95
|
+
"--migrate 'rake db:migrate'",
|
96
|
+
"--ref master",
|
97
|
+
"--stack nginx_unicorn",
|
98
|
+
].join(' ')
|
99
|
+
end
|
100
|
+
|
101
|
+
%w[1.6.4 2.0.0 2.1.0 2.2.0].each do |version|
|
102
|
+
context "on version ~> #{version}" do
|
103
|
+
it "sets --repo instead of --git flag" do
|
104
|
+
git_repo = 'git@github.com:engineyard/engineyard-serverside.git'
|
105
|
+
command = deploy_command do |args|
|
106
|
+
args.serverside_version = version
|
107
|
+
args.git = git_repo
|
108
|
+
end
|
109
|
+
|
110
|
+
expect(command).to match(/--repo #{Regexp.escape(git_repo)}/)
|
111
|
+
expect(command).not_to match(/--git/)
|
112
|
+
end
|
113
|
+
|
114
|
+
it "raises if both --archive and --git are set (you must specify git)" do
|
115
|
+
expect do
|
116
|
+
command = deploy_command do |args|
|
117
|
+
args.archive = "url"
|
118
|
+
args.serverside_version = version
|
119
|
+
end
|
120
|
+
end.to raise_error(ArgumentError)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
context "on version ~> 2.3.0" do
|
126
|
+
let(:version) { "2.3.0" }
|
127
|
+
|
128
|
+
it "sets --git and not --repo flag" do
|
129
|
+
git_repo = 'git@github.com:engineyard/engineyard-serverside.git'
|
130
|
+
command = deploy_command do |args|
|
131
|
+
args.serverside_version = version
|
132
|
+
args.git = git_repo
|
133
|
+
end
|
134
|
+
expect(command).to match(/--git #{Regexp.escape(git_repo)}/)
|
135
|
+
expect(command).not_to match(/--repo/)
|
136
|
+
end
|
137
|
+
|
138
|
+
it "raises if both --archive and --git are set" do
|
139
|
+
expect do
|
140
|
+
deploy_command do |args|
|
141
|
+
args.serverside_version = version
|
142
|
+
args.archive = "url"
|
143
|
+
end
|
144
|
+
end.to raise_error(ArgumentError)
|
145
|
+
end
|
146
|
+
|
147
|
+
it "raises if neither --archive nor --git are set" do
|
148
|
+
expect do
|
149
|
+
described_class.new do |arguments|
|
150
|
+
arguments.app = "rackapp"
|
151
|
+
arguments.environment_name = 'rackapp_production'
|
152
|
+
arguments.account_name = 'ey'
|
153
|
+
arguments.framework_env = 'production'
|
154
|
+
arguments.config = {'a' => 1}
|
155
|
+
arguments.instances = [{:hostname => 'localhost', :roles => %w[han solo], :name => 'chewie'}]
|
156
|
+
arguments.migrate = 'rake db:migrate'
|
157
|
+
arguments.ref = 'master'
|
158
|
+
arguments.stack = "nginx_unicorn"
|
159
|
+
arguments.serverside_version = version
|
160
|
+
end
|
161
|
+
end.to raise_error(ArgumentError)
|
162
|
+
end
|
163
|
+
|
164
|
+
it "sets --archive" do
|
165
|
+
command = archive_deploy_command do |args|
|
166
|
+
args.serverside_version = version
|
167
|
+
args.archive = "url"
|
168
|
+
end
|
169
|
+
expect(command).to match(/--archive url/)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
context "with git deploy" do
|
34
175
|
let(:command) do
|
35
176
|
adapter = described_class.new do |arguments|
|
36
177
|
arguments.app = "rackapp"
|
@@ -41,16 +182,12 @@ describe EY::Serverside::Adapter::Deploy do
|
|
41
182
|
arguments.instances = [{:hostname => 'localhost', :roles => %w[han solo], :name => 'chewie'}]
|
42
183
|
arguments.migrate = 'rake db:migrate'
|
43
184
|
arguments.ref = 'master'
|
44
|
-
arguments.
|
185
|
+
arguments.git = 'git@github.com:engineyard/engineyard-serverside.git'
|
45
186
|
arguments.stack = "nginx_unicorn"
|
46
187
|
end
|
47
188
|
last_command(adapter)
|
48
189
|
end
|
49
190
|
|
50
|
-
it "puts the config in the command line as json" do
|
51
|
-
command.should =~ /--config '#{Regexp.quote '{"a":1}'}'/
|
52
|
-
end
|
53
|
-
|
54
191
|
it "invokes exactly the right command" do
|
55
192
|
command.should == [
|
56
193
|
"engineyard-serverside",
|
@@ -61,17 +198,54 @@ describe EY::Serverside::Adapter::Deploy do
|
|
61
198
|
"--config '{\"a\":1}'",
|
62
199
|
"--environment-name rackapp_production",
|
63
200
|
"--framework-env production",
|
201
|
+
"--git git@github.com:engineyard/engineyard-serverside.git",
|
64
202
|
"--instance-names localhost:chewie",
|
65
203
|
"--instance-roles localhost:han,solo",
|
66
204
|
"--instances localhost",
|
67
205
|
"--migrate 'rake db:migrate'",
|
68
206
|
"--ref master",
|
69
|
-
"--
|
70
|
-
"--stack nginx_unicorn",
|
207
|
+
"--stack nginx_unicorn"
|
71
208
|
].join(' ')
|
72
209
|
end
|
73
210
|
end
|
74
211
|
|
212
|
+
context "with package deploy" do
|
213
|
+
let(:command) do
|
214
|
+
adapter = described_class.new do |args|
|
215
|
+
args.app = "rackapp"
|
216
|
+
args.environment_name = 'rackapp_production'
|
217
|
+
args.account_name = 'ey'
|
218
|
+
args.framework_env = 'production'
|
219
|
+
args.instances = [{:hostname => 'localhost', :roles => %w[han solo], :name => 'chewie'}]
|
220
|
+
args.migrate = false
|
221
|
+
args.stack = "nginx_unicorn"
|
222
|
+
args.archive = 'https://github.com/engineyard/engineyard-serverside/archive/master.zip'
|
223
|
+
args.serverside_version = EY::Serverside::Adapter::ENGINEYARD_SERVERSIDE_VERSION
|
224
|
+
end
|
225
|
+
|
226
|
+
last_command(adapter)
|
227
|
+
end
|
228
|
+
|
229
|
+
it "invokes exactly the right command" do
|
230
|
+
command.should == [
|
231
|
+
"engineyard-serverside",
|
232
|
+
"_#{EY::Serverside::Adapter::ENGINEYARD_SERVERSIDE_VERSION}_",
|
233
|
+
"deploy",
|
234
|
+
"--account-name ey",
|
235
|
+
"--app rackapp",
|
236
|
+
"--archive https://github.com/engineyard/engineyard-serverside/archive/master.zip",
|
237
|
+
"--environment-name rackapp_production",
|
238
|
+
"--framework-env production",
|
239
|
+
"--instance-names localhost:chewie",
|
240
|
+
"--instance-roles localhost:han,solo",
|
241
|
+
"--instances localhost",
|
242
|
+
"--no-migrate",
|
243
|
+
"--stack nginx_unicorn"
|
244
|
+
].join(' ')
|
245
|
+
end
|
246
|
+
|
247
|
+
end
|
248
|
+
|
75
249
|
context "with no migrate argument" do
|
76
250
|
let(:command) do
|
77
251
|
adapter = described_class.new do |arguments|
|
@@ -83,7 +257,7 @@ describe EY::Serverside::Adapter::Deploy do
|
|
83
257
|
arguments.instances = [{:hostname => 'localhost', :roles => %w[han solo], :name => 'chewie'}]
|
84
258
|
arguments.migrate = false
|
85
259
|
arguments.ref = 'master'
|
86
|
-
arguments.
|
260
|
+
arguments.git = 'git@github.com:engineyard/engineyard-serverside.git'
|
87
261
|
arguments.stack = "nginx_unicorn"
|
88
262
|
end
|
89
263
|
last_command(adapter)
|
@@ -103,12 +277,12 @@ describe EY::Serverside::Adapter::Deploy do
|
|
103
277
|
"--config '{\"a\":1}'",
|
104
278
|
"--environment-name rackapp_production",
|
105
279
|
"--framework-env production",
|
280
|
+
"--git git@github.com:engineyard/engineyard-serverside.git",
|
106
281
|
"--instance-names localhost:chewie",
|
107
282
|
"--instance-roles localhost:han,solo",
|
108
283
|
"--instances localhost",
|
109
284
|
"--no-migrate",
|
110
285
|
"--ref master",
|
111
|
-
"--repo git@github.com:engineyard/engineyard-serverside.git",
|
112
286
|
"--stack nginx_unicorn",
|
113
287
|
].join(' ')
|
114
288
|
end
|
@@ -11,12 +11,15 @@ describe EY::Serverside::Adapter::DisableMaintenance do
|
|
11
11
|
it_should_behave_like "it accepts serverside_version"
|
12
12
|
|
13
13
|
it_should_require :app
|
14
|
-
it_should_require :environment_name
|
15
|
-
it_should_require :account_name
|
14
|
+
it_should_require :environment_name, %w[2.0.0 2.1.0 2.2.0 2.3.0]
|
15
|
+
it_should_require :account_name, %w[2.0.0 2.1.0 2.2.0 2.3.0]
|
16
16
|
it_should_require :instances
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
it_should_ignore_requirement :environment_name, '1.6.4'
|
19
|
+
it_should_ignore_requirement :account_name, '1.6.4'
|
20
|
+
|
21
|
+
it_should_exclude_from_command :environment_name, %w[1.6.4]
|
22
|
+
it_should_exclude_from_command :account_name, %w[1.6.4]
|
20
23
|
|
21
24
|
context "with valid arguments" do
|
22
25
|
let(:command) do
|
@@ -11,12 +11,15 @@ describe EY::Serverside::Adapter::EnableMaintenance do
|
|
11
11
|
it_should_behave_like "it accepts serverside_version"
|
12
12
|
|
13
13
|
it_should_require :app
|
14
|
-
it_should_require :environment_name
|
15
|
-
it_should_require :account_name
|
14
|
+
it_should_require :environment_name, %w[2.0.0 2.1.0 2.2.0 2.3.0]
|
15
|
+
it_should_require :account_name, %w[2.0.0 2.1.0 2.2.0 2.3.0]
|
16
16
|
it_should_require :instances
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
it_should_ignore_requirement :environment_name, '1.6.4'
|
19
|
+
it_should_ignore_requirement :account_name, '1.6.4'
|
20
|
+
|
21
|
+
it_should_exclude_from_command :environment_name, %w[1.6.4]
|
22
|
+
it_should_exclude_from_command :account_name, %w[1.6.4]
|
20
23
|
|
21
24
|
context "with valid arguments" do
|
22
25
|
|
data/spec/integrate_spec.rb
CHANGED
@@ -13,14 +13,17 @@ describe EY::Serverside::Adapter::Integrate do
|
|
13
13
|
it_should_behave_like "it accepts serverside_version"
|
14
14
|
|
15
15
|
it_should_require :app
|
16
|
-
it_should_require :environment_name
|
17
|
-
it_should_require :account_name
|
16
|
+
it_should_require :environment_name, %w[2.0.0 2.1.0 2.2.0 2.3.0]
|
17
|
+
it_should_require :account_name, %w[2.0.0 2.1.0 2.2.0 2.3.0]
|
18
18
|
it_should_require :stack
|
19
19
|
it_should_require :instances
|
20
20
|
it_should_require :framework_env
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
it_should_ignore_requirement :environment_name, '1.6.4'
|
23
|
+
it_should_ignore_requirement :account_name, '1.6.4'
|
24
|
+
|
25
|
+
it_should_exclude_from_command :environment_name, %w[1.6.4]
|
26
|
+
it_should_exclude_from_command :account_name, %w[1.6.4]
|
24
27
|
|
25
28
|
context "with valid arguments" do
|
26
29
|
let(:command) do
|
data/spec/restart_spec.rb
CHANGED
@@ -12,13 +12,16 @@ describe EY::Serverside::Adapter::Restart do
|
|
12
12
|
it_should_behave_like "it accepts serverside_version"
|
13
13
|
|
14
14
|
it_should_require :app
|
15
|
-
it_should_require :environment_name
|
16
|
-
it_should_require :account_name
|
15
|
+
it_should_require :environment_name, %w[2.0.0 2.1.0 2.2.0 2.3.0]
|
16
|
+
it_should_require :account_name, %w[2.0.0 2.1.0 2.2.0 2.3.0]
|
17
17
|
it_should_require :instances
|
18
18
|
it_should_require :stack
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
it_should_ignore_requirement :environment_name, '1.6.4'
|
21
|
+
it_should_ignore_requirement :account_name, '1.6.4'
|
22
|
+
|
23
|
+
it_should_exclude_from_command :environment_name, %w[1.6.4]
|
24
|
+
it_should_exclude_from_command :account_name, %w[1.6.4]
|
22
25
|
|
23
26
|
context "with valid arguments" do
|
24
27
|
let(:command) do
|
data/spec/rollback_spec.rb
CHANGED
@@ -13,14 +13,17 @@ describe EY::Serverside::Adapter::Rollback do
|
|
13
13
|
it_should_behave_like "it accepts serverside_version"
|
14
14
|
|
15
15
|
it_should_require :app
|
16
|
-
it_should_require :environment_name
|
17
|
-
it_should_require :account_name
|
16
|
+
it_should_require :environment_name, %w[2.0.0 2.1.0 2.2.0 2.3.0]
|
17
|
+
it_should_require :account_name, %w[2.0.0 2.1.0 2.2.0 2.3.0]
|
18
18
|
it_should_require :framework_env
|
19
19
|
it_should_require :instances
|
20
20
|
it_should_require :stack
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
it_should_ignore_requirement :environment_name, '1.6.4'
|
23
|
+
it_should_ignore_requirement :account_name, '1.6.4'
|
24
|
+
|
25
|
+
it_should_exclude_from_command :environment_name, %w[1.6.4]
|
26
|
+
it_should_exclude_from_command :account_name, %w[1.6.4]
|
24
27
|
|
25
28
|
context "with valid arguments" do
|
26
29
|
let(:command) do
|
data/spec/spec_helper.rb
CHANGED
@@ -8,12 +8,13 @@ module ArgumentsHelpers
|
|
8
8
|
def valid_options
|
9
9
|
{
|
10
10
|
:app => 'rackapp',
|
11
|
-
:environment_name => 'rackapp_production',
|
12
11
|
:account_name => 'ey',
|
12
|
+
#:archive => 'https://github.com/engineyard/engineyard-serverside/archive/master.zip',
|
13
|
+
:environment_name => 'rackapp_production',
|
13
14
|
:framework_env => 'production',
|
15
|
+
:git => 'git@github.com:engineyard/engineyard-serverside.git',
|
14
16
|
:instances => [{:hostname => 'localhost', :roles => %w[han solo], :name => 'chewie'}],
|
15
17
|
:ref => 'master',
|
16
|
-
:repo => 'git@github.com:engineyard/engineyard-serverside.git',
|
17
18
|
:stack => 'nginx_unicorn',
|
18
19
|
}
|
19
20
|
end
|
@@ -46,32 +47,51 @@ module ArgumentsHelpers
|
|
46
47
|
end
|
47
48
|
|
48
49
|
module RequiredFieldHelpers
|
49
|
-
def it_should_require(field)
|
50
|
+
def it_should_require(field, versions=[:all])
|
50
51
|
context "field #{field}" do
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
versions.each do |version|
|
53
|
+
on_versions = version == :all ? "on all versions" : "on version ~> #{version}"
|
54
|
+
context on_versions do
|
55
|
+
it "is fine when #{field} is there" do
|
56
|
+
arguments = valid_arguments
|
57
|
+
arguments.serverside_version = version unless version == :all
|
58
|
+
expect { described_class.new(:arguments => arguments) }.to_not raise_error
|
59
|
+
end
|
60
|
+
|
61
|
+
it "raises an error if #{field} is missing" do
|
62
|
+
arguments = arguments_without(field)
|
63
|
+
arguments.serverside_version = version unless version == :all
|
64
|
+
expect { described_class.new(:arguments => arguments) }.to raise_error(ArgumentError)
|
65
|
+
end
|
66
|
+
end
|
57
67
|
end
|
58
68
|
end
|
59
69
|
end
|
60
70
|
|
61
|
-
def
|
62
|
-
context "field #{field}
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
71
|
+
def it_should_ignore_requirement(field, version)
|
72
|
+
context "field #{field}" do
|
73
|
+
context "on version ~> #{version}" do
|
74
|
+
it "is not required" do
|
75
|
+
arguments = arguments_without(field)
|
76
|
+
arguments.serverside_version = version
|
77
|
+
lambda { described_class.new(:arguments => arguments) }.should_not raise_error
|
78
|
+
end
|
67
79
|
end
|
80
|
+
end
|
81
|
+
end
|
68
82
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
83
|
+
def it_should_exclude_from_command(field, versions)
|
84
|
+
context "field #{field}" do
|
85
|
+
versions.each do |version|
|
86
|
+
context "on version ~> #{version}" do
|
87
|
+
it "is not included #{field} in the command" do
|
88
|
+
arguments = valid_arguments
|
89
|
+
arguments.serverside_version = version
|
90
|
+
action = described_class.new(:arguments => arguments)
|
91
|
+
commands = all_commands(action)
|
92
|
+
commands.last.should_not include(EY::Serverside::Adapter::Option.new(field, :string).to_switch)
|
93
|
+
end
|
94
|
+
end
|
75
95
|
end
|
76
96
|
end
|
77
97
|
end
|
@@ -127,7 +147,7 @@ RSpec.configure do |config|
|
|
127
147
|
:stack => '--stack',
|
128
148
|
:framework_env => '--framework-env',
|
129
149
|
:ref => '--ref',
|
130
|
-
:
|
150
|
+
:git => '--git',
|
131
151
|
:migrate => '--migrate',
|
132
152
|
}.each do |arg, switch|
|
133
153
|
shared_examples_for "it accepts #{arg}" do
|
@@ -158,6 +178,15 @@ RSpec.configure do |config|
|
|
158
178
|
end
|
159
179
|
end
|
160
180
|
|
181
|
+
shared_examples_for "it accepts archive" do
|
182
|
+
it "puts the --archive arg in the command line" do
|
183
|
+
arguments = arguments_without(:git)
|
184
|
+
arguments.archive = 'word'
|
185
|
+
adapter = described_class.new(:arguments => arguments)
|
186
|
+
last_command(adapter).should =~ /--archive word/
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
161
190
|
shared_examples_for "it accepts serverside_version" do
|
162
191
|
it "puts the _VERSION_ command part in the command line" do
|
163
192
|
adapter = described_class.new(:arguments => arguments_with(:serverside_version => '1.2.3'))
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: engineyard-serverside-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
5
|
-
prerelease:
|
4
|
+
version: 2.1.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Martin Emde
|
@@ -10,12 +9,11 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date: 2013-
|
12
|
+
date: 2013-08-03 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: escape
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
17
|
requirements:
|
20
18
|
- - ~>
|
21
19
|
- !ruby/object:Gem::Version
|
@@ -23,7 +21,6 @@ dependencies:
|
|
23
21
|
type: :runtime
|
24
22
|
prerelease: false
|
25
23
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
24
|
requirements:
|
28
25
|
- - ~>
|
29
26
|
- !ruby/object:Gem::Version
|
@@ -31,7 +28,6 @@ dependencies:
|
|
31
28
|
- !ruby/object:Gem::Dependency
|
32
29
|
name: multi_json
|
33
30
|
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
31
|
requirements:
|
36
32
|
- - ~>
|
37
33
|
- !ruby/object:Gem::Version
|
@@ -39,7 +35,6 @@ dependencies:
|
|
39
35
|
type: :runtime
|
40
36
|
prerelease: false
|
41
37
|
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
38
|
requirements:
|
44
39
|
- - ~>
|
45
40
|
- !ruby/object:Gem::Version
|
@@ -47,7 +42,6 @@ dependencies:
|
|
47
42
|
- !ruby/object:Gem::Dependency
|
48
43
|
name: rspec
|
49
44
|
requirement: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
45
|
requirements:
|
52
46
|
- - ~>
|
53
47
|
- !ruby/object:Gem::Version
|
@@ -55,7 +49,6 @@ dependencies:
|
|
55
49
|
type: :development
|
56
50
|
prerelease: false
|
57
51
|
version_requirements: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
52
|
requirements:
|
60
53
|
- - ~>
|
61
54
|
- !ruby/object:Gem::Version
|
@@ -63,7 +56,6 @@ dependencies:
|
|
63
56
|
- !ruby/object:Gem::Dependency
|
64
57
|
name: rake
|
65
58
|
requirement: !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
59
|
requirements:
|
68
60
|
- - ! '>='
|
69
61
|
- !ruby/object:Gem::Version
|
@@ -71,7 +63,6 @@ dependencies:
|
|
71
63
|
type: :development
|
72
64
|
prerelease: false
|
73
65
|
version_requirements: !ruby/object:Gem::Requirement
|
74
|
-
none: false
|
75
66
|
requirements:
|
76
67
|
- - ! '>='
|
77
68
|
- !ruby/object:Gem::Version
|
@@ -115,30 +106,27 @@ files:
|
|
115
106
|
- spec/rollback_spec.rb
|
116
107
|
- spec/spec_helper.rb
|
117
108
|
homepage: http://github.com/engineyard/engineyard-serverside-adapter
|
118
|
-
licenses:
|
109
|
+
licenses:
|
110
|
+
- MIT
|
111
|
+
metadata: {}
|
119
112
|
post_install_message:
|
120
113
|
rdoc_options: []
|
121
114
|
require_paths:
|
122
115
|
- lib
|
123
116
|
required_ruby_version: !ruby/object:Gem::Requirement
|
124
|
-
none: false
|
125
117
|
requirements:
|
126
118
|
- - ! '>='
|
127
119
|
- !ruby/object:Gem::Version
|
128
120
|
version: '0'
|
129
|
-
segments:
|
130
|
-
- 0
|
131
|
-
hash: -3196036238943305077
|
132
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
-
none: false
|
134
122
|
requirements:
|
135
123
|
- - ! '>='
|
136
124
|
- !ruby/object:Gem::Version
|
137
125
|
version: 1.3.6
|
138
126
|
requirements: []
|
139
127
|
rubyforge_project: engineyard-serverside-adapter
|
140
|
-
rubygems_version:
|
128
|
+
rubygems_version: 2.0.6
|
141
129
|
signing_key:
|
142
|
-
specification_version:
|
130
|
+
specification_version: 4
|
143
131
|
summary: Adapter for speaking to engineyard-serverside
|
144
132
|
test_files: []
|