pogo 2.31.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. data/README.md +73 -0
  2. data/bin/pogo +22 -0
  3. data/data/cacert.pem +3988 -0
  4. data/lib/heroku.rb +22 -0
  5. data/lib/heroku/auth.rb +320 -0
  6. data/lib/heroku/cli.rb +38 -0
  7. data/lib/heroku/client.rb +764 -0
  8. data/lib/heroku/client/heroku_postgresql.rb +111 -0
  9. data/lib/heroku/client/pgbackups.rb +113 -0
  10. data/lib/heroku/client/rendezvous.rb +105 -0
  11. data/lib/heroku/client/ssl_endpoint.rb +25 -0
  12. data/lib/heroku/command.rb +273 -0
  13. data/lib/heroku/command/account.rb +23 -0
  14. data/lib/heroku/command/accounts.rb +34 -0
  15. data/lib/heroku/command/addons.rb +305 -0
  16. data/lib/heroku/command/apps.rb +311 -0
  17. data/lib/heroku/command/auth.rb +86 -0
  18. data/lib/heroku/command/base.rb +230 -0
  19. data/lib/heroku/command/certs.rb +148 -0
  20. data/lib/heroku/command/config.rb +137 -0
  21. data/lib/heroku/command/db.rb +218 -0
  22. data/lib/heroku/command/domains.rb +85 -0
  23. data/lib/heroku/command/drains.rb +46 -0
  24. data/lib/heroku/command/git.rb +65 -0
  25. data/lib/heroku/command/help.rb +163 -0
  26. data/lib/heroku/command/keys.rb +115 -0
  27. data/lib/heroku/command/labs.rb +161 -0
  28. data/lib/heroku/command/logs.rb +98 -0
  29. data/lib/heroku/command/maintenance.rb +61 -0
  30. data/lib/heroku/command/pg.rb +277 -0
  31. data/lib/heroku/command/pgbackups.rb +289 -0
  32. data/lib/heroku/command/plugins.rb +110 -0
  33. data/lib/heroku/command/ps.rb +232 -0
  34. data/lib/heroku/command/releases.rb +124 -0
  35. data/lib/heroku/command/run.rb +179 -0
  36. data/lib/heroku/command/sharing.rb +89 -0
  37. data/lib/heroku/command/ssl.rb +61 -0
  38. data/lib/heroku/command/stack.rb +62 -0
  39. data/lib/heroku/command/status.rb +51 -0
  40. data/lib/heroku/command/update.rb +47 -0
  41. data/lib/heroku/command/version.rb +23 -0
  42. data/lib/heroku/deprecated.rb +5 -0
  43. data/lib/heroku/deprecated/help.rb +38 -0
  44. data/lib/heroku/distribution.rb +9 -0
  45. data/lib/heroku/helpers.rb +517 -0
  46. data/lib/heroku/helpers/heroku_postgresql.rb +104 -0
  47. data/lib/heroku/plugin.rb +161 -0
  48. data/lib/heroku/updater.rb +158 -0
  49. data/lib/heroku/version.rb +3 -0
  50. data/lib/vendor/heroku/okjson.rb +598 -0
  51. data/spec/helper/legacy_help.rb +16 -0
  52. data/spec/heroku/auth_spec.rb +246 -0
  53. data/spec/heroku/client/heroku_postgresql_spec.rb +34 -0
  54. data/spec/heroku/client/pgbackups_spec.rb +43 -0
  55. data/spec/heroku/client/rendezvous_spec.rb +62 -0
  56. data/spec/heroku/client/ssl_endpoint_spec.rb +48 -0
  57. data/spec/heroku/client_spec.rb +564 -0
  58. data/spec/heroku/command/addons_spec.rb +585 -0
  59. data/spec/heroku/command/apps_spec.rb +351 -0
  60. data/spec/heroku/command/auth_spec.rb +38 -0
  61. data/spec/heroku/command/base_spec.rb +109 -0
  62. data/spec/heroku/command/certs_spec.rb +178 -0
  63. data/spec/heroku/command/config_spec.rb +144 -0
  64. data/spec/heroku/command/db_spec.rb +110 -0
  65. data/spec/heroku/command/domains_spec.rb +87 -0
  66. data/spec/heroku/command/drains_spec.rb +34 -0
  67. data/spec/heroku/command/git_spec.rb +116 -0
  68. data/spec/heroku/command/help_spec.rb +93 -0
  69. data/spec/heroku/command/keys_spec.rb +120 -0
  70. data/spec/heroku/command/labs_spec.rb +99 -0
  71. data/spec/heroku/command/logs_spec.rb +60 -0
  72. data/spec/heroku/command/maintenance_spec.rb +51 -0
  73. data/spec/heroku/command/pg_spec.rb +223 -0
  74. data/spec/heroku/command/pgbackups_spec.rb +280 -0
  75. data/spec/heroku/command/plugins_spec.rb +104 -0
  76. data/spec/heroku/command/ps_spec.rb +195 -0
  77. data/spec/heroku/command/releases_spec.rb +130 -0
  78. data/spec/heroku/command/run_spec.rb +86 -0
  79. data/spec/heroku/command/sharing_spec.rb +59 -0
  80. data/spec/heroku/command/ssl_spec.rb +32 -0
  81. data/spec/heroku/command/stack_spec.rb +46 -0
  82. data/spec/heroku/command/status_spec.rb +48 -0
  83. data/spec/heroku/command/version_spec.rb +16 -0
  84. data/spec/heroku/command_spec.rb +211 -0
  85. data/spec/heroku/helpers/heroku_postgresql_spec.rb +109 -0
  86. data/spec/heroku/helpers_spec.rb +48 -0
  87. data/spec/heroku/plugin_spec.rb +172 -0
  88. data/spec/heroku/updater_spec.rb +44 -0
  89. data/spec/spec.opts +1 -0
  90. data/spec/spec_helper.rb +209 -0
  91. data/spec/support/display_message_matcher.rb +49 -0
  92. data/spec/support/openssl_mock_helper.rb +8 -0
  93. metadata +220 -0
