pogo 2.31.2

Sign up to get free protection for your applications and to get access to all the features.
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,110 @@
1
+ require "heroku/command/base"
2
+
3
+ module Heroku::Command
4
+
5
+ # manage plugins to the heroku gem
6
+ class Plugins < Base
7
+
8
+ # plugins
9
+ #
10
+ # list installed plugins
11
+ #
12
+ #Example:
13
+ #
14
+ # $ heroku plugins
15
+ # === Installed Plugins
16
+ # heroku-accounts
17
+ #
18
+ def index
19
+ validate_arguments!
20
+
21
+ plugins = ::Heroku::Plugin.list
22
+
23
+ if plugins.length > 0
24
+ styled_header("Installed Plugins")
25
+ styled_array(plugins)
26
+ else
27
+ display("You have no installed plugins.")
28
+ end
29
+ end
30
+
31
+ # plugins:install URL
32
+ #
33
+ # install a plugin
34
+ #
35
+ #Example:
36
+ #
37
+ # $ heroku plugins:install https://github.com/ddollar/heroku-accounts.git
38
+ # Installing heroku-accounts... done
39
+ #
40
+ def install
41
+ plugin = Heroku::Plugin.new(shift_argument)
42
+ validate_arguments!
43
+
44
+ action("Installing #{plugin.name}") do
45
+ if plugin.install
46
+ unless Heroku::Plugin.load_plugin(plugin.name)
47
+ plugin.uninstall
48
+ exit(1)
49
+ end
50
+ else
51
+ error("Could not install #{plugin.name}. Please check the URL and try again")
52
+ end
53
+ end
54
+ end
55
+
56
+ # plugins:uninstall PLUGIN
57
+ #
58
+ # uninstall a plugin
59
+ #
60
+ #Example:
61
+ #
62
+ # $ heroku plugins:uninstall heroku-accounts
63
+ # Uninstalling heroku-accounts... done
64
+ #
65
+ def uninstall
66
+ plugin = Heroku::Plugin.new(shift_argument)
67
+ validate_arguments!
68
+
69
+ action("Uninstalling #{plugin.name}") do
70
+ plugin.uninstall
71
+ end
72
+ end
73
+
74
+ # plugins:update [PLUGIN]
75
+ #
76
+ # updates all plugins or a single plugin by name
77
+ #
78
+ #Example:
79
+ #
80
+ # $ heroku plugins:update
81
+ # Updating heroku-accounts... done
82
+ #
83
+ # $ heroku plugins:update heroku-accounts
84
+ # Updating heroku-accounts... done
85
+ #
86
+ def update
87
+ plugins = if plugin = shift_argument
88
+ [plugin]
89
+ else
90
+ ::Heroku::Plugin.list
91
+ end
92
+ validate_arguments!
93
+
94
+ plugins.each do |plugin|
95
+ begin
96
+ action("Updating #{plugin}") do
97
+ begin
98
+ Heroku::Plugin.new(plugin).update
99
+ rescue Heroku::Plugin::ErrorUpdatingSymlinkPlugin
100
+ status "skipped symlink"
101
+ end
102
+ end
103
+ rescue SystemExit
104
+ # ignore so that other plugins still update
105
+ end
106
+ end
107
+ end
108
+
109
+ end
110
+ end
@@ -0,0 +1,232 @@
1
+ require "heroku/command/base"
2
+
3
+ # manage processes (dynos, workers)
4
+ #
5
+ class Heroku::Command::Ps < Heroku::Command::Base
6
+
7
+ # ps:dynos [QTY]
8
+ #
9
+ # DEPRECATED: use `heroku ps:scale dynos=N`
10
+ #
11
+ # scale to QTY web processes
12
+ #
13
+ # if QTY is not specified, display the number of web processes currently running
14
+ #
15
+ #Example:
16
+ #
17
+ # $ heroku ps:dynos 3
18
+ # Scaling dynos... done, now running 3
19
+ #
20
+ def dynos
21
+ # deprecation notice added to v2.21.3 on 03/16/12
22
+ display("~ `heroku ps:dynos QTY` has been deprecated and replaced with `heroku ps:scale dynos=QTY`")
23
+
24
+ dynos = shift_argument
25
+ validate_arguments!
26
+
27
+ if dynos
28
+ action("Scaling dynos") do
29
+ new_dynos = api.put_dynos(app, dynos).body["dynos"]
30
+ status("now running #{new_dynos}")
31
+ end
32
+ else
33
+ app_data = api.get_app(app).body
34
+ if app_data["stack"] == "cedar"
35
+ raise(Heroku::Command::CommandFailed, "For Cedar apps, use `heroku ps`")
36
+ else
37
+ display("#{app} is running #{quantify("dyno", app_data["dynos"])}")
38
+ end
39
+ end
40
+ end
41
+
42
+ alias_command "dynos", "ps:dynos"
43
+
44
+ # ps:workers [QTY]
45
+ #
46
+ # DEPRECATED: use `heroku ps:scale workers=N`
47
+ #
48
+ # scale to QTY background processes
49
+ #
50
+ # if QTY is not specified, display the number of background processes currently running
51
+ #
52
+ #Example:
53
+ #
54
+ # $ heroku ps:dynos 3
55
+ # Scaling workers... done, now running 3
56
+ #
57
+ def workers
58
+ # deprecation notice added to v2.21.3 on 03/16/12
59
+ display("~ `heroku ps:workers QTY` has been deprecated and replaced with `heroku ps:scale workers=QTY`")
60
+
61
+ workers = shift_argument
62
+ validate_arguments!
63
+
64
+ if workers
65
+ action("Scaling workers") do
66
+ new_workers = api.put_workers(app, workers).body["workers"]
67
+ status("now running #{new_workers}")
68
+ end
69
+ else
70
+ app_data = api.get_app(app).body
71
+ if app_data["stack"] == "cedar"
72
+ raise(Heroku::Command::CommandFailed, "For Cedar apps, use `heroku ps`")
73
+ else
74
+ display("#{app} is running #{quantify("worker", app_data["workers"])}")
75
+ end
76
+ end
77
+ end
78
+
79
+ alias_command "workers", "ps:workers"
80
+
81
+ # ps
82
+ #
83
+ # list processes for an app
84
+ #
85
+ #Example:
86
+ #
87
+ # $ heroku ps
88
+ # === run: one-off processes
89
+ # run.1: up for 5m: `bash`
90
+ #
91
+ # === web: `bundle exec thin start -p $PORT`
92
+ # web.1: created for 30s
93
+ #
94
+ def index
95
+ validate_arguments!
96
+ processes = api.get_ps(app).body
97
+
98
+ processes_by_command = Hash.new {|hash,key| hash[key] = []}
99
+ processes.each do |process|
100
+ name = process["process"].split(".").first
101
+ elapsed = time_ago(Time.now - process['elapsed'])
102
+
103
+ if name == "run"
104
+ key = "run: one-off processes"
105
+ item = "%s: %s %s: `%s`" % [ process["process"], process["state"], elapsed, process["command"] ]
106
+ else
107
+ key = "#{name}: `#{process["command"]}`"
108
+ item = "%s: %s %s" % [ process["process"], process["state"], elapsed ]
109
+ end
110
+
111
+ processes_by_command[key] << item
112
+ end
113
+
114
+ processes_by_command.keys.each do |key|
115
+ processes_by_command[key] = processes_by_command[key].sort do |x,y|
116
+ x.match(/\.(\d+):/).captures.first.to_i <=> y.match(/\.(\d+):/).captures.first.to_i
117
+ end
118
+ end
119
+
120
+ processes_by_command.keys.sort.each do |key|
121
+ styled_header(key)
122
+ styled_array(processes_by_command[key], :sort => false)
123
+ end
124
+ end
125
+
126
+ # ps:restart [PROCESS]
127
+ #
128
+ # restart an app process
129
+ #
130
+ # if PROCESS is not specified, restarts all processes on the app
131
+ #
132
+ #Examples:
133
+ #
134
+ # $ heroku ps:restart web.1
135
+ # Restarting web.1 process... done
136
+ #
137
+ # $ heroku ps:restart web
138
+ # Restarting web processes... done
139
+ #
140
+ # $ heroku ps:restart
141
+ # Restarting processes... done
142
+ #
143
+ def restart
144
+ process = shift_argument
145
+ validate_arguments!
146
+
147
+ message, options = case process
148
+ when NilClass
149
+ ["Restarting processes", {}]
150
+ when /.+\..+/
151
+ ps = args.first
152
+ ["Restarting #{ps} process", { :ps => ps }]
153
+ else
154
+ type = args.first
155
+ ["Restarting #{type} processes", { :type => type }]
156
+ end
157
+
158
+ action(message) do
159
+ api.post_ps_restart(app, options)
160
+ end
161
+ end
162
+
163
+ alias_command "restart", "ps:restart"
164
+
165
+ # ps:scale PROCESS1=AMOUNT1 [PROCESS2=AMOUNT2 ...]
166
+ #
167
+ # scale processes by the given amount
168
+ #
169
+ #Examples:
170
+ #
171
+ # $ heroku ps:scale web=3 worker+1
172
+ # Scaling web processes... done, now running 3
173
+ # Scaling worker processes... done, now running 1
174
+ #
175
+ def scale
176
+ changes = {}
177
+ args.each do |arg|
178
+ if arg =~ /^([a-zA-Z0-9_]+)([=+-]\d+)$/
179
+ changes[$1] = $2
180
+ end
181
+ end
182
+
183
+ if changes.empty?
184
+ error("Usage: heroku ps:scale PROCESS1=AMOUNT1 [PROCESS2=AMOUNT2 ...]\nMust specify PROCESS and AMOUNT to scale.")
185
+ end
186
+
187
+ changes.keys.sort.each do |process|
188
+ amount = changes[process]
189
+ action("Scaling #{process} processes") do
190
+ amount.gsub!("=", "")
191
+ new_qty = api.post_ps_scale(app, process, amount).body
192
+ status("now running #{new_qty}")
193
+ end
194
+ end
195
+ end
196
+
197
+ alias_command "scale", "ps:scale"
198
+
199
+ # ps:stop PROCESS
200
+ #
201
+ # stop an app process
202
+ #
203
+ # Examples:
204
+ #
205
+ # $ heroku stop run.3
206
+ # Stopping run.3 process... done
207
+ #
208
+ # $ heroku stop run
209
+ # Stopping run processes... done
210
+ #
211
+ def stop
212
+ process = shift_argument
213
+ validate_arguments!
214
+
215
+ message, options = case process
216
+ when NilClass
217
+ error("Usage: heroku ps:stop PROCESS\nMust specify PROCESS to stop.")
218
+ when /.+\..+/
219
+ ps = args.first
220
+ ["Stopping #{ps} process", { :ps => ps }]
221
+ else
222
+ type = args.first
223
+ ["Stopping #{type} processes", { :type => type }]
224
+ end
225
+
226
+ action(message) do
227
+ api.post_ps_stop(app, options)
228
+ end
229
+ end
230
+
231
+ alias_command "stop", "ps:stop"
232
+ end
@@ -0,0 +1,124 @@
1
+ require "heroku/command/base"
2
+
3
+ # manage app releases
4
+ #
5
+ class Heroku::Command::Releases < Heroku::Command::Base
6
+
7
+ # releases
8
+ #
9
+ # list releases
10
+ #
11
+ #Example:
12
+ #
13
+ # $ heroku releases
14
+ # === myapp Releases
15
+ # v1 Config add FOO_BAR by email@example.com 0s ago
16
+ # v2 Config add BAR_BAZ by email@example.com 0s ago
17
+ # v3 Config add BAZ_QUX by email@example.com 0s ago
18
+ #
19
+ def index
20
+ validate_arguments!
21
+
22
+ releases_data = api.get_releases(app).body.sort_by do |release|
23
+ release["name"][1..-1].to_i
24
+ end.reverse.slice(0, 15)
25
+
26
+ unless releases_data.empty?
27
+ releases = releases_data.map do |release|
28
+ [
29
+ release["name"],
30
+ truncate(release["descr"], 40),
31
+ release["user"],
32
+ time_ago(release['created_at'])
33
+ ]
34
+ end
35
+
36
+ styled_header("#{app} Releases")
37
+ styled_array(releases, :sort => false)
38
+ else
39
+ display("#{app} has no releases.")
40
+ end
41
+ end
42
+
43
+ # releases:info RELEASE
44
+ #
45
+ # view detailed information for a release
46
+ # find latest release details by passing 'current' as the release
47
+ #
48
+ # -s, --shell # output config vars in shell format
49
+ #
50
+ #Example:
51
+ #
52
+ # $ heroku releases:info v10
53
+ # === Release v10
54
+ # Addons: deployhooks:http
55
+ # By: email@example.com
56
+ # Change: deploy ABCDEFG
57
+ # When: 2012-01-01 12:00:00
58
+ #
59
+ # === v10 Config Vars
60
+ # EXAMPLE: foo
61
+ #
62
+ def info
63
+ unless release = shift_argument
64
+ error("Usage: heroku releases:info RELEASE")
65
+ end
66
+ validate_arguments!
67
+
68
+ release_data = api.get_release(app, release).body
69
+
70
+ data = {
71
+ 'By' => release_data['user'],
72
+ 'Change' => release_data['descr'],
73
+ 'When' => time_ago(release_data["created_at"])
74
+ }
75
+
76
+ unless release_data['addons'].empty?
77
+ data['Addons'] = release_data['addons']
78
+ end
79
+
80
+ styled_header("Release #{release}")
81
+ styled_hash(data)
82
+
83
+ display
84
+
85
+ styled_header("#{release} Config Vars")
86
+ unless release_data['env'].empty?
87
+ if options[:shell]
88
+ release_data['env'].keys.sort.each do |key|
89
+ display("#{key}=#{release_data['env'][key]}")
90
+ end
91
+ else
92
+ styled_hash(release_data['env'])
93
+ end
94
+ else
95
+ display("#{release} has no config vars.")
96
+ end
97
+ end
98
+
99
+ # releases:rollback [RELEASE]
100
+ #
101
+ # roll back to an older release
102
+ #
103
+ # if RELEASE is not specified, will roll back one step
104
+ #
105
+ #Example:
106
+ #
107
+ # $ heroku releases:rollback
108
+ # Rolling back myapp... done, v122
109
+ #
110
+ # $ heroku releases:rollback v42
111
+ # Rolling back myapp to v42... done
112
+ #
113
+ def rollback
114
+ release = shift_argument
115
+ validate_arguments!
116
+
117
+ action("Rolling back #{app}") do
118
+ status(api.post_release(app, release).body)
119
+ end
120
+ end
121
+
122
+ alias_command "rollback", "releases:rollback"
123
+
124
+ end