Skip to content
This repository has been archived by the owner on Aug 29, 2018. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master' into use_http_client_auth
Browse files Browse the repository at this point in the history
Conflicts:
	spec/rhc/commands/logout_spec.rb
  • Loading branch information
smarterclayton committed Jul 16, 2013
2 parents b661845 + f3b9ab1 commit 7d19858
Show file tree
Hide file tree
Showing 29 changed files with 312 additions and 146 deletions.
64 changes: 44 additions & 20 deletions autocomplete/rhc_bash
Expand Up @@ -8,11 +8,11 @@ _rhc()
cur="${COMP_WORDS[COMP_CWORD]}"
if [ $COMP_CWORD -eq 1 ]; then
if [[ "$cur" == -* ]]; then
opts="--clean --config --debug --insecure --mock --noprompt --password --rhlogin --server --ssl-ca-file --ssl-client-cert-file --ssl-version --timeout --token"
opts="--always-prefix --clean --config --debug --insecure --limit --mock --noprompt --password --raw --rhlogin --server --ssl-ca-file --ssl-client-cert-file --ssl-version --timeout --token"
elif [ -z $cur ]; then
opts="account alias alias-add alias-delete-cert alias-list alias-remove alias-update-cert app app-create app-delete app-force-stop app-reload app-restart app-show app-ssh app-start app-stop app-tidy apps authorization authorization-add authorization-delete authorization-delete-all cartridge cartridge-add cartridge-list cartridge-reload cartridge-remove cartridge-restart cartridge-scale cartridge-show cartridge-start cartridge-status cartridge-stop cartridge-storage domain domain-create domain-delete domain-show domain-update git-clone logout port-forward server setup snapshot snapshot-restore snapshot-save sshkey sshkey-add sshkey-list sshkey-remove sshkey-show tail threaddump"
opts="account alias alias-add alias-delete-cert alias-list alias-remove alias-update-cert app app-create app-delete app-force-stop app-reload app-restart app-show app-start app-stop app-tidy apps authorization authorization-add authorization-delete authorization-delete-all authorization-list cartridge cartridge-add cartridge-list cartridge-reload cartridge-remove cartridge-restart cartridge-scale cartridge-show cartridge-start cartridge-status cartridge-stop cartridge-storage domain domain-create domain-delete domain-show domain-update git-clone logout port-forward server setup snapshot snapshot-restore snapshot-save ssh sshkey sshkey-add sshkey-list sshkey-remove sshkey-show tail threaddump"
else
opts="account account-logout add-alias add-authorization add-cartridge add-sshkey alias alias-add alias-delete-cert alias-list alias-remove alias-update-cert app app-create app-delete app-force-stop app-reload app-restart app-show app-snapshot app-ssh app-start app-stop app-tidy apps authorization authorization-add authorization-delete authorization-delete-all authorizations cartridge cartridge-add cartridge-list cartridge-reload cartridge-remove cartridge-restart cartridge-scale cartridge-show cartridge-start cartridge-status cartridge-stop cartridge-storage cartridges create-app create-domain delete-all-authorization delete-app delete-authorization delete-cert-alias delete-domain domain domain-create domain-delete domain-show domain-update force-stop-app git-clone list-alias list-cartridge list-sshkey logout port-forward reload-app reload-cartridge remove-alias remove-cartridge remove-sshkey restart-app restart-cartridge restore-snapshot save-snapshot scale-cartridge server setup show-app show-cartridge show-domain show-sshkey snapshot snapshot-restore snapshot-save ssh ssh-app sshkey sshkey-add sshkey-delete sshkey-list sshkey-remove sshkey-show start-app start-cartridge status-cartridge stop-app stop-cartridge storage-cartridge tail threaddump tidy-app update-cert-alias update-domain"
opts="account account-logout add-alias add-authorization add-cartridge add-sshkey alias alias-add alias-delete-cert alias-list alias-remove alias-update-cert aliases app app-create app-delete app-force-stop app-reload app-restart app-show app-snapshot app-ssh app-start app-stop app-tidy apps authorization authorization-add authorization-delete authorization-delete-all authorization-list authorizations cartridge cartridge-add cartridge-list cartridge-reload cartridge-remove cartridge-restart cartridge-scale cartridge-show cartridge-start cartridge-status cartridge-stop cartridge-storage cartridges create-app create-domain delete-all-authorization delete-app delete-authorization delete-cert-alias delete-domain domain domain-create domain-delete domain-show domain-update force-stop-app git-clone list-alias list-authorization list-cartridge list-sshkey logout port-forward reload-app reload-cartridge remove-alias remove-cartridge remove-sshkey restart-app restart-cartridge restore-snapshot save-snapshot scale-cartridge server setup show-app show-cartridge show-domain show-sshkey snapshot snapshot-restore snapshot-save ssh sshkey sshkey-add sshkey-delete sshkey-list sshkey-remove sshkey-show start-app start-cartridge status-cartridge stop-app stop-cartridge storage-cartridge tail threaddump tidy-app update-cert-alias update-domain"
fi
else
prev="${COMP_WORDS[@]:0:COMP_CWORD}"
Expand Down Expand Up @@ -164,11 +164,19 @@ _rhc()
fi
;;