@@ -0,0 +1,179 @@
1
+ require "readline"
2
+ require "heroku/command/base"
3
+
4
+ # run one-off commands (console, rake)
5
+ #
6
+ class Heroku::Command::Run < Heroku::Command::Base
7
+
8
+ # run COMMAND
9
+ #
10
+ # run an attached process
11
+ #
12
+ #Example:
13
+ #
14
+ # $ heroku run bash
15
+ # Running `bash` attached to terminal... up, run.1
16
+ # ~ $
17
+ #
18
+ def index
19
+ command = args.join(" ")
20
+ error("Usage: heroku run COMMAND")if command.empty?
21
+ run_attached(command)
22
+ end
23
+
24
+ # run:detached COMMAND
25
+ #
26
+ # run a detached process, where output is sent to your logs
27
+ #
28
+ #Example:
29
+ #
30
+ # $ heroku run:detached ls
31
+ # Running `ls` detached... up, run.1
32
+ # Use `heroku logs -p run.1` to view the output.
33
+ #
34
+ def detached
35
+ command = args.join(" ")
36
+ error("Usage: heroku run COMMAND")if command.empty?
37
+ opts = { :attach => false, :command => command }
38
+ process_data = action("Running `#{command}` detached", :success => "up") do
39
+ process_data = api.post_ps(app, command, { :attach => false }).body
40
+ status(process_data['process'])
41
+ process_data
42
+ end
43
+ display("Use `heroku logs -p #{process_data['process']}` to view the output.")
44
+ end
45
+
46
+ # run:rake COMMAND
47
+ #
48
+ # WARNING: `heroku run:rake` has been deprecated. Please use `heroku run rake` instead."
49
+ #
50
+ # remotely execute a rake command
51
+ #
52
+ #Example:
53
+ #
54
+ # $ heroku run:rake -T
55
+ # Running `rake -T` attached to terminal... up, run.1
56
+ # (in /app)
57
+ # rake test # run tests
58
+ #
59
+ def rake
60
+ deprecate("`heroku #{current_command}` has been deprecated. Please use `heroku run rake` instead.")
61
+ command = "rake #{args.join(' ')}"
62
+ run_attached(command)
63
+ end
64
+
65
+ alias_command "rake", "run:rake"
66
+
67
+ # run:console [COMMAND]
68
+ #
69
+ # open a remote console session
70
+ #
71
+ # if COMMAND is specified, run the command and exit
72
+ #
73
+ # NOTE: For Cedar apps, use `heroku run console`
74
+ #
75
+ #Examples:
76
+ #
77
+ # $ heroku console
78
+ # Ruby console for myapp.heroku.com
79
+ # >>
80
+ #
81
+ def console
82
+ cmd = args.join(' ').strip
83
+ if cmd.empty?
84
+ console_session(app)
85
+ else
86
+ display(heroku.console(app, cmd))
87
+ end
88
+ rescue RestClient::RequestFailed => e
89
+ if e.http_body =~ /For Cedar apps, use: `heroku run console`/
90
+ deprecate("`heroku #{current_command}` has been deprecated for Cedar apps. Please use: `heroku run console` instead.")
91
+ command = "console #{args.join(' ')}"
92
+ run_attached(command)
93
+ else
94
+ raise(e)
95
+ end
96
+ rescue RestClient::RequestTimeout
97
+ error("Timed out. Long running requests are not supported on the console.\nPlease consider creating a rake task instead.")
98
+ rescue Heroku::Client::AppCrashed => e
99
+ error(e.message)
100
+ end
101
+
102
+ alias_command "console", "run:console"
103
+
104
+ protected
105
+
106
+ def run_attached(command)
107
+ process_data = action("Running `#{command}` attached to terminal", :success => "up") do
108
+ process_data = api.post_ps(app, command, { :attach => true, :ps_env => get_terminal_environment }).body
109
+ status(process_data["process"])
110
+ process_data
111
+ end
112
+ rendezvous_session(process_data["rendezvous_url"])
113
+ end
114
+
115
+ def rendezvous_session(rendezvous_url, &on_connect)
116
+ begin
117
+ set_buffer(false)
118
+ rendezvous = Heroku::Client::Rendezvous.new(
119
+ :rendezvous_url => rendezvous_url,
120
+ :connect_timeout => (ENV["HEROKU_CONNECT_TIMEOUT"] || 120).to_i,
121
+ :activity_timeout => nil,
122
+ :input => $stdin,
123
+ :output => $stdout)
124
+ rendezvous.on_connect(&on_connect)
125
+ rendezvous.start
126
+ rescue Timeout::Error
127
+ error "\nTimeout awaiting process"
128
+ rescue Errno::ECONNREFUSED, Errno::ECONNRESET, OpenSSL::SSL::SSLError
129
+ error "\nError connecting to process"
130
+ rescue Interrupt
131
+ ensure
132
+ set_buffer(true)
133
+ end
134
+ end
135
+
136
+ def console_history_dir
137
+ FileUtils.mkdir_p(path = "#{home_directory}/.heroku/console_history")
138
+ path
139
+ end
140
+
141
+ def console_session(app)
142
+ heroku.console(app) do |console|
143
+ console_history_read(app)
144
+
145
+ display "Ruby console for #{app}.#{heroku.host}"
146
+ while cmd = Readline.readline('>> ')
147
+ unless cmd.nil? || cmd.strip.empty?
148
+ console_history_add(app, cmd)
149
+ break if cmd.downcase.strip == 'exit'
150
+ display console.run(cmd)
151
+ end
152
+ end
153
+ end
154
+ end
155
+
156
+ def console_history_file(app)
157
+ "#{console_history_dir}/#{app}"
158
+ end
159
+
160
+ def console_history_read(app)
161
+ history = File.read(console_history_file(app)).split("\n")
162
+ if history.size > 50
163
+ history = history[(history.size - 51),(history.size - 1)]
164
+ File.open(console_history_file(app), "w") { |f| f.puts history.join("\n") }
165
+ end
166
+ history.each { |cmd| Readline::HISTORY.push(cmd) }
167
+ rescue Errno::ENOENT
168
+ rescue Exception => ex
169
+ display "Error reading your console history: #{ex.message}"
170
+ if confirm("Would you like to clear it? (y/N):")
171
+ FileUtils.rm(console_history_file(app)) rescue nil
172
+ end
173
+ end
174
+
175
+ def console_history_add(app, cmd)
176
+ Readline::HISTORY.push(cmd)
177
+ File.open(console_history_file(app), "a") { |f| f.puts cmd + "\n" }
178
+ end
179
+ end
@@ -0,0 +1,89 @@
1
+ require "heroku/command/base"
2
+
3
+ module Heroku::Command
4
+
5
+ # manage collaborators on an app
6
+ #
7
+ class Sharing < Base
8
+
9
+ # sharing
10
+ #
11
+ # list collaborators on an app
12
+ #
13
+ #Example:
14
+ #
15
+ # $ heroku sharing
16
+ # === myapp Collaborators
17
+ # collaborator@example.com
18
+ # email@example.com
19
+ #
20
+ def index
21
+ validate_arguments!
22
+
23
+ # this is never empty, as it always includes the owner
24
+ collaborators = api.get_collaborators(app).body
25
+ styled_header("#{app} Collaborators")
26
+ styled_array(collaborators.map {|collaborator| collaborator["email"]})
27
+ end
28
+
29
+ # sharing:add EMAIL
30
+ #
31
+ # add a collaborator to an app
32
+ #
33
+ #Example:
34
+ #
35
+ # $ heroku sharing:add collaborator@example.com
36
+ # Adding collaborator@example.com to myapp collaborators... done
37
+ #
38
+ def add
39
+ unless email = shift_argument
40
+ error("Usage: heroku sharing:add EMAIL\nMust specify EMAIL to add sharing.")
41
+ end
42
+ validate_arguments!
43
+
44
+ action("Adding #{email} to #{app} collaborators") do
45
+ api.post_collaborator(app, email)
46
+ end
47
+ end
48
+
49
+ # sharing:remove EMAIL
50
+ #
51
+ # remove a collaborator from an app
52
+ #
53
+ #Example:
54
+ #
55
+ # $ heroku sharing:remove collaborator@example.com
56
+ # Removing collaborator@example.com to myapp collaborators... done
57
+ #
58
+ def remove
59
+ unless email = shift_argument
60
+ error("Usage: heroku sharing:remove EMAIL\nMust specify EMAIL to remove sharing.")
61
+ end
62
+ validate_arguments!
63
+
64
+ action("Removing #{email} from #{app} collaborators") do
65
+ api.delete_collaborator(app, email)
66
+ end
67
+ end
68
+
69
+ # sharing:transfer EMAIL
70
+ #
71
+ # transfer an app to a new owner
72
+ #
73
+ #Example:
74
+ #
75
+ # $ heroku sharing:transfer collaborator@example.com
76
+ # Transferring myapp to collaborator@example.com... done
77
+ #
78
+ def transfer
79
+ unless email = shift_argument
80
+ error("Usage: heroku sharing:transfer EMAIL\nMust specify EMAIL to transfer an app.")
81
+ end
82
+ validate_arguments!
83
+
84
+ action("Transferring #{app} to #{email}") do
85
+ api.put_app(app, "transfer_owner" => email)
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,61 @@
1
+ require "heroku/command/base"
2
+
3
+ module Heroku::Command
4
+
5
+ # manage ssl certificates for an app
6
+ #
7
+ class Ssl < Base
8
+
9
+ # ssl
10
+ #
11
+ # list certificates for an app
12
+ #
13
+ def index
14
+ api.get_domains(app).body.each do |domain|
15
+ if cert = domain['cert']
16
+ display "#{domain['domain']} has a SSL certificate registered to #{cert['subject']} which expires on #{format_date(cert['expires_at'])}"
17
+ else
18
+ display "#{domain['domain']} has no certificate"
19
+ end
20
+ end
21
+ end
22
+
23
+ # ssl:add PEM KEY
24
+ #
25
+ # add an ssl certificate to an app
26
+ #
27
+ def add
28
+ pem_file = args.shift
29
+ key_file = args.shift
30
+ fail "Usage: heroku ssl:add PEM KEY" unless pem_file && key_file
31
+ raise CommandFailed, "Missing pem file." unless pem_file
32
+ raise CommandFailed, "Missing key file." unless key_file
33
+ raise CommandFailed, "Could not find pem in #{pem_file}" unless File.exists?(pem_file)
34
+ raise CommandFailed, "Could not find key in #{key_file}" unless File.exists?(key_file)
35
+
36
+ pem = File.read(pem_file)
37
+ key = File.read(key_file)
38
+ info = heroku.add_ssl(app, pem, key)
39
+ display "Added certificate to #{info['domain']}, expiring at #{info['expires_at']}"
40
+ end
41
+
42
+ # ssl:remove DOMAIN
43
+ #
44
+ # remove an ssl certificate from an app
45
+ #
46
+ def remove
47
+ raise CommandFailed, "Missing domain. Usage:\nheroku ssl:remove <domain>" unless domain = args.shift
48
+ heroku.remove_ssl(app, domain)
49
+ display "Removed certificate from #{domain}"
50
+ end
51
+
52
+ # ssl:clear
53
+ #
54
+ # remove all ssl certificates from an app
55
+ #
56
+ def clear
57
+ heroku.clear_ssl(app)
58
+ display "Cleared certificates for #{app}"
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,62 @@
1
+ require "heroku/command/base"
2
+
3
+ module Heroku::Command
4
+
5
+ # manage the stack for an app
6
+ class Stack < Base
7
+
8
+ # stack
9
+ #
10
+ # show the list of available stacks
11
+ #
12
+ #Example:
13
+ #
14
+ # $ heroku stack
15
+ # === myapp Available Stacks
16
+ # bamboo-mri-1.9.2
17
+ # bamboo-ree-1.8.7
18
+ # * cedar
19
+ #
20
+ def index
21
+ validate_arguments!
22
+
23
+ stacks_data = api.get_stack(app).body
24
+
25
+ styled_header("#{app} Available Stacks")
26
+ stacks = stacks_data.map do |stack|
27
+ row = [stack['current'] ? '*' : ' ', stack['name']]
28
+ row << '(beta)' if stack['beta']
29
+ row << '(deprecated)' if stack['deprecated']
30
+ row << '(prepared, will migrate on next git push)' if stack['requested']
31
+ row.join(' ')
32
+ end
33
+ styled_array(stacks)
34
+ end
35
+
36
+ # stack:migrate STACK
37
+ #
38
+ # prepare migration of this app to a new stack
39
+ #
40
+ #Example:
41
+ #
42
+ # $ heroku stack:migrate cedar
43
+ # -----> Preparing to migrate evening-warrior-2345
44
+ # bamboo-mri-1.9.2 -> bamboo-ree-1.8.7
45
+ #
46
+ # NOTE: You must specify ALL gems (including Rails) in manifest
47
+ #
48
+ # Please read the migration guide:
49
+ # http://devcenter.heroku.com/articles/bamboo
50
+ #
51
+ # -----> Migration prepared.
52
+ # Run 'git push heroku master' to execute migration.
53
+ #
54
+ def migrate
55
+ unless stack = shift_argument
56
+ error("Usage: heroku stack:migrate STACK.\nMust specify target stack.")
57
+ end
58
+
59
+ display(api.put_stack(app, stack).body)
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,51 @@
1
+ require "heroku/command/base"
2
+
3
+ # check status of heroku platform
4
+ #
5
+ class Heroku::Command::Status < Heroku::Command::Base
6
+
7
+ # status
8
+ #
9
+ # display current status of heroku platform
10
+ #
11
+ #Example:
12
+ #
13
+ # $ heroku status
14
+ # === Heroku Status
15
+ # Development: No known issues at this time.
16
+ # Production: No known issues at this time.
17
+ #
18
+ def index
19
+ validate_arguments!
20
+
21
+ heroku_status_host = ENV['HEROKU_STATUS_HOST'] || "status.heroku.com"
22
+ require('excon')
23
+ status = json_decode(Excon.get("https://#{heroku_status_host}/api/v3/current-status.json", :nonblock => false).body)
24
+
25
+ styled_header("Heroku Status")
26
+
27
+ status['status'].each do |key, value|
28
+ if value == 'green'
29
+ status['status'][key] = 'No known issues at this time.'
30
+ end
31
+ end
32
+ styled_hash(status['status'])
33
+
34
+ unless status['issues'].empty?
35
+ display
36
+ status['issues'].each do |issue|
37
+ duration = time_ago(issue['created_at']).gsub(' ago', '+')
38
+ styled_header("#{issue['title']} #{duration}")
39
+ changes = issue['updates'].map do |issue|
40
+ [
41
+ time_ago(Time.now - Time.parse(issue['created_at'])),
42
+ issue['update_type'],
43
+ issue['contents']
44
+ ]
45
+ end
46
+ styled_array(changes, :sort => false)
47
+ end
48
+ end
49
+ end
50
+
51
+ end
@@ -0,0 +1,47 @@
1
+ require "heroku/command/base"
2
+ require "heroku/updater"
3
+
4
+ # update the heroku client
5
+ #
6
+ class Heroku::Command::Update < Heroku::Command::Base
7
+
8
+ # update
9
+ #
10
+ # update the heroku client
11
+ #
12
+ # Example:
13
+ #
14
+ # $ heroku update
15
+ # Updating from v1.2.3... done, updated to v2.3.4
16
+ #
17
+ def index
18
+ validate_arguments!
19
+ update_from_url("https://toolbelt.herokuapp.com/download/zip")
20
+ end
21
+
22
+ # update:beta
23
+ #
24
+ # update to the latest beta client
25
+ #
26
+ # $ heroku update
27
+ # Updating from v1.2.3... done, updated to v2.3.4.pre
28
+ #
29
+ def beta
30
+ validate_arguments!
31
+ update_from_url("https://toolbelt.herokuapp.com/download/beta-zip")
32
+ end
33
+
34
+ private
35
+
36
+ def update_from_url(url)
37
+ Heroku::Updater.check_disabled!
38
+ action("Updating from #{Heroku::VERSION}") do
39
+ if new_version = Heroku::Updater.update(url)
40
+ status("updated to #{new_version}")
41
+ else
42
+ status("nothing to update")
43
+ end
44
+ end
45
+ end
46
+
47
+ end