engineyard-serverside-adapter 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +41 -21
- data/lib/engineyard-serverside-adapter/action.rb +8 -3
- data/lib/engineyard-serverside-adapter/arguments.rb +17 -41
- data/lib/engineyard-serverside-adapter/command.rb +4 -3
- data/lib/engineyard-serverside-adapter/version.rb +4 -1
- data/spec/adapter_spec.rb +12 -0
- data/spec/arguments_spec.rb +6 -0
- data/spec/deploy_spec.rb +1 -0
- data/spec/disable_maintenance_spec.rb +1 -0
- data/spec/enable_maintenance_spec.rb +1 -0
- data/spec/integrate_spec.rb +1 -0
- data/spec/restart_spec.rb +1 -0
- data/spec/rollback_spec.rb +1 -0
- data/spec/spec_helper.rb +7 -0
- metadata +3 -3
data/Rakefile
CHANGED
@@ -6,11 +6,15 @@ task :default => :spec
|
|
6
6
|
|
7
7
|
desc "Release engineyard-serverside-adapter gem"
|
8
8
|
task :release do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
puts "Adapter DOES NOT bump serverside automatically anymore."
|
10
|
+
puts "Please reference the serverside_version in the client."
|
11
|
+
puts
|
12
|
+
new_version = remove_pre
|
13
|
+
|
14
|
+
run_commands("git tag v#{new_version}",
|
15
|
+
"gem build engineyard-serverside-adapter.gemspec")
|
16
|
+
|
17
|
+
next_pre(new_version)
|
14
18
|
|
15
19
|
puts <<-PUSHGEM
|
16
20
|
## To publish the gem: #########################################################
|
@@ -22,25 +26,41 @@ task :release do
|
|
22
26
|
PUSHGEM
|
23
27
|
end
|
24
28
|
|
25
|
-
def
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
module Serverside
|
33
|
-
class Adapter
|
34
|
-
VERSION = "#{new_version}"
|
35
|
-
ENGINEYARD_SERVERSIDE_VERSION = ENV['ENGINEYARD_SERVERSIDE_VERSION'] || "#{new_version}"
|
36
|
-
end
|
29
|
+
def version_path
|
30
|
+
Pathname.new('lib/engineyard-serverside-adapter/version.rb')
|
31
|
+
end
|
32
|
+
|
33
|
+
def run_commands(*cmds)
|
34
|
+
cmds.flatten.each do |c|
|
35
|
+
system(c) or raise "Command #{c.inspect} failed to execute; aborting!"
|
37
36
|
end
|
38
37
|
end
|
39
|
-
EOT
|
40
38
|
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
def remove_pre
|
40
|
+
require 'engineyard-serverside-adapter/version'
|
41
|
+
version = EY::Serverside::Adapter::VERSION
|
42
|
+
unless version =~ /\.pre$/
|
43
|
+
raise "Version #{version.inspect} does not end with .pre, you should release manually if you want a custom version name."
|
44
44
|
end
|
45
|
+
new_version = version.gsub(/\.pre$/, '')
|
46
|
+
puts "New version is #{new_version}"
|
47
|
+
bump(new_version, "Bump to version #{new_version}")
|
45
48
|
new_version
|
46
49
|
end
|
50
|
+
|
51
|
+
def next_pre(version)
|
52
|
+
digits = version.scan(/(\d+)/).map { |x| x.first.to_i }
|
53
|
+
digits[-1] += 1
|
54
|
+
new_version = digits.join('.') + ".pre"
|
55
|
+
puts "Next version is #{new_version}"
|
56
|
+
bump(new_version, "Add .pre for next release")
|
57
|
+
end
|
58
|
+
|
59
|
+
def bump(new_version, commit_msg)
|
60
|
+
contents = version_path.read.sub(/VERSION = "[^"]+"/, %|VERSION = "#{new_version}"|)
|
61
|
+
version_path.unlink
|
62
|
+
version_path.open('w') { |f| f.write contents }
|
63
|
+
run_commands(
|
64
|
+
"git add #{version_path}",
|
65
|
+
"git commit -m '#{commit_msg}'")
|
66
|
+
end
|
@@ -10,6 +10,7 @@ module EY
|
|
10
10
|
@gem_bin_path = Pathname.new(options[:gem_bin_path] || "")
|
11
11
|
arguments = options[:arguments] || Arguments.new
|
12
12
|
block.call arguments if block
|
13
|
+
@serverside_version = arguments.serverside_version
|
13
14
|
|
14
15
|
extract_state_from_arguments(arguments)
|
15
16
|
validate!
|
@@ -45,8 +46,12 @@ module EY
|
|
45
46
|
"(#{check_command}) || (#{install_command})"
|
46
47
|
end
|
47
48
|
|
49
|
+
def engineyard_serverside_version
|
50
|
+
@serverside_version || ENGINEYARD_SERVERSIDE_VERSION
|
51
|
+
end
|
52
|
+
|
48
53
|
def check_command
|
49
|
-
escaped_engineyard_serverside_version =
|
54
|
+
escaped_engineyard_serverside_version = engineyard_serverside_version.gsub(/\./, '\.')
|
50
55
|
|
51
56
|
[
|
52
57
|
Escape.shell_command([gem_path, "list", "engineyard-serverside"]),
|
@@ -62,7 +67,7 @@ module EY
|
|
62
67
|
#
|
63
68
|
# rubygems help suggests that --remote will disable this
|
64
69
|
# behavior, but it doesn't.
|
65
|
-
install_command = "cd `mktemp -d` && #{gem_path} install engineyard-serverside --no-rdoc --no-ri -v #{
|
70
|
+
install_command = "cd `mktemp -d` && #{gem_path} install engineyard-serverside --no-rdoc --no-ri -v #{engineyard_serverside_version}"
|
66
71
|
Escape.shell_command(['sudo', 'sh', '-c', install_command])
|
67
72
|
end
|
68
73
|
|
@@ -71,7 +76,7 @@ module EY
|
|
71
76
|
end
|
72
77
|
|
73
78
|
def action_command
|
74
|
-
cmd = Command.new(@gem_bin_path, *task)
|
79
|
+
cmd = Command.new(@gem_bin_path, engineyard_serverside_version, *task)
|
75
80
|
@state.each do |option_name, value|
|
76
81
|
option_type = self.class.options[option_name][:type]
|
77
82
|
switch = "--" + option_name.to_s.gsub(/_/, '-')
|
@@ -1,27 +1,22 @@
|
|
1
1
|
module EY
|
2
2
|
module Serverside
|
3
3
|
class Adapter
|
4
|
-
class Arguments
|
5
|
-
|
6
|
-
def
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
def account_name=(acc)
|
17
|
-
enforce_nonempty!('account_name', acc)
|
18
|
-
super
|
4
|
+
class Arguments
|
5
|
+
|
6
|
+
def self.nonempty_writer(*names)
|
7
|
+
names.each do |name|
|
8
|
+
define_method(:"#{name}=") do |value|
|
9
|
+
if value.to_s.empty?
|
10
|
+
raise ArgumentError, "Value for '#{name}' must be non-empty."
|
11
|
+
end
|
12
|
+
instance_variable_set("@#{name}", value)
|
13
|
+
end
|
14
|
+
end
|
19
15
|
end
|
20
16
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
17
|
+
attr_reader :app, :environment_name, :account_name, :config, :framework_env, :instances, :migrate, :ref, :repo, :serverside_version, :stack, :verbose
|
18
|
+
nonempty_writer :app, :environment_name, :account_name, :framework_env, :ref, :repo, :serverside_version, :stack
|
19
|
+
attr_writer :config, :migrate, :verbose
|
25
20
|
|
26
21
|
def instances=(instances)
|
27
22
|
unless instances.respond_to?(:each)
|
@@ -38,30 +33,11 @@ module EY
|
|
38
33
|
end
|
39
34
|
end
|
40
35
|
|
41
|
-
|
36
|
+
@instances = instances
|
42
37
|
end
|
43
38
|
|
44
|
-
def
|
45
|
-
|
46
|
-
super
|
47
|
-
end
|
48
|
-
|
49
|
-
def repo=(repo)
|
50
|
-
enforce_nonempty!('repo', repo)
|
51
|
-
super
|
52
|
-
end
|
53
|
-
|
54
|
-
def stack=(stack)
|
55
|
-
enforce_nonempty!('stack', stack)
|
56
|
-
super
|
57
|
-
end
|
58
|
-
|
59
|
-
private
|
60
|
-
|
61
|
-
def enforce_nonempty!(name, value)
|
62
|
-
if value.to_s.empty?
|
63
|
-
raise ArgumentError, "Value for '#{name}' must be non-empty."
|
64
|
-
end
|
39
|
+
def serverside_version=(value)
|
40
|
+
@serverside_version = Gem::Version.new(value).to_s
|
65
41
|
end
|
66
42
|
|
67
43
|
end
|
@@ -5,14 +5,15 @@ module EY
|
|
5
5
|
module Serverside
|
6
6
|
class Adapter
|
7
7
|
class Command
|
8
|
-
def initialize(bin_path, *task)
|
8
|
+
def initialize(bin_path, serverside_version, *task)
|
9
|
+
@binary = bin_path.join('engineyard-serverside').to_s
|
10
|
+
@serverside_version = serverside_version
|
9
11
|
@task = task
|
10
12
|
@arguments = []
|
11
|
-
@binary = bin_path.join('engineyard-serverside').to_s
|
12
13
|
end
|
13
14
|
|
14
15
|
def to_s
|
15
|
-
Escape.shell_command [@binary, "_#{
|
16
|
+
Escape.shell_command [@binary, "_#{@serverside_version}_"] + @task + @arguments.sort_by { |x| x.first }.flatten
|
16
17
|
end
|
17
18
|
|
18
19
|
def array_argument(switch, values)
|
@@ -1,7 +1,10 @@
|
|
1
1
|
module EY
|
2
2
|
module Serverside
|
3
3
|
class Adapter
|
4
|
-
VERSION = "2.0.
|
4
|
+
VERSION = "2.0.2"
|
5
|
+
# For backwards compatibility, the serverside version default will be maintained until 2.1
|
6
|
+
# It is recommended that you supply a serverside_version to engineyard-serverside-adapter
|
7
|
+
# rather than relying on the default version here. This default will go away soon.
|
5
8
|
ENGINEYARD_SERVERSIDE_VERSION = ENV['ENGINEYARD_SERVERSIDE_VERSION'] || "2.0.1"
|
6
9
|
end
|
7
10
|
end
|
data/spec/adapter_spec.rb
CHANGED
@@ -76,6 +76,18 @@ shared_examples_for "a serverside action" do
|
|
76
76
|
commands.last.should =~ %r{^/usr/local/grin/engineyard-serverside}
|
77
77
|
end
|
78
78
|
end
|
79
|
+
|
80
|
+
context "with an alternate serverside_version specified" do
|
81
|
+
it "uses the given version for the gem install and serverside commands" do
|
82
|
+
action = @adapter.send(@method) do |args|
|
83
|
+
args.serverside_version = '1.6.4'
|
84
|
+
end
|
85
|
+
|
86
|
+
commands = all_commands(action)
|
87
|
+
commands.first.should == "(gem list engineyard-serverside | grep 'engineyard-serverside ' | egrep -q '1\\.6\\.4[,)]') || (sudo sh -c 'cd `mktemp -d` && gem install engineyard-serverside --no-rdoc --no-ri -v 1.6.4')"
|
88
|
+
commands.last.should =~ /engineyard-serverside _1\.6\.4_/
|
89
|
+
end
|
90
|
+
end
|
79
91
|
end
|
80
92
|
|
81
93
|
describe EY::Serverside::Adapter do
|
data/spec/arguments_spec.rb
CHANGED
@@ -25,4 +25,10 @@ describe EY::Serverside::Adapter::Arguments do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
it "raises an ArgumentError immediately when serverside_version is weird" do
|
29
|
+
raises_argument_error(/Malformed version number string what the flower/) do |arguments|
|
30
|
+
arguments.serverside_version = 'what the flower'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
28
34
|
end
|
data/spec/deploy_spec.rb
CHANGED
@@ -13,6 +13,7 @@ describe EY::Serverside::Adapter::Deploy do
|
|
13
13
|
it_should_behave_like "it accepts repo"
|
14
14
|
it_should_behave_like "it accepts stack"
|
15
15
|
it_should_behave_like "it accepts verbose"
|
16
|
+
it_should_behave_like "it accepts serverside_version"
|
16
17
|
|
17
18
|
it_should_require :app
|
18
19
|
it_should_require :environment_name
|
@@ -8,6 +8,7 @@ describe EY::Serverside::Adapter::DisableMaintenance do
|
|
8
8
|
it_should_behave_like "it accepts account_name"
|
9
9
|
it_should_behave_like "it accepts instances"
|
10
10
|
it_should_behave_like "it accepts verbose"
|
11
|
+
it_should_behave_like "it accepts serverside_version"
|
11
12
|
|
12
13
|
it_should_require :app
|
13
14
|
it_should_require :environment_name
|
@@ -8,6 +8,7 @@ describe EY::Serverside::Adapter::EnableMaintenance do
|
|
8
8
|
it_should_behave_like "it accepts account_name"
|
9
9
|
it_should_behave_like "it accepts instances"
|
10
10
|
it_should_behave_like "it accepts verbose"
|
11
|
+
it_should_behave_like "it accepts serverside_version"
|
11
12
|
|
12
13
|
it_should_require :app
|
13
14
|
it_should_require :environment_name
|
data/spec/integrate_spec.rb
CHANGED
@@ -10,6 +10,7 @@ describe EY::Serverside::Adapter::Integrate do
|
|
10
10
|
it_should_behave_like "it accepts instances"
|
11
11
|
it_should_behave_like "it accepts stack"
|
12
12
|
it_should_behave_like "it accepts verbose"
|
13
|
+
it_should_behave_like "it accepts serverside_version"
|
13
14
|
|
14
15
|
it_should_require :app
|
15
16
|
it_should_require :environment_name
|
data/spec/restart_spec.rb
CHANGED
@@ -9,6 +9,7 @@ describe EY::Serverside::Adapter::Restart do
|
|
9
9
|
it_should_behave_like "it accepts instances"
|
10
10
|
it_should_behave_like "it accepts stack"
|
11
11
|
it_should_behave_like "it accepts verbose"
|
12
|
+
it_should_behave_like "it accepts serverside_version"
|
12
13
|
|
13
14
|
it_should_require :app
|
14
15
|
it_should_require :environment_name
|
data/spec/rollback_spec.rb
CHANGED
@@ -10,6 +10,7 @@ describe EY::Serverside::Adapter::Rollback do
|
|
10
10
|
it_should_behave_like "it accepts instances"
|
11
11
|
it_should_behave_like "it accepts stack"
|
12
12
|
it_should_behave_like "it accepts verbose"
|
13
|
+
it_should_behave_like "it accepts serverside_version"
|
13
14
|
|
14
15
|
it_should_require :app
|
15
16
|
it_should_require :environment_name
|
data/spec/spec_helper.rb
CHANGED
@@ -142,6 +142,13 @@ RSpec.configure do |config|
|
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
145
|
+
shared_examples_for "it accepts serverside_version" do
|
146
|
+
it "puts the _VERSION_ command part in the command line" do
|
147
|
+
adapter = described_class.new(:arguments => arguments_with(:serverside_version => '1.2.3'))
|
148
|
+
last_command(adapter).should =~ /engineyard-serverside _1.2.3_/
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
145
152
|
shared_examples_for "it accepts instances" do
|
146
153
|
context "given an unnamed instance" do
|
147
154
|
it "puts the instance in the command line" do
|
metadata
CHANGED
@@ -1,7 +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.
|
4
|
+
version: 2.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-08-
|
13
|
+
date: 2012-08-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: escape
|
@@ -125,7 +125,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
125
125
|
version: '0'
|
126
126
|
segments:
|
127
127
|
- 0
|
128
|
-
hash:
|
128
|
+
hash: 3765689580942820898
|
129
129
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
130
|
none: false
|
131
131
|
requirements:
|