bosh_cli 1.2982.0 → 1.2983.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6f9901f35b38a8d19557f025c539b6429ad6d1cb
4
- data.tar.gz: c0b59a2d9ddfa2d1c5827d3cb899eb97cf278b27
3
+ metadata.gz: ebcf2ddd1601fd0a009078c3b52f043df2c81969
4
+ data.tar.gz: 3e9306e4515ddd0dd38cc8da3a31028b6d6e42ab
5
5
  SHA512:
6
- metadata.gz: f80da0368d9d91d331e37d0c225e250a287e9881a7ea5f587158487149a0e1bc1c16c34f4ecfdb9f401d5ee7eb8b2f48fe475d2289e5742865446de18ff75336
7
- data.tar.gz: 08a5c19f09873e03bf20b6208330ca167549d248387df76d813746c92d672ef3c1f070c337cc91f543e4c42af5a4298f2e8c17932bbfdf1fbf0a98fbe30168bb
6
+ metadata.gz: 5634530f84e9f3e1c06f28d3d3b3f6b223077a81e4cbb4b55f0daae9ed5b256379d149031365070db740b1d013c9bd3c43e3f945c0ce507d553b71158ac1ce98
7
+ data.tar.gz: 93545f71bc76fc460cad14e07122075340840220adc2f7433f466d2e2362dfc8369d2c29432f4b07edbf6dcdd5248cea51e3ca0f120ec4217733df3bea69abbd
@@ -40,7 +40,7 @@ module Bosh::Cli
40
40
 
41
41
  def director
42
42
  @director ||= Bosh::Cli::Client::Director.new(
43
- target, credentials, @options.select { |k, _| k == :no_track })
43
+ target, credentials, @options.select { |k, _| k == :no_track })
44
44
  end
45
45
 
46
46
  def release
@@ -62,7 +62,7 @@ module Bosh::Cli
62
62
  end
63
63
 
64
64
  def logged_in?
65
- !!(credentials)
65
+ !!(credentials && credentials.authorization_header)
66
66
  end
67
67
 
68
68
  def non_interactive?
@@ -92,6 +92,7 @@ module Bosh::Cli
92
92
  url = config.resolve_alias(:target, raw_url) || raw_url
93
93
  url ? normalize_url(url) : nil
94
94
  end
95
+
95
96
  alias_method :target_url, :target
96
97
 
97
98
  # @return [String] Deployment manifest path
@@ -100,153 +101,154 @@ module Bosh::Cli
100
101
  end
101
102
 
102
103
  def credentials
103
- auth_token = uaa_token_provider.token
104
- return Client::UaaCredentials.new(auth_token) if auth_token
105
-
106
- if username && password
107
- return Client::BasicCredentials.new(username, password)
108
- end
109
-
110
- nil
111
- end
104
+ return @credentials if @credentials
112
105
 
113
- def uaa_token_provider
114
- @uaa_token_provider ||= begin
115
- director_client = Client::Director.new(target)
116
- auth_info = Client::Uaa::AuthInfo.new(director_client, ENV, config.ca_cert(target))
106
+ if auth_info.uaa?
117
107
  token_decoder = Client::Uaa::TokenDecoder.new
118
- Client::Uaa::TokenProvider.new(auth_info, config, token_decoder, target)
108
+ uaa_token_provider = Client::Uaa::TokenProvider.new(auth_info, config, token_decoder, target)
109
+ @credentials = Client::UaaCredentials.new(uaa_token_provider)
110
+ elsif username && password
111
+ @credentials = Client::BasicCredentials.new(username, password)
119
112
  end
120
- end
121
113
 
122
- def target_name
123
- options[:target] || config.target_name || target_url
114
+ @credentials
124
115
  end
125
116
 
126
- def cache_dir
127
- File.join(Dir.home, '.bosh', 'cache')
128
- end
117
+ def target_name
118
+ options[:target] || config.target_name || target_url
119
+ end
129
120
 
130
- protected
121
+ def cache_dir
122
+ File.join(Dir.home, '.bosh', 'cache')
123
+ end
131
124
 
132
- # @return [String] Director username
133
- def username
134
- options[:username] || ENV['BOSH_USER'] || config.username(target)
135
- end
125
+ protected
136
126
 
137
- # @return [String] Director password
138
- def password
139
- options[:password] || ENV['BOSH_PASSWORD'] || config.password(target)
127
+ def auth_info
128
+ @auth_info ||= begin
129
+ director_client = Client::Director.new(target)
130
+ Client::Uaa::AuthInfo.new(director_client, ENV, config.ca_cert(target))
140
131
  end
132
+ end
141
133
 
