Class: RHC::Commands::Alias
Constant Summary
Constants included from Helpers
Helpers::BOUND_WARNING, Helpers::PREFIX, Helpers::ROLES
Instance Method Summary collapse
- #add(app, app_alias) ⇒ Object
- #delete_cert(app, app_alias) ⇒ Object
- #list(app) ⇒ Object
- #remove(app, app_alias) ⇒ Object
- #update_cert(app, app_alias) ⇒ Object
Methods inherited from Base
Methods included from RHC::ContextHelpers
#find_app, #find_domain, #find_membership_container, #find_team, #from_local_git, included, #namespace_context, #server_context
Methods included from GitHelpers
#git_clone_application, #git_clone_deploy_hooks, #git_clone_repo, #git_cmd, #git_config_get, #git_config_set, #git_remote_add, #git_version, #has_git?
Methods included from Helpers
#agree, #certificate_file, #client_from_options, #collect_env_vars, #color, #confirm_action, #date, #datetime_rfc3339, #debug, #debug?, #debug_error, #decode_json, #deprecated, #deprecated_command, #disable_deprecated?, #distance_of_time_in_words, #env_var_regex_pattern, #error, #exec, #host_exists?, #hosts_file_contains?, #human_size, #info, #interactive?, #jruby?, #mac?, #openshift_online_server?, #openshift_rest_endpoint, #openshift_server, #openshift_url, #pluralize, #results, #role_name, #run_with_tee, #ssh_string, #ssh_string_parts, #ssl_options, #success, #system_path, #table_heading, #to_host, #to_uri, #token_for_user, #unix?, #user_agent, #warn, #windows?, #with_tolerant_encoding
Methods included from OutputHelpers
#default_display_env_var, #display_app, #display_app_configurations, #display_authorization, #display_cart, #display_cart_storage_info, #display_cart_storage_list, #display_deployment, #display_deployment_list, #display_domain, #display_env_var_list, #display_key, #display_team, #format_cart_gears, #format_cart_header, #format_gear_info, #format_key_header, #format_scaling_info, #format_usage_message
Constructor Details
This class inherits a constructor from RHC::Commands::Base
Instance Method Details
#add(app, app_alias) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/rhc/commands/alias.rb', line 24 def add(app, app_alias) rest_app = find_app rest_app.add_alias(app_alias) success "Alias '#{app_alias}' has been added." 0 end |
#delete_cert(app, app_alias) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/rhc/commands/alias.rb', line 91 def delete_cert(app, app_alias) rest_app = find_app rest_alias = rest_app.find_alias(app_alias) if rest_client.api_version_negotiated >= 1.4 confirm_action "#{color("This is a non-reversible action! Your SSL certificate will be permanently deleted from application '#{app}'.", :yellow)}\n\nAre you sure you want to delete the SSL certificate?" rest_alias.delete_certificate success "SSL certificate successfully deleted." 0 else raise RHC::Rest::SslCertificatesNotSupported, "The server does not support SSL certificates for custom aliases." end end |
#list(app) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/rhc/commands/alias.rb', line 108 def list(app) rest_app = find_app items = rest_app.aliases.map do |a| a.is_a?(String) ? [a, 'no', '-'] : [a.id, a.has_private_ssl_certificate? ? 'yes' : 'no', a.has_private_ssl_certificate? ? Date.parse(a.certificate_added_at) : '-'] end if items.empty? info "No aliases associated with the application #{app}." else say table(items, :header => ["Alias", "Has Certificate?", "Certificate Added"]) end 0 end |
#remove(app, app_alias) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/rhc/commands/alias.rb', line 36 def remove(app, app_alias) rest_app = find_app rest_app.remove_alias(app_alias) success "Alias '#{app_alias}' has been removed." 0 end |
#update_cert(app, app_alias) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/rhc/commands/alias.rb', line 62 def update_cert(app, app_alias) certificate_file_path = .certificate raise ArgumentError, "Certificate file not found: #{certificate_file_path}" if !File.exist?(certificate_file_path) || !File.file?(certificate_file_path) private_key_file_path = .private_key raise ArgumentError, "Private key file not found: #{private_key_file_path}" if !File.exist?(private_key_file_path) || !File.file?(private_key_file_path) certificate_content = File.read(certificate_file_path) raise ArgumentError, "Invalid certificate file: #{certificate_file_path} is empty" if certificate_content.to_s.strip.length == 0 private_key_content = File.read(private_key_file_path) raise ArgumentError, "Invalid private key file: #{private_key_file_path} is empty" if private_key_content.to_s.strip.length == 0 rest_app = find_app rest_alias = rest_app.find_alias(app_alias) if rest_client.api_version_negotiated >= 1.4 rest_alias.add_certificate(certificate_content, private_key_content, .passphrase) success "SSL certificate successfully added." 0 else raise RHC::Rest::SslCertificatesNotSupported, "The server does not support SSL certificates for custom aliases." end end |