378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
|
# File 'lib/cf/cli.rb', line 378
def client(target = client_target)
return @@client if defined?(@@client) && @@client
return unless target
info = target_info(target)
token = info[:token] && CFoundry::AuthToken.from_hash(info)
fail "V1 targets are no longer supported." if info[:version] == 1
@@client = CFoundry::V2::Client.new(target, token)
@@client.http_proxy = input[:http_proxy] || ENV['HTTP_PROXY'] || ENV['http_proxy']
@@client.https_proxy = input[:https_proxy] || ENV['HTTPS_PROXY'] || ENV['https_proxy']
@@client.trace = input[:trace]
uri = URI.parse(target)
@@client.log = File.expand_path("#{LOGS_DIR}/#{uri.host}.log")
unless info.key? :version
info[:version] = @@client.version
save_target_info(info, target)
end
if (org = info[:organization])
@@client.current_organization = @@client.organization(org)
end
if (space = info[:space])
@@client.current_space = @@client.space(space)
end
@@client
rescue CFoundry::InvalidTarget
end
|