142
- # Prints director task completion report. Note that event log usually
143
- # contains pretty detailed error report and other UI niceties, so most
144
- # of the time this could just do nothing
145
- # @param [Symbol] status Task status
146
- # @param [#to_s] task_id Task ID
147
- def task_report(status, task_id, success_msg = nil, error_msg = nil)
148
- case status
149
- when :non_trackable
150
- report = "Can't track director task".make_red
151
- when :track_timeout
152
- report = 'Task tracking timeout'.make_red
153
- when :running
154
- report = "Task #{task_id.make_yellow} running"
155
- when :error
156
- report = error_msg
157
- when :done
158
- report = success_msg
159
- else
160
- report = "Task exited with status #{status}"
161
- end
134
+ # @return [String] Director username
135
+ def username
136
+ options[:username] || ENV['BOSH_USER'] || config.username(target)
137
+ end
162
138
 
163
- unless [:running, :done].include?(status)
164
- @exit_code = 1
165
- end
139
+ # @return [String] Director password
140
+ def password
141
+ options[:password] || ENV['BOSH_PASSWORD'] || config.password(target)
142
+ end
166
143
 
167
- say("\n#{report}") if report
168
- say("\nFor a more detailed error report, run: bosh task #{task_id} --debug") if status == :error
144
+ # Prints director task completion report. Note that event log usually
145
+ # contains pretty detailed error report and other UI niceties, so most
146
+ # of the time this could just do nothing
147
+ # @param [Symbol] status Task status
148
+ # @param [#to_s] task_id Task ID
149
+ def task_report(status, task_id, success_msg = nil, error_msg = nil)
150
+ case status
151
+ when :non_trackable
152
+ report = "Can't track director task".make_red
153
+ when :track_timeout
154
+ report = 'Task tracking timeout'.make_red
155
+ when :running
156
+ report = "Task #{task_id.make_yellow} running"
157
+ when :error
158
+ report = error_msg
159
+ when :done
160
+ report = success_msg
161
+ else
162
+ report = "Task exited with status #{status}"
169
163
  end
170
164
 
171
- def auth_required
172
- target_required
173
- err('Please log in first') unless logged_in?
165
+ unless [:running, :done].include?(status)
166
+ @exit_code = 1
174
167
  end
175
168
 
176
- def target_required
177
- err('Please choose target first') if target.nil?
178
- end
169
+ say("\n#{report}") if report
170
+ say("\nFor a more detailed error report, run: bosh task #{task_id} --debug") if status == :error
171
+ end
179
172
 
180
- def deployment_required
181
- err('Please choose deployment first') if deployment.nil?
182
- end
173
+ def auth_required
174
+ target_required
175
+ err('Please log in first') unless logged_in?
176
+ end
183
177
 
184
- def show_deployment
185
- say("Current deployment is #{deployment.make_green}")
186
- end
178
+ def target_required
179
+ err('Please choose target first') if target.nil?
180
+ end
187
181
 
188
- def no_track_unsupported
189
- if @options.delete(:no_track)
190
- say('Ignoring `' + '--no-track'.make_yellow + "' option")
191
- end
192
- end
182
+ def deployment_required
183
+ err('Please choose deployment first') if deployment.nil?
184
+ end
193
185
 
194
- def check_if_release_dir
195
- unless in_release_dir?
196
- err("Sorry, your current directory doesn't look like release directory")
197
- end
198
- end
186
+ def show_deployment
187
+ say("Current deployment is #{deployment.make_green}")
188
+ end
199
189
 
200
- def raise_dirty_state_error
201
- say("\n%s\n" % [`git status`])
202
- err('Your current directory has some local modifications, ' +
203
- "please discard or commit them first.\n\n" +
204
- 'Use the --force option to skip this check.')
190
+ def no_track_unsupported
191
+ if @options.delete(:no_track)
192
+ say('Ignoring `' + '--no-track'.make_yellow + "' option")
205
193
  end
194
+ end
206
195
 
207
- def in_release_dir?
208
- File.directory?('packages') &&
209
- File.directory?('jobs') &&
210
- File.directory?('src')
196
+ def check_if_release_dir
197
+ unless in_release_dir?
198
+ err("Sorry, your current directory doesn't look like release directory")
211
199
  end
200
+ end
212
201
 
213
- def dirty_state?
214
- git_status = `git status 2>&1`
215
- case $?.exitstatus
216
- when 128 # Not in a git repo
217
- false
218
- when 127 # git command not found
219
- false
220
- else
221
- !git_status.lines.to_a.last.include?('nothing to commit')
222
- end
223
- end
202
+ def raise_dirty_state_error
203
+ say("\n%s\n" % [`git status`])
204
+ err('Your current directory has some local modifications, ' +
205
+ "please discard or commit them first.\n\n" +
206
+ 'Use the --force option to skip this check.')
207
+ end
208
+
209
+ def in_release_dir?
210
+ File.directory?('packages') &&
211
+ File.directory?('jobs') &&
212
+ File.directory?('src')
213
+ end
224
214
 