"rhc aliases")
if [[ "$cur" == -* ]]; then
opts="--app --namespace"
else
opts=""
fi
;;

"rhc app")
if [[ "$cur" == -* ]]; then
opts=""
else
opts="create delete start stop force-stop restart reload tidy show ssh"
opts="snapshot create delete start stop force-stop restart reload tidy show"
fi
;;

Expand Down Expand Up @@ -222,15 +230,15 @@ _rhc()

"rhc app snapshot")
if [[ "$cur" == -* ]]; then
opts=""
opts="--app --filepath --namespace"
else
opts=""
fi
;;

"rhc app ssh")
if [[ "$cur" == -* ]]; then
opts="--app --namespace --ssh"
opts="--app --gears --limit --namespace --raw --ssh"
else
opts=""
fi
Expand Down Expand Up @@ -310,15 +318,15 @@ _rhc()

"rhc app-snapshot")
if [[ "$cur" == -* ]]; then
opts=""
opts="--app --filepath --namespace"
else
opts=""
fi
;;

"rhc app-ssh")
if [[ "$cur" == -* ]]; then
opts="--app --namespace --ssh"
opts="--app --gears --limit --namespace --raw --ssh"
else
opts=""
fi
Expand Down Expand Up @@ -360,7 +368,7 @@ _rhc()
if [[ "$cur" == -* ]]; then
opts=""
else
opts="add delete delete-all"
opts="list add delete delete-all"
fi
;;

Expand Down Expand Up @@ -388,6 +396,14 @@ _rhc()
fi
;;

"rhc authorization list")
if [[ "$cur" == -* ]]; then
opts=""
else
opts=""
fi
;;

"rhc authorization-add")
if [[ "$cur" == -* ]]; then
opts="--expires-in --note --scopes"
Expand All @@ -412,6 +428,14 @@ _rhc()
fi
;;

"rhc authorization-list")
if [[ "$cur" == -* ]]; then
opts=""
else
opts=""
fi
;;

"rhc authorizations")
if [[ "$cur" == -* ]]; then
opts=""
Expand Down Expand Up @@ -764,6 +788,14 @@ _rhc()
fi
;;

"rhc list-authorization")
if [[ "$cur" == -* ]]; then
opts=""
else
opts=""
fi
;;

"rhc list-cartridge")
if [[ "$cur" == -* ]]; then
opts="--verbose"
Expand All @@ -790,7 +822,7 @@ _rhc()

"rhc port-forward")
if [[ "$cur" == -* ]]; then
opts="--app --namespace"
opts="--app --gear --namespace"
else
opts=""
fi
Expand Down Expand Up @@ -966,15 +998,7 @@ _rhc()

"rhc ssh")
if [[ "$cur" == -* ]]; then
opts="--app --namespace --ssh"
else
opts=""
fi
;;

"rhc ssh-app")
if [[ "$cur" == -* ]]; then
opts="--app --namespace --ssh"
opts="--app --gears --limit --namespace --raw --ssh"
else
opts=""
fi
Expand Down Expand Up @@ -1118,7 +1142,7 @@ _rhc()

"rhc tail")
if [[ "$cur" == -* ]]; then
opts="--app --files --namespace --opts"
opts="--app --files --gear --namespace --opts"
else
opts=""
fi
Expand Down
46 changes: 45 additions & 1 deletion client.spec
Expand Up @@ -3,7 +3,7 @@

Summary: OpenShift client management tools
Name: rhc
Version: 1.11.1
Version: 1.12.1
Release: 1%{?dist}
Group: Network/Daemons
License: ASL 2.0
Expand All @@ -22,6 +22,9 @@ Requires: rubygem-archive-tar-minitar
Requires: rubygem-commander
Requires: rubygem-open4
Requires: git
%if 0%{?fedora} >= 19 || 0%{?rhel} >= 7
Requires: rubygem-net-ssh-multi
%endif
Obsoletes: rhc-rest
Provides: rubygem-rhc

