pbox 1.17.3 → 1.17.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/features/core_feature.rb +5 -3
- data/features/domains_feature.rb +9 -0
- data/lib/rhc/cartridge_helpers.rb +1 -1
- data/lib/rhc/commands/cartridge.rb +1 -1
- data/lib/rhc/commands/domain.rb +9 -5
- data/lib/rhc/deployment_helpers.rb +28 -5
- data/lib/rhc/exceptions.rb +6 -0
- data/lib/rhc/rest/mock.rb +4 -3
- data/spec/direct_execution_helper.rb +3 -2
- data/spec/rhc/commands/cartridge_spec.rb +9 -0
- data/spec/rhc/commands/deployment_spec.rb +45 -4
- data/spec/rhc/commands/domain_spec.rb +18 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfee555f9ee9118e0f424635efa02f04ac6a2f42
|
4
|
+
data.tar.gz: 397cdb8bd8890ecb90e24c5347b41ea06e428b6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdb3780c523b969c9b368145055815c843aaeacac1225058b0410227bc770d07b93cee33d68f3e4f899fd4d6e3a6e77253e2626df4fdd4b6998b5565b476adfa
|
7
|
+
data.tar.gz: 43bec694062f48e44c2ac6493cbb420c05b8c35eb8ec2a99a9e7e70c8eb9b3073130a84edc4c061e560322453b5deaeeb21fd333f794e50c184bfc4f9a7b7ada
|
data/features/core_feature.rb
CHANGED
@@ -161,14 +161,16 @@ describe "pbox core scenarios" do
|
|
161
161
|
let(:app){ @app }
|
162
162
|
|
163
163
|
it "should add a cartridge with small gear size" do
|
164
|
-
|
165
|
-
r.
|
164
|
+
cartridge = a_random_cartridge(['embedded', 'service', 'database'])
|
165
|
+
r = pbox 'add-cartridge', cartridge, '-a', app.name, '--gear-size', 'small'
|
166
|
+
r.stdout.should match /#{cartridge}/
|
166
167
|
r.stdout.should match /Gears:\s+1 small/
|
167
168
|
r.status.should == 0
|
168
169
|
end
|
169
170
|
|
170
171
|
it "should fail for a cartridge with not allowed gear size" do
|
171
|
-
|
172
|
+
cartridge = a_random_cartridge(['embedded', 'service', 'database'])
|
173
|
+
r = pbox 'add-cartridge', cartridge, '-a', app.name, '--gear-size', 'medium'
|
172
174
|
r.stdout.should match "The gear size 'medium' is not valid for this domain. Allowed sizes: small."
|
173
175
|
r.status.should_not == 0
|
174
176
|
end
|
data/features/domains_feature.rb
CHANGED
@@ -34,12 +34,21 @@ describe "pbox domain scenarios" do
|
|
34
34
|
|
35
35
|
it "should reject invalid gear size configuration changes" do
|
36
36
|
all_sizes = client.user.capabilities.gear_sizes
|
37
|
+
valid_sizes = client.api.links['ADD_DOMAIN']['optional_params'].inject([]) {|sizes, p| sizes += p['valid_options'] if p['name'] == 'allowed_gear_sizes' } rescue []
|
38
|
+
disallowed_sizes = valid_sizes - all_sizes
|
37
39
|
|
38
40
|
r = pbox 'configure-domain', domain.name, '--allowed-gear-sizes', '_not_a_size_'
|
39
41
|
r.status.should_not == 1
|
40
42
|
r.stdout.should match "Updating domain configuration.*The following gear sizes are invalid: _not_a_size_"
|
41
43
|
client.reset.find_domain(domain.name).allowed_gear_sizes.should == all_sizes
|
42
44
|
|
45
|
+
if disallowed_sizes.first
|
46
|
+
r = pbox 'configure-domain', domain.name, '--allowed-gear-sizes', disallowed_sizes.first
|
47
|
+
r.status.should_not == 1
|
48
|
+
r.stdout.should match "Updating domain configuration.*The following gear sizes are not available.*: #{disallowed_sizes.first}"
|
49
|
+
client.reset.find_domain(domain.name).allowed_gear_sizes.should == all_sizes
|
50
|
+
end
|
51
|
+
|
43
52
|
r = pbox 'configure-domain', domain.name, '--allowed-gear-sizes'
|
44
53
|
r.status.should_not == 1
|
45
54
|
r.stdout.should match "invalid option: Provide a comma delimited .* --allowed-gear-sizes"
|
@@ -51,7 +51,7 @@ module RHC
|
|
51
51
|
].compact.any?{ |s| s.present? && s.downcase.gsub(/[_\-\s]/,' ').include?(search) } ||
|
52
52
|
search.length > 2 && [
|
53
53
|
cart.description
|
54
|
-
].compact.any?{ |s| s.present? && !s.downcase.match(/\b#{search}\b/).nil? }
|
54
|
+
].compact.any?{ |s| s.present? && !s.downcase.match(/\b#{Regexp.escape(search)}\b/).nil? }
|
55
55
|
end
|
56
56
|
|
57
57
|
def web_carts_only
|
@@ -199,7 +199,7 @@ module RHC::Commands
|
|
199
199
|
cartridges such as databases may require specific increments of scaling (1, 3, 5) in order to
|
200
200
|
properly function. Please consult the cartridge documentation for more on specifics of scaling.
|
201
201
|
|
202
|
-
Set both values the same to guarantee a scale value. You may
|
202
|
+
Set both values the same to guarantee a scale value. You may specify both values with the argument
|
203
203
|
'multiplier' or use '--min' and '--max' independently.
|
204
204
|
|
205
205
|
Scaling may take several minutes or more if the server must provision multiple gears. Your operation
|
data/lib/rhc/commands/domain.rb
CHANGED
@@ -37,7 +37,8 @@ module RHC::Commands
|
|
37
37
|
'--allowed-gear-sizes' option. If '--no-allowed-gear-sizes' is set, no applications
|
38
38
|
can be created in the domain. Older servers may not support this option.
|
39
39
|
DESC
|
40
|
-
option ['--
|
40
|
+
option ['--no-allowed-gear-sizes'], 'Do not allow any gear sizes in this domain.', :optional => true
|
41
|
+
option ['--allowed-gear-sizes [SIZES]'], 'A comma-delimited list of the gear sizes that will be allowed in this domain.', :optional => true
|
41
42
|
argument :namespace, "New domain name (letters and numbers, max 16 chars)", ["-n", "--namespace NAME"]
|
42
43
|
def create(namespace)
|
43
44
|
say "Creating domain '#{namespace}' ... "
|
@@ -68,12 +69,13 @@ module RHC::Commands
|
|
68
69
|
|
69
70
|
summary "Change one or more configuration settings on the domain"
|
70
71
|
syntax "<namespace>"
|
71
|
-
option ['--
|
72
|
+
option ['--no-allowed-gear-sizes'], 'Do not allow any gear sizes in this domain.', :optional => true
|
73
|
+
option ['--allowed-gear-sizes [SIZES]'], "A comma-delimited list of gear sizes allowed in this domain. To see available sizes, run 'pbox account'.", :optional => true
|
72
74
|
takes_domain :argument => true
|
73
75
|
def configure(_)
|
74
76
|
domain = find_domain
|
75
77
|
payload = {}
|
76
|
-
payload[:allowed_gear_sizes] = check_allowed_gear_sizes unless options.allowed_gear_sizes.nil?
|
78
|
+
payload[:allowed_gear_sizes] = check_allowed_gear_sizes unless options.allowed_gear_sizes.nil? and options.no_allowed_gear_sizes.nil?
|
77
79
|
|
78
80
|
if payload.present?
|
79
81
|
say "Updating domain configuration ... "
|
@@ -128,11 +130,12 @@ module RHC::Commands
|
|
128
130
|
summary "Delete a domain"
|
129
131
|
syntax "<namespace>"
|
130
132
|
takes_domain :argument => true
|
133
|
+
option ["-f", "--force"], "Force the action"
|
131
134
|
def delete(_)
|
132
135
|
domain = find_domain
|
133
136
|
|
134
137
|
say "Deleting domain '#{domain.name}' ... "
|
135
|
-
domain.destroy
|
138
|
+
domain.destroy(options.force.present?)
|
136
139
|
success "deleted"
|
137
140
|
|
138
141
|
0
|
@@ -153,7 +156,8 @@ module RHC::Commands
|
|
153
156
|
|
154
157
|
protected
|
155
158
|
def check_allowed_gear_sizes
|
156
|
-
sizes
|
159
|
+
raise OptionParser::InvalidOption, "--allowed-gear-sizes and --no-allowed-gear-sizes cannot both be specified" unless options.allowed_gear_sizes.nil? or options.no_allowed_gear_sizes.nil?
|
160
|
+
sizes = options.no_allowed_gear_sizes.nil? ? options.allowed_gear_sizes : false
|
157
161
|
raise OptionParser::InvalidOption, "The server does not support --allowed-gear-sizes" unless sizes.nil? || rest_client.api.has_param?(:add_domain, 'allowed_gear_sizes')
|
158
162
|
if sizes.is_a? String
|
159
163
|
sizes.split(',').map(&:strip).map(&:presence)
|
@@ -10,11 +10,34 @@ module RHC
|
|
10
10
|
protected
|
11
11
|
|
12
12
|
def deploy_artifact(rest_app, artifact, hot_deploy, force_clean_build)
|
13
|
-
File.file?(artifact)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
is_file = File.file?(artifact)
|
14
|
+
is_url = URI::ABS_URI.match(artifact).present?
|
15
|
+
|
16
|
+
if rest_app.deployment_type == 'binary'
|
17
|
+
if is_file
|
18
|
+
deploy_local_file(rest_app, artifact, hot_deploy, force_clean_build)
|
19
|
+
elsif is_url
|
20
|
+
deploy_file_from_url(rest_app, artifact, hot_deploy, force_clean_build)
|
21
|
+
else
|
22
|
+
paragraph do
|
23
|
+
warn "The application '#{rest_app.name}' is configured for binary deployments but the artifact "\
|
24
|
+
"provided ('#{artifact}') is not a binary file. Please provide the path to a deployable file on "\
|
25
|
+
"your local filesystem or a url, or configure your app to deploy from a git reference with 'pbox "\
|
26
|
+
"configure-app #{rest_app.name} --deployment-type git'."
|
27
|
+
end
|
28
|
+
raise IncompatibleDeploymentTypeException
|
29
|
+
end
|
30
|
+
elsif is_file || is_url
|
31
|
+
paragraph do
|
32
|
+
warn "The application '#{rest_app.name}' is configured for git "\
|
33
|
+
"reference deployments but the artifact provided ('#{artifact}') is #{is_file ? 'a file' : 'a url'}. Please "\
|
34
|
+
"provide a git reference to deploy (branch, tag or commit SHA1) or configure your app to deploy from binaries "\
|
35
|
+
"with 'pbox configure-app #{rest_app.name} --deployment-type binary'."
|
36
|
+
end
|
37
|
+
raise IncompatibleDeploymentTypeException
|
38
|
+
else
|
39
|
+
deploy_git_ref(rest_app, artifact, hot_deploy, force_clean_build)
|
40
|
+
end
|
18
41
|
end
|
19
42
|
|
20
43
|
def deploy_git_ref(rest_app, ref, hot_deploy, force_clean_build)
|
data/lib/rhc/exceptions.rb
CHANGED
@@ -132,6 +132,12 @@ module RHC
|
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
135
|
+
class IncompatibleDeploymentTypeException < Exception
|
136
|
+
def initialize(message="The artifact provided is not compatible with the app deployment type.")
|
137
|
+
super message, 133
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
135
141
|
class MissingScalingValueException < Exception
|
136
142
|
def initialize(message="Must provide either a min or max value for scaling")
|
137
143
|
super message
|
data/lib/rhc/rest/mock.rb
CHANGED
@@ -667,8 +667,8 @@ module RHC::Rest::Mock
|
|
667
667
|
self
|
668
668
|
end
|
669
669
|
|
670
|
-
def destroy
|
671
|
-
raise RHC::Rest::ClientErrorException.new("Applications must be empty.") unless @applications.empty?
|
670
|
+
def destroy(force=false)
|
671
|
+
raise RHC::Rest::ClientErrorException.new("Applications must be empty.") unless @applications.empty? or force.present?
|
672
672
|
client.domains.delete_if { |d| d.name == @name }
|
673
673
|
|
674
674
|
@applications = nil
|
@@ -929,9 +929,10 @@ module RHC::Rest::Mock
|
|
929
929
|
|
930
930
|
attr_accessor :usage_rate
|
931
931
|
|
932
|
-
def initialize(client, name, type, app=nil, tags=[], properties=[{'type' => 'cart_data', 'name' => 'connection_url', 'value' => "http://fake.url" }])
|
932
|
+
def initialize(client, name, type, app=nil, tags=[], properties=[{'type' => 'cart_data', 'name' => 'connection_url', 'value' => "http://fake.url" }], description=nil)
|
933
933
|
super({}, client)
|
934
934
|
@name = name
|
935
|
+
@description = description || "Description of #{name}"
|
935
936
|
@type = type
|
936
937
|
@app = app
|
937
938
|
@tags = tags
|
@@ -36,8 +36,9 @@ module RhcExecutionHelper
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
def
|
40
|
-
|
39
|
+
def a_random_cartridge(with_tags=nil, for_user=nil)
|
40
|
+
c = for_user ? for_user.client : client
|
41
|
+
c.cartridges.select{|cartridge| with_tags.nil? || (with_tags - cartridge.tags).empty?}.shuffle.first.name
|
41
42
|
end
|
42
43
|
|
43
44
|
def pbox(*args)
|
@@ -184,6 +184,15 @@ describe RHC::Commands::Cartridge do
|
|
184
184
|
}
|
185
185
|
end
|
186
186
|
|
187
|
+
context 'when cartridge with regex breaking name does not exist' do
|
188
|
+
let(:arguments) { ['cartridge', 'add', '*##', '--app', 'app1'] }
|
189
|
+
before do
|
190
|
+
domain = rest_client.add_domain("mock_domain")
|
191
|
+
app = domain.add_application("app1", "mock_type")
|
192
|
+
end
|
193
|
+
it{ fail_with_code 154 }
|
194
|
+
end
|
195
|
+
|
187
196
|
context 'when cartridge does not exist' do
|
188
197
|
let(:arguments) { ['cartridge', 'add', 'nomatch_cart', '--app', 'app1'] }
|
189
198
|
before do
|
@@ -58,6 +58,7 @@ describe RHC::Commands::Deployment do
|
|
58
58
|
|
59
59
|
context "binary file successfully" do
|
60
60
|
before do
|
61
|
+
@rest_app.stub(:deployment_type).and_return('binary')
|
61
62
|
ssh = double(Net::SSH)
|
62
63
|
session = double(Net::SSH::Connection::Session)
|
63
64
|
channel = double(Net::SSH::Connection::Channel)
|
@@ -92,6 +93,7 @@ describe RHC::Commands::Deployment do
|
|
92
93
|
URI('https://foo.com/path/to/file/' + DEPLOYMENT_APP_NAME + '.tar.gz')].each do |uri|
|
93
94
|
context "url file successfully" do
|
94
95
|
before do
|
96
|
+
@rest_app.stub(:deployment_type).and_return('binary')
|
95
97
|
ssh = double(Net::SSH)
|
96
98
|
session = double(Net::SSH::Connection::Session)
|
97
99
|
channel = double(Net::SSH::Connection::Channel)
|
@@ -126,6 +128,7 @@ describe RHC::Commands::Deployment do
|
|
126
128
|
|
127
129
|
context "binary file with corrupted file" do
|
128
130
|
before do
|
131
|
+
@rest_app.stub(:deployment_type).and_return('binary')
|
129
132
|
ssh = double(Net::SSH)
|
130
133
|
session = double(Net::SSH::Connection::Session)
|
131
134
|
channel = double(Net::SSH::Connection::Channel)
|
@@ -165,7 +168,10 @@ describe RHC::Commands::Deployment do
|
|
165
168
|
end
|
166
169
|
|
167
170
|
context "fails when deploying binary file" do
|
168
|
-
before (:each)
|
171
|
+
before (:each) do
|
172
|
+
@rest_app.stub(:deployment_type).and_return('binary')
|
173
|
+
Net::SSH.should_receive(:start).and_raise(Errno::ECONNREFUSED)
|
174
|
+
end
|
169
175
|
let(:arguments) {['app', 'deploy', @targz_filename, '--app', DEPLOYMENT_APP_NAME]}
|
170
176
|
it "should exit with error" do
|
171
177
|
expect{ run }.to exit_with_code(1)
|
@@ -173,7 +179,10 @@ describe RHC::Commands::Deployment do
|
|
173
179
|
end
|
174
180
|
|
175
181
|
context "fails when deploying binary file" do
|
176
|
-
before (:each)
|
182
|
+
before (:each) do
|
183
|
+
@rest_app.stub(:deployment_type).and_return('binary')
|
184
|
+
Net::SSH.should_receive(:start).and_raise(SocketError)
|
185
|
+
end
|
177
186
|
let(:arguments) {['app', 'deploy', @targz_filename, '--app', DEPLOYMENT_APP_NAME]}
|
178
187
|
it "should exit with error" do
|
179
188
|
expect{ run }.to exit_with_code(1)
|
@@ -181,7 +190,10 @@ describe RHC::Commands::Deployment do
|
|
181
190
|
end
|
182
191
|
|
183
192
|
context "fails when deploying url file" do
|
184
|
-
before (:each)
|
193
|
+
before (:each) do
|
194
|
+
@rest_app.stub(:deployment_type).and_return('binary')
|
195
|
+
Net::SSH.should_receive(:start).and_raise(Errno::ECONNREFUSED)
|
196
|
+
end
|
185
197
|
let(:arguments) {['app', 'deploy', 'http://foo.com/deploy.tar.gz', '--app', DEPLOYMENT_APP_NAME]}
|
186
198
|
it "should exit with error" do
|
187
199
|
expect{ run }.to exit_with_code(1)
|
@@ -189,7 +201,10 @@ describe RHC::Commands::Deployment do
|
|
189
201
|
end
|
190
202
|
|
191
203
|
context "fails when deploying url file" do
|
192
|
-
before (:each)
|
204
|
+
before (:each) do
|
205
|
+
@rest_app.stub(:deployment_type).and_return('binary')
|
206
|
+
Net::SSH.should_receive(:start).and_raise(SocketError)
|
207
|
+
end
|
193
208
|
let(:arguments) {['app', 'deploy', 'http://foo.com/deploy.tar.gz', '--app', DEPLOYMENT_APP_NAME]}
|
194
209
|
it "should exit with error" do
|
195
210
|
expect{ run }.to exit_with_code(1)
|
@@ -217,6 +232,32 @@ describe RHC::Commands::Deployment do
|
|
217
232
|
end
|
218
233
|
end
|
219
234
|
|
235
|
+
context "fails when deploying git reference on an app configured to deployment_type = binary" do
|
236
|
+
before { @rest_app.stub(:deployment_type).and_return('binary') }
|
237
|
+
let(:arguments) {['app', 'deploy', 'master', '--app', DEPLOYMENT_APP_NAME]}
|
238
|
+
it "should exit with error" do
|
239
|
+
expect{ run }.to exit_with_code(133)
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
context "fails when deploying file on an app configured to deployment_type = git" do
|
244
|
+
before { @rest_app.stub(:deployment_type).and_return('git') }
|
245
|
+
let(:arguments) {['app', 'deploy', @targz_filename, '--app', DEPLOYMENT_APP_NAME]}
|
246
|
+
it "should exit with error" do
|
247
|
+
expect{ run }.to exit_with_code(133)
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
[URI('http://foo.com/path/to/file/' + DEPLOYMENT_APP_NAME + '.tar.gz'),
|
252
|
+
URI('https://foo.com/path/to/file/' + DEPLOYMENT_APP_NAME + '.tar.gz')].each do |uri|
|
253
|
+
context "fails when deploying url on an app configured to deployment_type = git" do
|
254
|
+
before { @rest_app.stub(:deployment_type).and_return('git') }
|
255
|
+
let(:arguments) {['app', 'deploy', uri.to_s, '--app', DEPLOYMENT_APP_NAME]}
|
256
|
+
it "should exit with error" do
|
257
|
+
expect{ run }.to exit_with_code(133)
|
258
|
+
end
|
259
|
+
end
|
260
|
+
end
|
220
261
|
end
|
221
262
|
|
222
263
|
describe "activate deployment" do
|
@@ -321,6 +321,11 @@ describe RHC::Commands::Domain do
|
|
321
321
|
it("should succeed"){ expect { run }.to exit_with_code(0) }
|
322
322
|
it("should display the domain config"){ run_output.should match(/Domain domain1 configuration.*Allowed Gear Sizes:\s+<none>/m) }
|
323
323
|
end
|
324
|
+
|
325
|
+
context "with --allowed-gear-sizes and --no-allowed-gear-sizes" do
|
326
|
+
let(:arguments) { ['domain', 'configure', 'domain1', '--trace', '--no-allowed-gear-sizes', '--allowed-gear-sizes', 'small'] }
|
327
|
+
it("raise an invalid option"){ expect{ run }.to raise_error(OptionParser::InvalidOption, /--allowed-gear-sizes.*--no-allowed-gear-sizes/) }
|
328
|
+
end
|
324
329
|
end
|
325
330
|
end
|
326
331
|
|
@@ -368,6 +373,19 @@ describe RHC::Commands::Domain do
|
|
368
373
|
end
|
369
374
|
it { run_output.should match("Applications must be empty") }
|
370
375
|
end
|
376
|
+
|
377
|
+
context 'when delete is forced' do
|
378
|
+
let(:arguments) { ['domain', 'delete', 'deleteme', '--force'] }
|
379
|
+
before do
|
380
|
+
domain = rest_client.add_domain("deleteme")
|
381
|
+
domain.add_application 'testapp1', 'mock-1.0'
|
382
|
+
end
|
383
|
+
it "should delete successfully" do
|
384
|
+
expect { run }.to exit_with_code(0)
|
385
|
+
rest_client.domains.empty?.should be_true
|
386
|
+
end
|
387
|
+
end
|
388
|
+
|
371
389
|
end
|
372
390
|
|
373
391
|
describe 'help' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.17.
|
4
|
+
version: 1.17.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ProtonBox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: net-ssh
|