225
- def valid_index_for(job, index, options = {})
226
- index = '0' if job_unique_in_deployment?(job)
227
- err('You should specify the job index. There is more than one instance of this job type.') if index.nil?
228
- index = index.to_i if options[:integer_index]
229
- index
215
+ def dirty_state?
216
+ git_status = `git status 2>&1`
217
+ case $?.exitstatus
218
+ when 128 # Not in a git repo
219
+ false
220
+ when 127 # git command not found
221
+ false
222
+ else
223
+ !git_status.lines.to_a.last.include?('nothing to commit')
230
224
  end
225
+ end
231
226
 
232
- def normalize_url(url)
233
- url = url.gsub(/\/$/, '')
234
- url = "https://#{url}" unless url.match(/^http:?/)
235
- uri = URI.parse(url)
227
+ def valid_index_for(job, index, options = {})
228
+ index = '0' if job_unique_in_deployment?(job)
229
+ err('You should specify the job index. There is more than one instance of this job type.') if index.nil?
230
+ index = index.to_i if options[:integer_index]
231
+ index
232
+ end
236
233
 
237
- if port = url.match(/:(\d+)$/)
238
- port_number = port.captures[0].to_i
239
- if port_number == URI::HTTPS::DEFAULT_PORT
240
- uri.to_s + ":#{URI::HTTPS::DEFAULT_PORT}"
241
- else
242
- uri.port = port_number
243
- uri.to_s
244
- end
234
+ def normalize_url(url)
235
+ url = url.gsub(/\/$/, '')
236
+ url = "https://#{url}" unless url.match(/^http:?/)
237
+ uri = URI.parse(url)
238
+
239
+ if port = url.match(/:(\d+)$/)
240
+ port_number = port.captures[0].to_i
241
+ if port_number == URI::HTTPS::DEFAULT_PORT
242
+ uri.to_s + ":#{URI::HTTPS::DEFAULT_PORT}"
245
243
  else
246
- uri.port = DEFAULT_DIRECTOR_PORT
244
+ uri.port = port_number
247
245
  uri.to_s
248
246
  end
247
+ else
248
+ uri.port = DEFAULT_DIRECTOR_PORT
249
+ uri.to_s
249
250
  end
250
251
  end
251
252
  end
252
253
  end
254
+ end
@@ -2,12 +2,12 @@ module Bosh
2
2
  module Cli
3
3
  module Client
4
4
  class UaaCredentials
5
- def initialize(token)
6
- @token = token
5
+ def initialize(token_provider)
6
+ @token_provider = token_provider
7
7
  end
8
8
 
9
9
  def authorization_header
10
- @token
10
+ @token_provider.token
11
11
  end
12
12
  end
13
13
 
@@ -16,6 +16,13 @@ module Bosh
16
16
  end
17
17
 
18
18
  def client_auth?
19
+ if @client_id.nil? && !@client_secret.nil?
20
+ raise ValidationError.new('BOSH_CLIENT is missing')
21
+ end
22
+ if @client_secret.nil? && !@client_id.nil?
23
+ raise ValidationError.new('BOSH_CLIENT_SECRET is missing')
24
+ end
25
+
19
26
  !@client_id.nil? && !@client_secret.nil?
20
27
  end
21
28
 
@@ -24,15 +31,15 @@ module Bosh
24
31
  end
25
32
 
26
33
  def url
27
- auth_info.fetch('options', {}).fetch('url', nil)
28
- end
29
-
30
- def validate!
31
- return unless uaa?
34
+ url = auth_info.fetch('options', {}).fetch('url', nil)
32
35
 
33
- unless URI.parse(url).instance_of?(URI::HTTPS)
34
- raise ValidationError.new('HTTPS protocol is required')
36
+ if url
37
+ unless URI.parse(url).instance_of?(URI::HTTPS)
38
+ raise ValidationError.new('HTTPS protocol is required')
39
+ end
35
40
  end
41
+
42
+ url
36
43
  end
37
44
 
38
45
  private
@@ -15,8 +15,6 @@ module Bosh
15
15
  end
16
16
 
17
17
  def access_info(_)
18
- @auth_info.validate!
19
-
20
18
  token = token_issuer.client_credentials_grant
21
19
  ClientAccessInfo.new(token, @token_decoder)
22
20
  end
@@ -1,5 +1,5 @@
1
1
  module Bosh
2
2
  module Cli
3
- VERSION = '1.2982.0'
3
+ VERSION = '1.2983.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2982.0
4
+ version: 1.2983.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - VMware
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-10 00:00:00.000000000 Z
11
+ date: 2015-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bosh_common
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.2982.0
19
+ version: 1.2983.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.2982.0
26
+ version: 1.2983.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bosh-template
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.2982.0
33
+ version: 1.2983.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.2982.0
40
+ version: 1.2983.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: cf-uaa-lib
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 1.2982.0
131
+ version: 1.2983.0
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 1.2982.0
138
+ version: 1.2983.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: net-ssh
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -306,7 +306,7 @@ dependencies:
306
306
  version: '0'
307
307
  description: |-
308
308
  BOSH CLI
309
- 30e5c6
309
+ 71d152
310
310
  email: support@cloudfoundry.com
311
311
  executables:
312
312
  - bosh