rhc 1.17.6 → 1.18.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rhc/auth/token.rb +1 -1
- data/lib/rhc/commands/app.rb +7 -3
- data/lib/rhc/commands/authorization.rb +1 -1
- data/lib/rhc/commands/git_clone.rb +9 -4
- data/lib/rhc/git_helpers.rb +11 -5
- data/spec/rhc/auth_spec.rb +1 -1
- data/spec/rhc/commands/app_spec.rb +9 -0
- data/spec/rhc/commands/authorization_spec.rb +10 -0
- data/spec/rhc/commands/git_clone_spec.rb +9 -0
- data/spec/rhc/helpers_spec.rb +6 -0
- metadata +5 -5
data/lib/rhc/auth/token.rb
CHANGED
@@ -74,7 +74,7 @@ module RHC::Auth
|
|
74
74
|
@can_get_token = client.supports_sessions? && @allows_tokens
|
75
75
|
|
76
76
|
if has_token
|
77
|
-
warn "Your authorization token has expired. Please sign in now to continue."
|
77
|
+
warn "Your authorization token has expired. Please sign in now to continue on #{openshift_server}."
|
78
78
|
elsif @can_get_token
|
79
79
|
info "Please sign in to start a new session to #{openshift_server}."
|
80
80
|
end
|
data/lib/rhc/commands/app.rb
CHANGED
@@ -92,14 +92,14 @@ module RHC::Commands
|
|
92
92
|
|
93
93
|
paragraph do
|
94
94
|
header "Application Options"
|
95
|
-
table([["Domain:", options.namespace],
|
95
|
+
say table([["Domain:", options.namespace],
|
96
96
|
["Cartridges:", cart_names],
|
97
97
|
(["Source Code:", options.from_code] if options.from_code),
|
98
98
|
["Gear Size:", options.gear_size || "default"],
|
99
99
|
["Scaling:", options.scaling ? "yes" : "no"],
|
100
100
|
(["Environment Variables:", env.map{|item| "#{item.name}=#{item.value}"}.join(', ')] if env.present?),
|
101
101
|
].compact
|
102
|
-
)
|
102
|
+
)
|
103
103
|
end
|
104
104
|
|
105
105
|
paragraph do
|
@@ -165,7 +165,11 @@ module RHC::Commands
|
|
165
165
|
if options.git
|
166
166
|
section(:now => true, :top => 1, :bottom => 1) do
|
167
167
|
begin
|
168
|
-
|
168
|
+
if has_git?
|
169
|
+
repo_dir = git_clone_application(rest_app)
|
170
|
+
else
|
171
|
+
warn "You do not have git installed, so your application's git repo will not be cloned"
|
172
|
+
end
|
169
173
|
rescue RHC::GitException => e
|
170
174
|
warn "#{e}"
|
171
175
|
unless RHC::Helpers.windows? and windows_nslookup_bug?(rest_app)
|
@@ -42,7 +42,7 @@ module RHC::Commands
|
|
42
42
|
server maximum, you will be given the default value.
|
43
43
|
DESC
|
44
44
|
def add
|
45
|
-
unless options.scopes
|
45
|
+
unless options.scopes.to_s.strip.present?
|
46
46
|
say "When adding an authorization, you must specify which permissions clients will have."
|
47
47
|
scope_help
|
48
48
|
say "Run 'rhc authorization add --help' to see more options"
|
@@ -16,11 +16,16 @@ module RHC::Commands
|
|
16
16
|
# TODO: Implement default values for arguments once ffranz has added context arguments
|
17
17
|
# argument :directory, "The name of a new directory to clone into", [], :default => nil
|
18
18
|
def run(app_name)
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
if has_git?
|
20
|
+
rest_app = find_app
|
21
|
+
dir = git_clone_application(rest_app)
|
22
|
+
success "Your application Git repository has been cloned to '#{system_path(dir)}'"
|
22
23
|
|
23
|
-
|
24
|
+
0
|
25
|
+
else
|
26
|
+
error "You do not have git installed. In order to fully interact with OpenShift you will need to install and configure a git client."
|
27
|
+
2
|
28
|
+
end
|
24
29
|
end
|
25
30
|
|
26
31
|
private
|
data/lib/rhc/git_helpers.rb
CHANGED
@@ -3,8 +3,12 @@ require 'fileutils'
|
|
3
3
|
|
4
4
|
module RHC
|
5
5
|
module GitHelpers
|
6
|
+
def git_cmd
|
7
|
+
"git"
|
8
|
+
end
|
9
|
+
|
6
10
|
def git_version
|
7
|
-
@git_version ||=
|
11
|
+
@git_version ||= `#{git_cmd} --version 2>&1`.strip #:nocov:
|
8
12
|
end
|
9
13
|
|
10
14
|
def has_git?
|
@@ -46,7 +50,9 @@ module RHC
|
|
46
50
|
|
47
51
|
# :nocov: These all call external binaries so test them in cucumber
|
48
52
|
def git_config_get(key)
|
49
|
-
|
53
|
+
return nil unless has_git?
|
54
|
+
|
55
|
+
config_get_cmd = "#{git_cmd} config --get #{key}"
|
50
56
|
value = %x[#{config_get_cmd}].strip
|
51
57
|
debug "Git config '#{config_get_cmd}' returned '#{value}'"
|
52
58
|
value = nil if $?.exitstatus != 0 or value.empty?
|
@@ -55,8 +61,8 @@ module RHC
|
|
55
61
|
end
|
56
62
|
|
57
63
|
def git_config_set(key, value)
|
58
|
-
unset_cmd = "
|
59
|
-
config_cmd = "
|
64
|
+
unset_cmd = "#{git_cmd} config --unset-all #{key}"
|
65
|
+
config_cmd = "#{git_cmd} config --add #{key} #{value}"
|
60
66
|
debug "Adding #{key} = #{value} to git config"
|
61
67
|
commands = [unset_cmd, config_cmd]
|
62
68
|
commands.each do |cmd|
|
@@ -70,7 +76,7 @@ module RHC
|
|
70
76
|
def git_clone_repo(git_url, repo_dir)
|
71
77
|
# quote the repo to avoid input injection risk
|
72
78
|
destination = (repo_dir ? " \"#{repo_dir}\"" : "")
|
73
|
-
cmd = "
|
79
|
+
cmd = "#{git_cmd} clone #{git_url}#{destination}"
|
74
80
|
debug "Running #{cmd}"
|
75
81
|
|
76
82
|
status, stdout, stderr = run_with_tee(cmd)
|
data/spec/rhc/auth_spec.rb
CHANGED
@@ -391,7 +391,7 @@ describe RHC::Auth::Token do
|
|
391
391
|
context "with a token" do
|
392
392
|
let(:default_options){ {:use_authorization_tokens => true, :token => 'foo'} }
|
393
393
|
it("should invoke raise an error on retry because sessions are not supported") do
|
394
|
-
subject.should_receive(:warn).with("Your authorization token has expired. Please sign in now to continue.")
|
394
|
+
subject.should_receive(:warn).with("Your authorization token has expired. Please sign in now to continue on #{subject.openshift_server}.")
|
395
395
|
auth.should_receive(:retry_auth?).with(response, client).and_return true
|
396
396
|
subject.retry_auth?(response, client).should be_true
|
397
397
|
#expect{ subject.retry_auth?(response, client) }.to raise_error RHC::Rest::AuthorizationsNotSupported
|
@@ -411,6 +411,15 @@ describe RHC::Commands::App do
|
|
411
411
|
end
|
412
412
|
end
|
413
413
|
|
414
|
+
context 'when run without git installed' do
|
415
|
+
before do
|
416
|
+
@instance.stub(:has_git?) { false }
|
417
|
+
end
|
418
|
+
it "should print out git warning" do
|
419
|
+
run_output.should match("You do not have git installed")
|
420
|
+
end
|
421
|
+
end
|
422
|
+
|
414
423
|
context 'when run with windows and no nslookup bug' do
|
415
424
|
before do
|
416
425
|
RHC::Helpers.stub(:windows?) { true }
|
@@ -126,6 +126,16 @@ describe RHC::Commands::Authorization do
|
|
126
126
|
|
127
127
|
expect_an_unsupported_message
|
128
128
|
|
129
|
+
context "with empty scope options" do
|
130
|
+
let(:arguments) { ['authorization', 'add', '--scopes', ' ', '--note', 'a_note', '--expires-in', '300'] }
|
131
|
+
using_command_instance
|
132
|
+
with_authorization
|
133
|
+
before{ instance.should_receive(:scope_help) }
|
134
|
+
|
135
|
+
it('should display the scope help') { command_output.should =~ /When adding an authorization.*to see more options/m }
|
136
|
+
it{ expect{ run_command }.to exit_with_code(0) }
|
137
|
+
end
|
138
|
+
|
129
139
|
context "with options" do
|
130
140
|
let(:arguments) { ['authorization', 'add', '--scope', 'foo,bar', '--note', 'a_note', '--expires-in', '300'] }
|
131
141
|
with_authorization
|
@@ -32,6 +32,15 @@ describe RHC::Commands::GitClone do
|
|
32
32
|
describe 'git-clone' do
|
33
33
|
let(:arguments) { ['app', 'git-clone', 'app1'] }
|
34
34
|
|
35
|
+
context 'when run without git installed' do
|
36
|
+
before do
|
37
|
+
@instance.stub(:has_git?) { false }
|
38
|
+
end
|
39
|
+
it "should print out git warning" do
|
40
|
+
run_output.should match("You do not have git installed")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
35
44
|
context "stubbing git_clone_repo" do
|
36
45
|
context "reports success successfully" do
|
37
46
|
before do
|
data/spec/rhc/helpers_spec.rb
CHANGED
@@ -269,6 +269,12 @@ describe AllRhcHelpers do
|
|
269
269
|
before{ subject.stub(:git_version){ raise "Fake Exception" } }
|
270
270
|
its(:has_git?) { should be_false }
|
271
271
|
|
272
|
+
context "without git" do
|
273
|
+
before{ subject.stub(:git_cmd){ "nonexistent_git" } }
|
274
|
+
its(:has_git?) { should be_false }
|
275
|
+
it { subject.git_config_get('key').should == nil }
|
276
|
+
end
|
277
|
+
|
272
278
|
context "git clone repo" do
|
273
279
|
let(:stdout){ 'fake git clone' }
|
274
280
|
let(:exit_status){ 0 }
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rhc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 91
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
8
|
+
- 18
|
9
|
+
- 2
|
10
|
+
version: 1.18.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Red Hat
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2013-12-
|
18
|
+
date: 2013-12-11 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: net-ssh
|