Expand Down Expand Up @@ -99,6 +102,47 @@ rm -rf $RPM_BUILD_ROOT
%attr(0644,-,-) /etc/bash_completion.d/rhc

%changelog
* Fri Jul 12 2013 Adam Miller <admiller@redhat.com> 1.12.1-1
- bump_minor_versions for sprint 31 (admiller@redhat.com)

* Wed Jul 10 2013 Adam Miller <admiller@redhat.com> 1.11.4-1
- Bug 979963 - Log and trace errors for interrupts during rhc setup
(ccoleman@redhat.com)
- Merge pull request #425 from
smarterclayton/bug_979992_fix_stty_handling_for_non_interactive
(dmcphers+openshiftbot@redhat.com)
- Merge pull request #420 from pravisankar/dev/ravi/bug980804
(dmcphers+openshiftbot@redhat.com)
- Bug 979992 - Only respond to 'y', 'yes', 'n', and 'no' (ccoleman@redhat.com)
- Bug 980804 - Alias name need to be in lower case while comparing with
existing app aliases (rpenta@redhat.com)

* Tue Jul 09 2013 Adam Miller <admiller@redhat.com> 1.11.3-1
- Merge pull request #421 from smarterclayton/bug_981780_better_responses
(dmcphers+openshiftbot@redhat.com)
- Merge pull request #423 from
smarterclayton/bug_982135_fix_namespace_optional_message
(dmcphers+openshiftbot@redhat.com)
- Merge pull request #424 from
smarterclayton/bug_981274_forgot_to_update_autocomplete
(dmcphers+openshiftbot@redhat.com)
- Bug 981274 - Update autocomplete script (ccoleman@redhat.com)
- Bug 982135 - Namespace optional should affect the message displayed
(ccoleman@redhat.com)
- Bug 980413 - Options that are nil should default to true
(ccoleman@redhat.com)
- Bug 981780 - Filter broker results more effectively, and display results on
cartridge actions (ccoleman@redhat.com)

* Tue Jul 02 2013 Adam Miller <admiller@redhat.com> 1.11.2-1
- Add net-ssh-multi as dependency on F19+ (kraman@gmail.com)
- Bug 978837 - Don't show stack trace if --ssh executable not found
(andy.goldstein@redhat.com)
- Webmock 1.12 breaks query parameter compatibility, can't dupe Symbol/Fixnum
when it tries to match a request signature. Lock to < 1.12 for now.
(ccoleman@redhat.com)
- fix typos (dmcphers@redhat.com)

* Tue Jun 25 2013 Adam Miller <admiller@redhat.com> 1.11.1-1
- bump_minor_versions for sprint 30 (admiller@redhat.com)

Expand Down
1 change: 1 addition & 0 deletions lib/rhc/cli.rb
Expand Up @@ -15,6 +15,7 @@ module CLI

def self.set_terminal
$terminal.wrap_at = HighLine::SystemExtensions.terminal_size.first rescue 80 if $stdin.tty?
$terminal.wrap_at = nil if $terminal.wrap_at == 0
#$terminal.page_at = :auto if $stdin.tty? and $stdout.tty?
# FIXME: ANSI terminals are not default on windows but we may just be
# hitting a bug in highline if windows does support another method.
Expand Down
13 changes: 13 additions & 0 deletions lib/rhc/commands.rb
Expand Up @@ -13,6 +13,19 @@ def root?
root.present?
end

#
# Force proxy_option_struct to default to nil for values,
# backported for Commander 4.0.3
#
def proxy_option_struct
proxy_options.inject Options.new do |options, (option, value)|
# options that are present will evaluate to true
value = true if value.nil?
options.__send__ :"#{option}=", value
options
end
end

def deprecated(as_alias=nil)
return false unless info
return info[:deprecated] if info[:deprecated]
Expand Down
22 changes: 13 additions & 9 deletions lib/rhc/commands/cartridge.rb
Expand Up @@ -84,7 +84,7 @@ def add(cart_type)
rest_app = rest_client.find_application(options.namespace, options.app, :include => :cartridges)
rest_cartridge = rest_app.add_cartridge(cart)

success "Success"
success "done"

paragraph{ display_cart(rest_cartridge) }
paragraph{ rest_cartridge.messages.each { |msg| success msg } }
Expand Down Expand Up @@ -135,18 +135,18 @@ def remove(cartridge)
option ["-a", "--app NAME"], "Application the cartridge", :context => :app_context, :required => true
alias_action :"app cartridge start", :root_command => true, :deprecated => true
def start(cartridge)
cartridge_action(cartridge, :start){ |_, c| results{ say "#{c.name} started" } }
cartridge_action(cartridge, :start, 'Starting %s ... ')
0
end

