Class: Heroku::Command::Addons
- Includes:
- Helpers::HerokuPostgresql
- Defined in:
- lib/heroku/command/addons.rb
Overview
manage addon resources
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#add ⇒ Object
addons:add ADDON.
-
#docs ⇒ Object
addons:docs ADDON.
-
#downgrade ⇒ Object
addons:downgrade ADDON.
-
#index ⇒ Object
addons.
-
#list ⇒ Object
addons:list.
-
#open ⇒ Object
addons:open ADDON.
-
#remove ⇒ Object
addons:remove ADDON1 [ADDON2 …].
-
#upgrade ⇒ Object
addons:upgrade ADDON.
Methods included from Helpers::HerokuPostgresql
#app_attachments, #app_config_vars, #find_database_url_real_attachment, #forget_config!, #hpg_addon_name, #hpg_databases, #hpg_resolve, #hpg_translate_fork_and_follow, #match_attachments_by_name, #resource_url
Methods included from Helpers
#action, #ask, #confirm, #confirm_billing, #confirm_command, #create_git_remote, #deprecate, #display, #display_header, #display_object, #display_row, #display_table, #error, error_with_failure, error_with_failure=, extended, extended_into, #fail, #format_bytes, #format_date, #format_error, #format_with_bang, #get_terminal_environment, #git, #has_git?, #home_directory, #host_name, #hprint, #hputs, included, included_into, #json_decode, #json_encode, #launchy, #line_formatter, #longest, #output_with_bang, #quantify, #redisplay, #retry_on_exception, #run_command, #running_on_a_mac?, #running_on_windows?, #set_buffer, #shell, #spinner, #status, #string_distance, #styled_array, #styled_error, #styled_hash, #styled_header, #suggestion, #time_ago, #truncate, #with_tty
Methods inherited from Base
#api, #app, #heroku, #initialize, namespace
Constructor Details
This class inherits a constructor from Heroku::Command::Base
Instance Method Details
#add ⇒ Object
addons:add ADDON
install an addon
71 72 73 74 75 |
# File 'lib/heroku/command/addons.rb', line 71 def add configure_addon('Adding') do |addon, config| heroku.install_addon(app, addon, config) end end |
#docs ⇒ Object
addons:docs ADDON
open an addon’s documentation in your browser
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/heroku/command/addons.rb', line 118 def docs unless addon = shift_argument error("Usage: pogo addons:docs ADDON\nMust specify ADDON to open docs for.") end validate_arguments! addon_names = api.get_addons.body.map {|a| a['name']} addon_types = addon_names.map {|name| name.split(':').first}.uniq name_matches = addon_names.select {|name| name =~ /^#{addon}/} type_matches = addon_types.select {|name| name =~ /^#{addon}/} if name_matches.include?(addon) || type_matches.include?(addon) type_matches = [addon] end case type_matches.length when 0 then error([ "`#{addon}` is not a pogoapp add-on.", suggestion(addon, addon_names + addon_types), "See `pogo addons:list` for all available addons." ].compact.join("\n")) when 1 addon_type = type_matches.first launchy("Opening #{addon_type} docs", addon_docs_url(addon_type)) else error("Ambiguous addon name: #{addon}\nPerhaps you meant #{name_matches[0...-1].map {|match| "`#{match}`"}.join(', ')} or `#{name_matches.last}`.\n") end end |
#downgrade ⇒ Object
addons:downgrade ADDON
downgrade an existing addon
91 92 93 94 95 |
# File 'lib/heroku/command/addons.rb', line 91 def downgrade configure_addon('Downgrading to') do |addon, config| heroku.upgrade_addon(app, addon, config) end end |
#index ⇒ Object
addons
list installed addons
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/heroku/command/addons.rb', line 16 def index validate_arguments! installed = api.get_addons(app).body if installed.empty? display("#{app} has no add-ons.") else available, pending = installed.partition { |a| a['configured'] } unless available.empty? styled_header("#{app} Configured Add-ons") styled_array(available.map do |a| [a['name'], a['attachment_name'] || ''] end) end unless pending.empty? styled_header("#{app} Add-ons to Configure") styled_array(pending.map do |a| [a['name'], app_addon_url(a['name'])] end) end end end |
#list ⇒ Object
addons:list
list all available addons
–region REGION # specify a region for addon availability
Example:
$ pogo addons:list –region eu
available
adept-scale:battleship, corvette… adminium:enterprise, petproject…
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/heroku/command/addons.rb', line 54 def list addons = heroku.addons() if addons.empty? display "No addons available currently" else partitioned_addons = partition_addons(addons) partitioned_addons.each do |key, addons| partitioned_addons[key] = format_for_display(addons) end display_object(partitioned_addons) end end |
#open ⇒ Object
addons:open ADDON
open an addon’s dashboard in your browser
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/heroku/command/addons.rb', line 153 def open unless addon = shift_argument error("Usage: pogo addons:open ADDON\nMust specify ADDON to open.") end validate_arguments! app_addons = api.get_addons(app).body.map {|a| a['name']} matches = app_addons.select {|a| a =~ /^#{addon}/}.sort case matches.length when 0 then addon_names = api.get_addons.body.map {|a| a['name']} if addon_names.any? {|name| name =~ /^#{addon}/} error("Addon not installed: #{addon}") else error([ "`#{addon}` is not a pogoapp add-on.", suggestion(addon, addon_names + addon_names.map {|name| name.split(':').first}.uniq), "See `pogo addons:list` for all available addons." ].compact.join("\n")) end when 1 then addon_to_open = matches.first launchy("Opening #{addon_to_open} for #{app}", app_addon_url(addon_to_open)) else error("Ambiguous addon name: #{addon}\nPerhaps you meant #{matches[0...-1].map {|match| "`#{match}`"}.join(', ')} or `#{matches.last}`.\n") end end |
#remove ⇒ Object
addons:remove ADDON1 [ADDON2 …]
uninstall one or more addons
101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/heroku/command/addons.rb', line 101 def remove return unless confirm_command args.each do |name| = nil action("Removing #{name} on #{app}") do = addon_run { heroku.uninstall_addon(app, name, :confirm => app) } end display([:attachment]) if [:attachment] display([:message]) if [:message] end end |
#upgrade ⇒ Object
addons:upgrade ADDON
upgrade an existing addon
81 82 83 84 85 |
# File 'lib/heroku/command/addons.rb', line 81 def upgrade configure_addon('Upgrading to') do |addon, config| heroku.upgrade_addon(app, addon, config) end end |