rhc 1.2.7 → 1.3.8
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/rhc +6 -8
- data/bin/rhc-chk +23 -10
- data/features/domain.feature +1 -1
- data/features/lib/rhc_helper.rb +3 -2
- data/features/lib/rhc_helper/api.rb +7 -0
- data/features/lib/rhc_helper/app.rb +8 -10
- data/features/lib/rhc_helper/domain.rb +2 -1
- data/features/lib/rhc_helper/runnable.rb +2 -24
- data/features/sshkey.feature +3 -3
- data/features/step_definitions/cartridge_steps.rb +6 -6
- data/features/step_definitions/client_steps.rb +0 -1
- data/features/step_definitions/sshkey_steps.rb +2 -2
- data/features/support/before_hooks.rb +0 -1
- data/features/support/env.rb +5 -3
- data/lib/rhc-common.rb +1 -1
- data/lib/rhc.rb +9 -8
- data/lib/rhc/auth.rb +3 -0
- data/lib/rhc/auth/basic.rb +54 -0
- data/lib/rhc/cartridge_helpers.rb +11 -5
- data/lib/rhc/cli.rb +4 -2
- data/lib/rhc/command_runner.rb +35 -30
- data/lib/rhc/commands.rb +127 -18
- data/lib/rhc/commands/account.rb +24 -0
- data/lib/rhc/commands/alias.rb +1 -1
- data/lib/rhc/commands/app.rb +210 -209
- data/lib/rhc/commands/apps.rb +22 -0
- data/lib/rhc/commands/base.rb +10 -77
- data/lib/rhc/commands/cartridge.rb +35 -35
- data/lib/rhc/commands/domain.rb +20 -13
- data/lib/rhc/commands/git_clone.rb +30 -0
- data/lib/rhc/commands/{port-forward.rb → port_forward.rb} +3 -3
- data/lib/rhc/commands/server.rb +28 -16
- data/lib/rhc/commands/setup.rb +18 -1
- data/lib/rhc/commands/snapshot.rb +4 -4
- data/lib/rhc/commands/sshkey.rb +4 -18
- data/lib/rhc/commands/tail.rb +32 -9
- data/lib/rhc/config.rb +168 -99
- data/lib/rhc/context_helper.rb +22 -9
- data/lib/rhc/core_ext.rb +41 -1
- data/lib/rhc/exceptions.rb +21 -5
- data/lib/rhc/git_helpers.rb +81 -0
- data/lib/rhc/help_formatter.rb +21 -1
- data/lib/rhc/helpers.rb +222 -87
- data/lib/rhc/output_helpers.rb +94 -110
- data/lib/rhc/rest.rb +15 -198
- data/lib/rhc/rest/api.rb +88 -0
- data/lib/rhc/rest/application.rb +29 -30
- data/lib/rhc/rest/attributes.rb +27 -0
- data/lib/rhc/rest/base.rb +29 -33
- data/lib/rhc/rest/cartridge.rb +42 -20
- data/lib/rhc/rest/client.rb +351 -89
- data/lib/rhc/rest/domain.rb +7 -13
- data/lib/rhc/rest/gear_group.rb +1 -1
- data/lib/rhc/rest/key.rb +7 -2
- data/lib/rhc/rest/mock.rb +609 -0
- data/lib/rhc/rest/user.rb +6 -2
- data/lib/rhc/{ssh_key_helpers.rb → ssh_helpers.rb} +58 -28
- data/lib/rhc/{targz.rb → tar_gz.rb} +0 -0
- data/lib/rhc/usage_templates/command_help.erb +4 -1
- data/lib/rhc/usage_templates/help.erb +24 -11
- data/lib/rhc/usage_templates/options_help.erb +14 -0
- data/lib/rhc/wizard.rb +283 -213
- data/spec/keys/example.pem +23 -0
- data/spec/keys/example_private.pem +27 -0
- data/spec/keys/server.pem +19 -0
- data/spec/rest_spec_helper.rb +3 -371
- data/spec/rhc/auth_spec.rb +226 -0
- data/spec/rhc/cli_spec.rb +41 -14
- data/spec/rhc/command_spec.rb +44 -15
- data/spec/rhc/commands/account_spec.rb +41 -0
- data/spec/rhc/commands/alias_spec.rb +16 -15
- data/spec/rhc/commands/app_spec.rb +115 -92
- data/spec/rhc/commands/apps_spec.rb +39 -0
- data/spec/rhc/commands/cartridge_spec.rb +134 -112
- data/spec/rhc/commands/domain_spec.rb +31 -86
- data/spec/rhc/commands/git_clone_spec.rb +56 -0
- data/spec/rhc/commands/{port-forward_spec.rb → port_forward_spec.rb} +27 -32
- data/spec/rhc/commands/server_spec.rb +28 -3
- data/spec/rhc/commands/setup_spec.rb +29 -11
- data/spec/rhc/commands/snapshot_spec.rb +4 -3
- data/spec/rhc/commands/sshkey_spec.rb +24 -56
- data/spec/rhc/commands/tail_spec.rb +26 -9
- data/spec/rhc/commands/threaddump_spec.rb +12 -11
- data/spec/rhc/config_spec.rb +211 -164
- data/spec/rhc/context_spec.rb +2 -0
- data/spec/rhc/helpers_spec.rb +242 -46
- data/spec/rhc/rest_application_spec.rb +42 -28
- data/spec/rhc/rest_client_spec.rb +110 -93
- data/spec/rhc/rest_spec.rb +220 -131
- data/spec/rhc/targz_spec.rb +1 -1
- data/spec/rhc/wizard_spec.rb +435 -624
- data/spec/spec.opts +1 -1
- data/spec/spec_helper.rb +140 -6
- data/spec/wizard_spec_helper.rb +326 -0
- metadata +163 -143
- data/lib/rhc/client.rb +0 -17
- data/lib/rhc/git_helper.rb +0 -59
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rhc/commands/base'
|
2
|
+
|
3
|
+
module RHC::Commands
|
4
|
+
class Apps < Base
|
5
|
+
summary "List all your applications"
|
6
|
+
description "Display the list of applications that you own. Includes information about each application."
|
7
|
+
def run
|
8
|
+
domains = rest_client.domains
|
9
|
+
|
10
|
+
info "In order to deploy applications, you must create a domain with 'rhc setup' or 'rhc domain create'." and return 1 if domains.empty?
|
11
|
+
|
12
|
+
applications = domains.map{ |d| d.applications(:include => :cartridges) }.flatten.sort
|
13
|
+
|
14
|
+
applications.each{ |a| display_app(a, a.cartridges) }.blank? and
|
15
|
+
info "No applications. Use 'rhc app create'." and
|
16
|
+
return 1
|
17
|
+
|
18
|
+
success "You have #{applications.length} applications"
|
19
|
+
0
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/rhc/commands/base.rb
CHANGED
@@ -10,58 +10,10 @@ require 'rhc/context_helper'
|
|
10
10
|
class RHC::Commands::Base
|
11
11
|
|
12
12
|
attr_writer :options, :config
|
13
|
-
attr_reader :messages
|
14
13
|
|
15
14
|
def initialize(options=Commander::Command::Options.new,
|
16
|
-
config=
|
15
|
+
config=RHC::Config.new)
|
17
16
|
@options, @config = options, config
|
18
|
-
@messages = []
|
19
|
-
end
|
20
|
-
|
21
|
-
def validate_args_and_options(args_metadata, options_metadata, args)
|
22
|
-
# process options
|
23
|
-
options_metadata.each do |option_meta|
|
24
|
-
arg = option_meta[:arg]
|
25
|
-
|
26
|
-
# Check to see if we've provided a value for an option tagged as deprecated
|
27
|
-
if (!(val = @options.__hash__[arg]).nil? && dep_info = option_meta[:deprecated])
|
28
|
-
# Get the arg for the correct option and what the value should be
|
29
|
-
(correct_arg, default) = dep_info.values_at(:key, :value)
|
30
|
-
# Set the default value for the correct option to the passed value
|
31
|
-
## Note: If this isn't triggered, then the original default will be honored
|
32
|
-
## If the user specifies any value for the correct option, it will be used
|
33
|
-
options.default correct_arg => default
|
34
|
-
# Alert the users if they're using a deprecated option
|
35
|
-
(correct, incorrect) = [options_metadata.find{|x| x[:arg] == correct_arg },option_meta].flatten.map{|x| x[:switches].join(", ") }
|
36
|
-
deprecated_option(incorrect, correct)
|
37
|
-
end
|
38
|
-
|
39
|
-
context_helper = option_meta[:context_helper]
|
40
|
-
|
41
|
-
@options.__hash__[arg] = self.send(context_helper) if @options.__hash__[arg].nil? and context_helper
|
42
|
-
raise ArgumentError.new("Missing required option '#{arg}'.") if option_meta[:required] and @options.__hash__[arg].nil?
|
43
|
-
end
|
44
|
-
|
45
|
-
# process args
|
46
|
-
arg_slots = [].fill(nil, 0, args_metadata.length)
|
47
|
-
fill_args = args.reverse
|
48
|
-
args_metadata.each_with_index do |arg_meta, i|
|
49
|
-
# check options
|
50
|
-
value = @options.__hash__[arg_meta[:option_symbol]] unless arg_meta[:option_symbol].nil?
|
51
|
-
if value
|
52
|
-
arg_slots[i] = value
|
53
|
-
elsif arg_meta[:arg_type] == :list
|
54
|
-
arg_slots[i] = fill_args.reverse
|
55
|
-
fill_args = []
|
56
|
-
else
|
57
|
-
raise ArgumentError.new("Missing required argument '#{arg_meta[:name]}'.") if fill_args.empty?
|
58
|
-
arg_slots[i] = fill_args.pop
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
raise ArgumentError.new("Too many arguments passed in: #{fill_args.reverse.join(" ")}") unless fill_args.empty?
|
63
|
-
|
64
|
-
arg_slots
|
65
17
|
end
|
66
18
|
|
67
19
|
protected
|
@@ -70,23 +22,6 @@ class RHC::Commands::Base
|
|
70
22
|
|
71
23
|
attr_reader :options, :config
|
72
24
|
|
73
|
-
#
|
74
|
-
# The implicit config object provides no defaults.
|
75
|
-
#
|
76
|
-
def config
|
77
|
-
@config ||= begin
|
78
|
-
RHC::Config.new
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def application
|
83
|
-
#@application ||= ... identify current application or throw,
|
84
|
-
# indicating one is needed. Should check
|
85
|
-
# options (commands which have it as an ARG
|
86
|
-
# should set it onto options), then check
|
87
|
-
# current git repo for remote, fail.
|
88
|
-
end
|
89
|
-
|
90
25
|
# Return a client object capable of making calls
|
91
26
|
# to the OpenShift API that transforms intent
|
92
27
|
# and options, to remote calls, and then handle
|
@@ -94,16 +29,7 @@ class RHC::Commands::Base
|
|
94
29
|
# formatted object output. Most interactions
|
95
30
|
# should be through this call pattern.
|
96
31
|
def rest_client
|
97
|
-
@rest_client ||=
|
98
|
-
username = config.username
|
99
|
-
unless username
|
100
|
-
username = ask "Login to #{openshift_server}: "
|
101
|
-
config.config_user(username)
|
102
|
-
end
|
103
|
-
config.password = config.password || RHC::get_password
|
104
|
-
|
105
|
-
RHC::Rest::Client.new(openshift_rest_node, username, config.password, @options.debug)
|
106
|
-
end
|
32
|
+
@rest_client ||= client_from_options(:auth => RHC::Auth::Basic.new(options))
|
107
33
|
end
|
108
34
|
|
109
35
|
def help(*args)
|
@@ -149,7 +75,13 @@ class RHC::Commands::Base
|
|
149
75
|
end
|
150
76
|
|
151
77
|
def self.description(*args)
|
152
|
-
|
78
|
+
o = args.join(' ')
|
79
|
+
indent = o.scan(/^[ \t]*(?=\S)/).min.size || 0
|
80
|
+
options[:description] =
|
81
|
+
o.gsub(/^[ \t]{#{indent}}/, '').
|
82
|
+
gsub(/(\b)\s*\n(?!\s*\n)(\S)/m, '\1 \2').
|
83
|
+
gsub(/\n+\Z/, '').
|
84
|
+
gsub(/\n{3,}/, "\n\n")
|
153
85
|
end
|
154
86
|
def self.summary(value)
|
155
87
|
options[:summary] = value
|
@@ -196,6 +128,7 @@ class RHC::Commands::Base
|
|
196
128
|
args_metadata << {:name => name,
|
197
129
|
:description => description,
|
198
130
|
:switches => switches,
|
131
|
+
:context_helper => options[:context],
|
199
132
|
:option_symbol => option_symbol,
|
200
133
|
:arg_type => arg_type}
|
201
134
|
end
|
@@ -8,27 +8,29 @@ module RHC::Commands
|
|
8
8
|
alias_action :"app cartridge", :root_command => true, :deprecated => true
|
9
9
|
default_action :list
|
10
10
|
|
11
|
-
summary "List
|
11
|
+
summary "List available cartridges"
|
12
|
+
option ["-v", "--verbose"], "Display more details about each cartridge"
|
12
13
|
alias_action :"app cartridge list", :root_command => true, :deprecated => true
|
13
14
|
def list
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
|
15
|
+
carts = rest_client.cartridges.sort_by{ |c| "#{c.type == 'standalone' && 1}_#{c.tags.include?('experimental') ? 1 : 0}_#{(c.display_name || c.name).downcase}" }
|
16
|
+
|
17
|
+
list = if options.verbose
|
18
|
+
carts.map do |c|
|
19
|
+
name = c.display_name != c.name && "#{color(c.display_name, :cyan)} [#{c.name}]" || c.name
|
20
|
+
tags = c.tags - RHC::Rest::Cartridge::HIDDEN_TAGS
|
21
|
+
[
|
22
|
+
underline("#{name} (#{c.only_in_new? ? 'web' : 'addon'})"),
|
23
|
+
c.description,
|
24
|
+
tags.present? ? "\nTagged with: #{tags.sort.join(', ')}" : nil,
|
25
|
+
].compact << "\n"
|
26
|
+
end.flatten
|
27
|
+
else
|
28
|
+
table(carts.map{ |c| [c.name, c.display_name, c.only_in_new? ? 'web' : 'addon'] })
|
29
|
+
end
|
28
30
|
|
29
|
-
paragraph{ say "Use the short name of a cartridge when interacting with your applications." }
|
30
31
|
|
31
|
-
say
|
32
|
+
say list.join("\n")
|
33
|
+
paragraph{ say "Note: Web cartridges can only be added to new applications." }
|
32
34
|
|
33
35
|
0
|
34
36
|
end
|
@@ -42,14 +44,17 @@ module RHC::Commands
|
|
42
44
|
def add(cart_type)
|
43
45
|
cart = find_cartridge rest_client, cart_type
|
44
46
|
|
45
|
-
say "Adding
|
47
|
+
say "Adding #{cart.name} to application '#{options.app}' ... "
|
46
48
|
|
47
49
|
rest_domain = rest_client.find_domain(options.namespace)
|
48
50
|
rest_app = rest_domain.find_application(options.app)
|
49
51
|
rest_cartridge = rest_app.add_cartridge(cart.name)
|
50
|
-
say "Success"
|
51
52
|
|
52
|
-
|
53
|
+
success "Success"
|
54
|
+
|
55
|
+
paragraph{ display_cart(rest_cartridge) }
|
56
|
+
|
57
|
+
results{ rest_cartridge.messages.each { |msg| success msg } }
|
53
58
|
|
54
59
|
0
|
55
60
|
end
|
@@ -64,7 +69,7 @@ module RHC::Commands
|
|
64
69
|
rest_app = rest_domain.find_application(options.app)
|
65
70
|
rest_cartridge = find_cartridge rest_app, cartridge, nil
|
66
71
|
|
67
|
-
display_cart(rest_cartridge
|
72
|
+
display_cart(rest_cartridge)
|
68
73
|
|
69
74
|
0
|
70
75
|
end
|
@@ -74,20 +79,20 @@ module RHC::Commands
|
|
74
79
|
argument :cartridge, "The name of the cartridge you are removing", ["-c", "--cartridge cartridge"]
|
75
80
|
option ["-n", "--namespace namespace"], "Namespace of the application you are removing the cartridge from", :context => :namespace_context, :required => true
|
76
81
|
option ["-a", "--app app"], "Application you are removing the cartridge from", :context => :app_context, :required => true
|
77
|
-
option ["--confirm"], "
|
82
|
+
option ["--confirm"], "Pass to confirm removing the cartridge"
|
78
83
|
alias_action :"app cartridge remove", :root_command => true, :deprecated => true
|
79
84
|
def remove(cartridge)
|
80
|
-
unless options.confirm
|
81
|
-
results { say "Removing a cartridge is a destructive operation that may result in loss of data associated with the cartridge. You must pass the --confirm switch to this command in order to to remove the cartridge." }
|
82
|
-
return 1
|
83
|
-
end
|
84
85
|
|
85
86
|
rest_domain = rest_client.find_domain(options.namespace)
|
86
87
|
rest_app = rest_domain.find_application(options.app)
|
87
88
|
rest_cartridge = rest_app.find_cartridge cartridge, :type => "embedded"
|
89
|
+
|
90
|
+
confirm_action "Removing a cartridge is a destructive operation that may result in loss of data associated with the cartridge.\n\nAre you sure you wish to remove #{rest_cartridge.name} from '#{rest_app.name}'?"
|
91
|
+
|
92
|
+
say "Removing #{rest_cartridge.name} from '#{rest_app.name}' ... "
|
88
93
|
rest_cartridge.destroy
|
94
|
+
success "removed"
|
89
95
|
|
90
|
-
results { say "Success: Cartridge '#{rest_cartridge.name}' removed from application '#{rest_app.name}'." }
|
91
96
|
0
|
92
97
|
end
|
93
98
|
|
@@ -140,12 +145,7 @@ module RHC::Commands
|
|
140
145
|
rest_domain = rest_client.find_domain(options.namespace)
|
141
146
|
rest_app = rest_domain.find_application(options.app)
|
142
147
|
rest_cartridge = find_cartridge(rest_app, cartridge)
|
143
|
-
|
144
|
-
results {
|
145
|
-
msgs.each do |msg|
|
146
|
-
say msg['message']
|
147
|
-
end
|
148
|
-
}
|
148
|
+
results { rest_cartridge.status.each{ |msg| say msg['message'] } }
|
149
149
|
0
|
150
150
|
end
|
151
151
|
|
@@ -184,8 +184,8 @@ module RHC::Commands
|
|
184
184
|
})
|
185
185
|
|
186
186
|
results do
|
187
|
-
|
188
|
-
|
187
|
+
paragraph{ display_cart(cart) }
|
188
|
+
success "Success: Scaling values updated"
|
189
189
|
end
|
190
190
|
|
191
191
|
0
|
data/lib/rhc/commands/domain.rb
CHANGED
@@ -41,28 +41,35 @@ module RHC::Commands
|
|
41
41
|
0
|
42
42
|
end
|
43
43
|
|
44
|
-
summary "Display
|
44
|
+
summary "Display your domain and any applications"
|
45
45
|
def show
|
46
46
|
domain = rest_client.domains.first
|
47
47
|
|
48
|
-
|
48
|
+
warn "In order to deploy applications, you must create a domain with 'rhc setup' or 'rhc domain create'." and return 1 unless domain
|
49
|
+
|
50
|
+
applications = domain.applications(:include => :cartridges)
|
51
|
+
|
52
|
+
if applications.present?
|
53
|
+
header "Applications in #{domain.id} domain" do
|
54
|
+
applications.each do |a|
|
55
|
+
display_app(a,a.cartridges)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
success "You have #{applications.length} applications in your domain."
|
59
|
+
else
|
60
|
+
success "The domain #{domain.id} exists but has no applications. You can use 'rhc app create' to create a new application."
|
61
|
+
end
|
49
62
|
|
50
63
|
0
|
51
64
|
end
|
52
65
|
|
53
|
-
summary "
|
66
|
+
summary "DEPRECATED use 'setup' instead"
|
67
|
+
deprecated 'rhc setup'
|
68
|
+
# :nocov:
|
54
69
|
def status
|
55
|
-
|
56
|
-
|
57
|
-
options.__hash__.each do |key, value|
|
58
|
-
value = value.to_s
|
59
|
-
if value.length > 0 && value.to_s.strip.length == 0; value = "'#{value}'" end
|
60
|
-
args << "--#{key} #{value}"
|
61
|
-
end
|
62
|
-
|
63
|
-
Kernel.system("rhc-chk #{args.join(' ')} 2>&1")
|
64
|
-
$?.exitstatus.nil? ? 1 : $?.exitstatus
|
70
|
+
1 # return error status
|
65
71
|
end
|
72
|
+
# :nocov:
|
66
73
|
|
67
74
|
summary "Deletes your domain."
|
68
75
|
syntax "<namespace>"
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rhc/commands/base'
|
2
|
+
require 'rhc/git_helpers'
|
3
|
+
|
4
|
+
module RHC::Commands
|
5
|
+
class GitClone < Base
|
6
|
+
summary "Clone and configure an application's repository locally"
|
7
|
+
description "This is a convenience wrapper for 'git clone' with the added",
|
8
|
+
"benefit of adding configuration data such as the application's",
|
9
|
+
"UUID to the local repository. It also automatically",
|
10
|
+
"figures out the git url from the application name so you don't",
|
11
|
+
"have to look it up."
|
12
|
+
syntax "<app> [--namespace namespace]"
|
13
|
+
option ["-n", "--namespace namespace"], "Namespace of the application", :context => :namespace_context, :required => true
|
14
|
+
option ["-r", "--repo dir"], "Path to the Git repository (defaults to ./$app_name)"
|
15
|
+
argument :app, "The application you wish to clone", ["-a", "--app name"]
|
16
|
+
alias_action 'app git-clone', :deprecated => true, :root_command => true
|
17
|
+
# TODO: Implement default values for arguments once ffranz has added context arguments
|
18
|
+
# argument :directory, "The name of a new directory to clone into", [], :default => nil
|
19
|
+
def run(app_name)
|
20
|
+
domain = rest_client.find_domain(options.namespace)
|
21
|
+
app = domain.find_application(app_name)
|
22
|
+
git_clone_application(app)
|
23
|
+
|
24
|
+
0
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
include RHC::GitHelpers
|
29
|
+
end
|
30
|
+
end
|
@@ -180,10 +180,10 @@ module RHC::Commands
|
|
180
180
|
raise RHC::PortForwardFailedException.new("#{e.message + "\n" if options.debug}Error trying to forward ports. You can try to forward manually by running:\n" + ssh_cmd.join(" "))
|
181
181
|
end
|
182
182
|
|
183
|
-
|
184
|
-
rescue
|
183
|
+
0
|
184
|
+
rescue RHC::Rest::ConnectionException => e
|
185
185
|
error "Connection to #{openshift_server} failed: #{e.message}"
|
186
|
-
|
186
|
+
1
|
187
187
|
end
|
188
188
|
end
|
189
189
|
end
|
data/lib/rhc/commands/server.rb
CHANGED
@@ -1,28 +1,40 @@
|
|
1
|
-
require 'rhc/commands/base'
|
2
|
-
|
3
1
|
module RHC::Commands
|
4
2
|
class Server < Base
|
5
3
|
suppress_wizard
|
6
4
|
|
7
5
|
summary "Display information about the status of the OpenShift service."
|
8
|
-
description
|
6
|
+
description <<-DESC
|
7
|
+
Retrieves any open issues or notices about the operation of the
|
8
|
+
OpenShift service and displays them in the order they were opened.
|
9
|
+
|
10
|
+
When connected to an OpenShift Enterprise server, will only display
|
11
|
+
the version of the API that it is connecting to.
|
12
|
+
DESC
|
9
13
|
def run
|
10
|
-
|
11
|
-
open = status['open']
|
14
|
+
say "Connected to #{openshift_server}"
|
12
15
|
|
13
|
-
|
16
|
+
if openshift_online_server?
|
17
|
+
#status = decode_json(get("#{openshift_url}/app/status/status.json").body)
|
18
|
+
status = rest_client.request(:method => :get, :url => "#{openshift_url}/app/status/status.json", :lazy_auth => true){ |res| decode_json(res.content) }
|
19
|
+
open = status['open']
|
14
20
|
|
15
|
-
|
16
|
-
i = i['issue']
|
17
|
-
say color("%-3s %s" % ["##{i['id']}", i['title']], :bold)
|
18
|
-
items = i['updates'].map{ |u| [u['description'], date(u['created_at'])] }
|
19
|
-
items.unshift ['Opened', date(i['created_at'])]
|
20
|
-
table(items, :align => [nil,:right], :join => ' ').each{ |s| say " #{s}" }
|
21
|
-
end
|
22
|
-
say "\n"
|
23
|
-
warn pluralize(open.length, "open issue")
|
21
|
+
(success 'All systems running fine' and return 0) if open.blank?
|
24
22
|
|
25
|
-
|
23
|
+
open.each do |i|
|
24
|
+
i = i['issue']
|
25
|
+
say color("%-3s %s" % ["##{i['id']}", i['title']], :bold)
|
26
|
+
items = i['updates'].map{ |u| [u['description'], date(u['created_at'])] }
|
27
|
+
items.unshift ['Opened', date(i['created_at'])]
|
28
|
+
table(items, :align => [nil,:right], :join => ' ').each{ |s| say " #{s}" }
|
29
|
+
end
|
30
|
+
say "\n"
|
31
|
+
warn pluralize(open.length, "open issue")
|
32
|
+
|
33
|
+
open.length #exit with the count of open items
|
34
|
+
else
|
35
|
+
success "Using API version #{rest_client.api_version_negotiated}"
|
36
|
+
0
|
37
|
+
end
|
26
38
|
end
|
27
39
|
end
|
28
40
|
end
|
data/lib/rhc/commands/setup.rb
CHANGED
@@ -6,7 +6,24 @@ module RHC::Commands
|
|
6
6
|
class Setup < Base
|
7
7
|
suppress_wizard
|
8
8
|
|
9
|
-
summary "
|
9
|
+
summary "Connects to OpenShift and sets up your keys and domain"
|
10
|
+
description <<-DESC
|
11
|
+
Connects to an OpenShift server to get you started. Will help you
|
12
|
+
configure your SSH keys, set up a domain, and check for any potential
|
13
|
+
problems with Git or SSH.
|
14
|
+
|
15
|
+
Any options you pass to the setup command will be stored in a
|
16
|
+
.openshift/express.conf file in your home directory. If you run
|
17
|
+
setup at a later time, any previous configuration will be reused.
|
18
|
+
|
19
|
+
|
20
|
+
Pass the --clean option to ignore your saved configuration and only
|
21
|
+
use options you pass on the command line. Pass --config FILE to use
|
22
|
+
default values from another config (the values will still be written
|
23
|
+
to .openshift/express.conf).
|
24
|
+
DESC
|
25
|
+
option ["--server NAME"], "Hostname of an OpenShift server", :context => :server_context, :required => true
|
26
|
+
option ['--clean'], "Ignore any saved configuration options"
|
10
27
|
def run
|
11
28
|
raise OptionParser::InvalidOption, "Setup can not be run with the --noprompt option" if options.noprompt
|
12
29
|
RHC::RerunWizard.new(config, options).run ? 0 : 1
|