summary "Stop a cartridge"
syntax "<cartridge> [--namespace NAME] [--app NAME]"
argument :cart_type, "The name of the cartridge you are stopping", ["-c", "--cartridge cartridge"]
option ["-n", "--namespace NAME"], "Namespace of the application the cartridge belongs to", :context => :namespace_context, :required => true
option ["-a", "--app NAME"], "Application you the cartridge belongs to", :context => :app_context, :required => true
option ["-a", "--app NAME"], "Application the cartridge belongs to", :context => :app_context, :required => true
alias_action :"app cartridge stop", :root_command => true, :deprecated => true
def stop(cartridge)
cartridge_action(cartridge, :stop){ |_, c| results{ say "#{c.name} stopped" } }
cartridge_action(cartridge, :stop, 'Stopping %s ... ')
0
end

Expand All @@ -157,7 +157,7 @@ def stop(cartridge)
option ["-a", "--app NAME"], "Application the cartridge belongs to", :context => :app_context, :required => true
alias_action :"app cartridge restart", :root_command => true, :deprecated => true
def restart(cartridge)
cartridge_action(cartridge, :restart){ |_, c| results{ say "#{c.name} restarted" } }
cartridge_action(cartridge, :restart, 'Restarting %s ... ')
0
end

Expand All @@ -181,7 +181,7 @@ def status(cartridge)
option ["-a", "--app NAME"], "Application the cartridge belongs to", :context => :app_context, :required => true
alias_action :"app cartridge reload", :root_command => true, :deprecated => true
def reload(cartridge)
cartridge_action(cartridge, :reload){ |_, c| results{ say "#{c.name} reloaded" } }
cartridge_action(cartridge, :reload, 'Reloading %s ... ')
0
end

Expand Down Expand Up @@ -305,12 +305,16 @@ def storage(cartridge)
private
include RHC::CartridgeHelpers

def cartridge_action(cartridge, action, &block)
def cartridge_action(cartridge, action, message=nil)
rest_app = rest_client.find_application(options.namespace, options.app, :include => :cartridges)
rest_cartridge = check_cartridges(cartridge, :from => rest_app.cartridges).first
result = rest_cartridge.send action
say message % [rest_cartridge.name] if message
result = rest_cartridge.send(action)
resp = [result, rest_cartridge, rest_app]
yield resp if block_given?
if message
success "done"
result.messages.each{ |s| paragraph{ say s } }
end
resp
end
end
Expand Down
2 changes: 2 additions & 0 deletions lib/rhc/commands/ssh.rb
Expand Up @@ -30,6 +30,8 @@ def run(app_name, command)
raise ArgumentError, "--gears requires a command" if options.gears && command.blank?
raise ArgumentError, "--limit must be an integer greater than zero" if options.limit && options.limit < 1
raise OptionParser::InvalidOption, "No system SSH available. Please use the --ssh option to specify the path to your SSH executable, or install SSH." unless options.ssh or has_ssh?
raise OptionParser::InvalidOption, "SSH executable '#{options.ssh}' does not exist." if options.ssh and not File.exist?(options.ssh)
raise OptionParser::InvalidOption, "SSH executable '#{options.ssh}' is not executable." if options.ssh and not File.executable?(options.ssh)

if options.gears
groups = rest_client.find_application_gear_groups(options.namespace, app_name)
Expand Down
15 changes: 13 additions & 2 deletions lib/rhc/helpers.rb
Expand Up @@ -212,7 +212,7 @@ def certificate_file(file)
#

def interactive?
$stdout.tty? and not options.noprompt
$stdin.tty? and $stdout.tty? and not options.noprompt
end

def debug(*args)
Expand Down Expand Up @@ -242,9 +242,20 @@ def deprecated(msg,short = false)
warn "Warning: #{msg}\n" % ['a warning','an error',1]
end

#
# By default, agree should take a single character in interactive
#
def agree(*args, &block)
#args.push(interactive?.presence) if args.length == 1
block = lambda do |q|
q.validate = /\A(?:y|yes|n|no)\Z/i
end unless block_given?
super *args, &block
end

def confirm_action(question)
return if options.confirm
return if !options.noprompt && paragraph{ agree("#{question} (yes|no): ") }
return if !options.noprompt && paragraph{ agree "#{question} (yes|no): " }
raise RHC::ConfirmationError
end

Expand Down

0 comments on commit 7d19858

Please sign in to comment.