qtc-sdk 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +18 -18
  3. data/.rspec +2 -0
  4. data/.travis.yml +7 -0
  5. data/Changelog.md +28 -23
  6. data/Gemfile +4 -4
  7. data/LICENSE.txt +22 -22
  8. data/README.md +42 -44
  9. data/Rakefile +1 -1
  10. data/bin/qtc-cli +13 -13
  11. data/lib/qtc-sdk.rb +1 -1
  12. data/lib/qtc/cli/commands.rb +15 -15
  13. data/lib/qtc/cli/common.rb +146 -146
  14. data/lib/qtc/cli/eds/base.rb +27 -27
  15. data/lib/qtc/cli/eds/commands.rb +20 -20
  16. data/lib/qtc/cli/eds/instances.rb +30 -30
  17. data/lib/qtc/cli/mar/apps.rb +116 -116
  18. data/lib/qtc/cli/mar/base.rb +60 -60
  19. data/lib/qtc/cli/mar/commands.rb +268 -266
  20. data/lib/qtc/cli/mar/debug.rb +94 -88
  21. data/lib/qtc/cli/mar/domains.rb +35 -35
  22. data/lib/qtc/cli/mar/env.rb +38 -38
  23. data/lib/qtc/cli/mar/repository.rb +24 -24
  24. data/lib/qtc/cli/mar/slugs.rb +80 -80
  25. data/lib/qtc/cli/mar/ssl_certificates.rb +40 -40
  26. data/lib/qtc/cli/mar/stack.rb +29 -29
  27. data/lib/qtc/cli/mdb/base.rb +47 -47
  28. data/lib/qtc/cli/mdb/commands.rb +43 -43
  29. data/lib/qtc/cli/mdb/instances.rb +79 -79
  30. data/lib/qtc/cli/platform/clouds.rb +33 -33
  31. data/lib/qtc/cli/platform/commands.rb +133 -132
  32. data/lib/qtc/cli/platform/datacenters.rb +23 -23
  33. data/lib/qtc/cli/platform/ssh_keys.rb +41 -41
  34. data/lib/qtc/cli/platform/user.rb +29 -25
  35. data/lib/qtc/cli/platform/vpn.rb +93 -93
  36. data/lib/qtc/client.rb +170 -170
  37. data/lib/qtc/eds/client.rb +116 -116
  38. data/lib/qtc/eds/collection.rb +124 -124
  39. data/lib/qtc/eds/user_collection.rb +13 -13
  40. data/lib/qtc/eds/usergroup_collection.rb +41 -41
  41. data/lib/qtc/errors.rb +13 -13
  42. data/lib/qtc/version.rb +3 -3
  43. data/qtc-sdk.gemspec +28 -28
  44. data/spec/spec_helper.rb +17 -0
  45. data/spec/unit/qtc/client_spec.rb +147 -147
  46. metadata +5 -3
@@ -1,266 +1,268 @@
1
- require_relative 'apps'
2
- require_relative 'domains'
3
- require_relative 'ssl_certificates'
4
- require_relative 'env'
5
- require_relative 'repository'
6
- require_relative 'debug'
7
- require_relative 'stack'
8
- require_relative 'slugs'
9
-
10
- command 'mar list' do |c|
11
- c.syntax = 'qtc-cli mar list'
12
- c.description = 'List all apps'
13
- c.action do |args, options|
14
- Qtc::Cli::Mar::Apps.new.list
15
- end
16
- end
17
-
18
- command 'mar show' do |c|
19
- c.syntax = 'qtc-cli mar show'
20
- c.description = 'Show app details'
21
- c.example 'Show app details for app with instance id: mar-eu-1-example', 'qtc-cli mar show --app mar-eu-1-example'
22
- c.option '--app APP', String, 'App instance id'
23
- c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
24
- c.action do |args, options|
25
- Qtc::Cli::Mar::Apps.new.show(options)
26
- end
27
- end
28
-
29
- command 'mar restart' do |c|
30
- c.syntax = 'qtc-cli mar restart'
31
- c.description = 'Restart app'
32
- c.option '--app APP', String, 'App instance id'
33
- c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
34
- c.action do |args, options|
35
- Qtc::Cli::Mar::Apps.new.restart(options)
36
- end
37
- end
38
-
39
- command 'mar create' do |c|
40
- c.syntax = 'qtc-cli mar create NAME'
41
- c.description = 'Create a new app instance'
42
- c.option '--size SIZE', String, 'App runtime size'
43
- c.action do |args, options|
44
- raise ArgumentError.new('NAME is required') if args[0].nil?
45
- Qtc::Cli::Mar::Apps.new.create(args[0], options)
46
- end
47
- end
48
-
49
- command 'mar stack' do |c|
50
- c.syntax = 'qtc-cli mar stack'
51
- c.description = 'Get app stack'
52
- c.option '--app APP', String, 'App instance id'
53
- c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
54
- c.action do |args, options|
55
- Qtc::Cli::Mar::Stack.new.show(args[0], options)
56
- end
57
- end
58
-
59
- command 'mar stack:set' do |c|
60
- c.syntax = 'qtc-cli mar stack:set STACK'
61
- c.description = 'Set app stack'
62
- c.option '--app APP', String, 'App instance id'
63
- c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
64
- c.action do |args, options|
65
- raise ArgumentError.new('STACK is required') if args[0].nil?
66
- Qtc::Cli::Mar::Stack.new.update(args[0], options)
67
- end
68
- end
69
-
70
- command 'mar scale' do |c|
71
- c.syntax = 'qtc-cli mar scale KEY=VALUE'
72
- c.description = 'Scale app processes'
73
- c.option '--app APP', String, 'App instance id'
74
- c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
75
- c.action do |args, options|
76
- Qtc::Cli::Mar::Apps.new.scale(args, options)
77
- end
78
- end
79
-
80
- command 'mar logs' do |c|
81
- c.syntax = 'qtc-cli mar logs'
82
- c.description = 'List app log entries'
83
- c.option '--app APP', String, 'App instance id'
84
- c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
85
- c.option '--timestamp', String, 'Include timestamp'
86
- c.option '--stream', String, 'stdout or stderr'
87
- c.option '--limit LIMIT', Integer, 'Limit'
88
- c.option '--offset OFFSET', Integer, 'Offset'
89
- c.action do |args, options|
90
- Qtc::Cli::Mar::Apps.new.logs(options)
91
- end
92
- end
93
-
94
- command 'mar domains' do |c|
95
- c.syntax = 'qtc-cli mar domains'
96
- c.description = 'List app domains'
97
- c.option '--app APP', String, 'App instance id'
98
- c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
99
- c.action do |args, options|
100
- Qtc::Cli::Mar::Domains.new.list(options)
101
- end
102
- end
103
-
104
- command 'mar domains:add' do |c|
105
- c.syntax = 'qtc-cli mar domains:add DOMAIN'
106
- c.description = 'Add custom domain to app'
107
- c.option '--app APP', String, 'App instance id'
108
- c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
109
- c.action do |args, options|
110
- raise ArgumentError.new('DOMAIN is required') if args[0].nil?
111
- Qtc::Cli::Mar::Domains.new.create(args[0], options)
112
- end
113
- end
114
-
115
- command 'mar domains:remove' do |c|
116
- c.syntax = 'qtc-cli domains:remove DOMAIN'
117
- c.description = 'Remove custom domain from app'
118
- c.option '--app APP', String, 'App instance id'
119
- c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
120
- c.action do |args, options|
121
- raise ArgumentError.new('DOMAIN is required') if args[0].nil?
122
- Qtc::Cli::Mar::Domains.new.destroy(args[0], options)
123
- end
124
- end
125
-
126
- command 'mar envs' do |c|
127
- c.syntax = 'qtc-cli mar envs'
128
- c.description = 'List app environment variables'
129
- c.option '--app APP', String, 'App instance id'
130
- c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
131
- c.action do |args, options|
132
- Qtc::Cli::Mar::Env.new.show(options)
133
- end
134
- end
135
-
136
- command 'mar envs:set' do |c|
137
- c.syntax = 'qtc-cli mar envs:set KEY=value'
138
- c.description = 'Set app environment variable'
139
- c.option '--app APP', String, 'App instance id'
140
- c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
141
- c.action do |args, options|
142
- raise ArgumentError.new("You didn't specify any values") if args[0].nil?
143
- Qtc::Cli::Mar::Env.new.set(args, options)
144
- end
145
- end
146
-
147
- command 'mar ssl:add' do |c|
148
- c.syntax = 'qtc-cli mar ssl:add --key=<path_to_pem> --cert=<path_to_crt>'
149
- c.description = 'Add SSL certificate to app'
150
- c.option '--app APP', String, 'App instance id'
151
- c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
152
- c.option '--key PATH', String, 'Path to private key file'
153
- c.option '--cert PATH', String, 'Path to certificate file'
154
- c.option '--chain PATH', String, 'Path to certificate chain file'
155
- c.action do |args, options|
156
- raise ArgumentError.new("--key is required") unless options.key
157
- raise ArgumentError.new("--cert is required") unless options.cert
158
- Qtc::Cli::Mar::SslCertificates.new.create(options)
159
- end
160
- end
161
-
162
- command 'mar ssl:remove' do |c|
163
- c.syntax = 'qtc-cli mar remove-ssl-cert'
164
- c.description = 'Remove SSL certificate from app'
165
- c.option '--app APP', String, 'App instance id'
166
- c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
167
- c.action do |args, options|
168
- Qtc::Cli::Mar::SslCertificates.new.destroy(options)
169
- end
170
- end
171
-
172
- command 'mar repo:purge_cache' do |c|
173
- c.syntax = 'qtc-cli mar repo:purge_cache'
174
- c.description = 'Delete remote repository build cache contents'
175
- c.option '--app APP', String, 'App instance id'
176
- c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
177
- c.action do |args, options|
178
- Qtc::Cli::Mar::Repository.new.purge_cache(options)
179
- end
180
- end
181
-
182
- command 'mar repo:reset' do |c|
183
- c.syntax = 'qtc-cli mar repo:reset'
184
- c.description = 'Reset remote git repository'
185
- c.option '--app APP', String, 'App instance id'
186
- c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
187
- c.action do |args, options|
188
- Qtc::Cli::Mar::Repository.new.reset(options)
189
- end
190
- end
191
-
192
- command 'mar local:run' do |c|
193
- c.syntax = 'qtc-cli mar local:run'
194
- c.option '--clean', String, 'Force clean build'
195
- c.option '--stack STRING', String, 'Define used stack (default: cedar-14)'
196
- c.description = 'Debug mar app locally (requires docker)'
197
- c.action do |args, options|
198
- Qtc::Cli::Mar::Debug.new.local_debug(args, options)
199
- end
200
- end
201
-
202
- command 'mar local:build_slug' do |c|
203
- c.syntax = 'qtc-cli mar local:build_slug'
204
- c.option '--stack STRING', String, 'Define used stack (default: cedar-14)'
205
- c.description = 'Build mar app slug locally (requires docker)'
206
- c.action do |args, options|
207
- Qtc::Cli::Mar::Debug.new.local_build_slug(options)
208
- end
209
- end
210
-
211
- command 'mar exec' do |c|
212
- c.syntax = 'qtc-cli mar exec <cmd>'
213
- c.description = 'Execute command inside app process'
214
- c.option '--process PROCESS_ID', String, 'App process id'
215
- c.option '--app APP', String, 'App instance id'
216
- c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
217
- c.action do |args, options|
218
- raise ArgumentError.new("command required") if args.size == 0
219
- raise ArgumentError.new("--process is required") unless options.process
220
- Qtc::Cli::Mar::Apps.new.exec(args.join(" "), options)
221
- end
222
- end
223
-
224
- command 'mar slug:upload' do |c|
225
- c.syntax = 'qtc-cli mar slug:upload --slug=<path to slug.tgz> --procfile=<path to Procfile> --tag <git hash or arbitrary unique tag>'
226
- c.description = 'Upload ready made slug into app'
227
- c.option '--app APP', String, 'App instance id'
228
- c.option '--slug SLUG', String, 'The path to the slug file'
229
- c.option '--procfile PROCFILE', String , 'The path to Procfile where the process types will be loaded'
230
- c.option '--tag TAG', String, 'The tag to identify the slug. Could be e.g. commit hash if CD system is uploading the slug'
231
- c.action do |args, options|
232
- raise ArgumentError.new("--slug is required") unless options.slug
233
- raise ArgumentError.new("--procfile is required") unless options.procfile
234
- raise ArgumentError.new("--tag is required") unless options.tag
235
- Qtc::Cli::Mar::Slugs.new.upload(options)
236
- end
237
- end
238
-
239
- command 'mar slug:deploy' do |c|
240
- c.syntax = 'qtc-cli mar slug:deploy <tag>'
241
- c.description = 'Deploy slug into app'
242
- c.option '--app APP', String, 'App instance id'
243
- c.action do |args, options|
244
- raise ArgumentError.new("Slug identifier tag required") if args.size == 0
245
- Qtc::Cli::Mar::Slugs.new.deploy(args[0], options)
246
- end
247
- end
248
-
249
- command 'mar slug:list' do |c|
250
- c.syntax = 'qtc-cli mar slug:list'
251
- c.description = 'Deploy slug into app'
252
- c.option '--app APP', String, 'App instance id'
253
- c.action do |args, options|
254
- Qtc::Cli::Mar::Slugs.new.list(options)
255
- end
256
- end
257
-
258
- command 'mar slug:remove' do |c|
259
- c.syntax = 'qtc-cli mar slug:remove <id>'
260
- c.description = 'Removes a slug from system'
261
- c.option '--app APP', String, 'App instance id'
262
- c.action do |args, options|
263
- raise ArgumentError.new("Slug identifier tag required") if args.size == 0
264
- Qtc::Cli::Mar::Slugs.new.remove(args[0], options)
265
- end
266
- end
1
+ require_relative 'apps'
2
+ require_relative 'domains'
3
+ require_relative 'ssl_certificates'
4
+ require_relative 'env'
5
+ require_relative 'repository'
6
+ require_relative 'debug'
7
+ require_relative 'stack'
8
+ require_relative 'slugs'
9
+
10
+ command 'mar list' do |c|
11
+ c.syntax = 'qtc-cli mar list'
12
+ c.description = 'List all apps'
13
+ c.action do |args, options|
14
+ Qtc::Cli::Mar::Apps.new.list
15
+ end
16
+ end
17
+
18
+ command 'mar show' do |c|
19
+ c.syntax = 'qtc-cli mar show'
20
+ c.description = 'Show app details'
21
+ c.example 'Show app details for app with instance id: mar-eu-1-example', 'qtc-cli mar show --app mar-eu-1-example'
22
+ c.option '--app APP', String, 'App instance id'
23
+ c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
24
+ c.action do |args, options|
25
+ Qtc::Cli::Mar::Apps.new.show(options)
26
+ end
27
+ end
28
+
29
+ command 'mar restart' do |c|
30
+ c.syntax = 'qtc-cli mar restart'
31
+ c.description = 'Restart app'
32
+ c.option '--app APP', String, 'App instance id'
33
+ c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
34
+ c.action do |args, options|
35
+ Qtc::Cli::Mar::Apps.new.restart(options)
36
+ end
37
+ end
38
+
39
+ command 'mar create' do |c|
40
+ c.syntax = 'qtc-cli mar create NAME'
41
+ c.description = 'Create a new app instance'
42
+ c.option '--size SIZE', String, 'App runtime size'
43
+ c.action do |args, options|
44
+ raise ArgumentError.new('NAME is required') if args[0].nil?
45
+ Qtc::Cli::Mar::Apps.new.create(args[0], options)
46
+ end
47
+ end
48
+
49
+ command 'mar stack' do |c|
50
+ c.syntax = 'qtc-cli mar stack'
51
+ c.description = 'Get app stack'
52
+ c.option '--app APP', String, 'App instance id'
53
+ c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
54
+ c.action do |args, options|
55
+ Qtc::Cli::Mar::Stack.new.show(args[0], options)
56
+ end
57
+ end
58
+
59
+ command 'mar stack:set' do |c|
60
+ c.syntax = 'qtc-cli mar stack:set STACK'
61
+ c.description = 'Set app stack'
62
+ c.option '--app APP', String, 'App instance id'
63
+ c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
64
+ c.action do |args, options|
65
+ raise ArgumentError.new('STACK is required') if args[0].nil?
66
+ Qtc::Cli::Mar::Stack.new.update(args[0], options)
67
+ end
68
+ end
69
+
70
+ command 'mar scale' do |c|
71
+ c.syntax = 'qtc-cli mar scale KEY=VALUE'
72
+ c.description = 'Scale app processes'
73
+ c.option '--app APP', String, 'App instance id'
74
+ c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
75
+ c.action do |args, options|
76
+ Qtc::Cli::Mar::Apps.new.scale(args, options)
77
+ end
78
+ end
79
+
80
+ command 'mar logs' do |c|
81
+ c.syntax = 'qtc-cli mar logs'
82
+ c.description = 'List app log entries'
83
+ c.option '--app APP', String, 'App instance id'
84
+ c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
85
+ c.option '--timestamp', String, 'Include timestamp'
86
+ c.option '--stream', String, 'stdout or stderr'
87
+ c.option '--limit LIMIT', Integer, 'Limit'
88
+ c.option '--offset OFFSET', Integer, 'Offset'
89
+ c.action do |args, options|
90
+ Qtc::Cli::Mar::Apps.new.logs(options)
91
+ end
92
+ end
93
+
94
+ command 'mar domains' do |c|
95
+ c.syntax = 'qtc-cli mar domains'
96
+ c.description = 'List app domains'
97
+ c.option '--app APP', String, 'App instance id'
98
+ c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
99
+ c.action do |args, options|
100
+ Qtc::Cli::Mar::Domains.new.list(options)
101
+ end
102
+ end
103
+
104
+ command 'mar domains:add' do |c|
105
+ c.syntax = 'qtc-cli mar domains:add DOMAIN'
106
+ c.description = 'Add custom domain to app'
107
+ c.option '--app APP', String, 'App instance id'
108
+ c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
109
+ c.action do |args, options|
110
+ raise ArgumentError.new('DOMAIN is required') if args[0].nil?
111
+ Qtc::Cli::Mar::Domains.new.create(args[0], options)
112
+ end
113
+ end
114
+
115
+ command 'mar domains:remove' do |c|
116
+ c.syntax = 'qtc-cli domains:remove DOMAIN'
117
+ c.description = 'Remove custom domain from app'
118
+ c.option '--app APP', String, 'App instance id'
119
+ c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
120
+ c.action do |args, options|
121
+ raise ArgumentError.new('DOMAIN is required') if args[0].nil?
122
+ Qtc::Cli::Mar::Domains.new.destroy(args[0], options)
123
+ end
124
+ end
125
+
126
+ command 'mar envs' do |c|
127
+ c.syntax = 'qtc-cli mar envs'
128
+ c.description = 'List app environment variables'
129
+ c.option '--app APP', String, 'App instance id'
130
+ c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
131
+ c.action do |args, options|
132
+ Qtc::Cli::Mar::Env.new.show(options)
133
+ end
134
+ end
135
+
136
+ command 'mar envs:set' do |c|
137
+ c.syntax = 'qtc-cli mar envs:set KEY=value'
138
+ c.description = 'Set app environment variable'
139
+ c.option '--app APP', String, 'App instance id'
140
+ c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
141
+ c.action do |args, options|
142
+ raise ArgumentError.new("You didn't specify any values") if args[0].nil?
143
+ Qtc::Cli::Mar::Env.new.set(args, options)
144
+ end
145
+ end
146
+
147
+ command 'mar ssl:add' do |c|
148
+ c.syntax = 'qtc-cli mar ssl:add --key=<path_to_pem> --cert=<path_to_crt>'
149
+ c.description = 'Add SSL certificate to app'
150
+ c.option '--app APP', String, 'App instance id'
151
+ c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
152
+ c.option '--key PATH', String, 'Path to private key file'
153
+ c.option '--cert PATH', String, 'Path to certificate file'
154
+ c.option '--chain PATH', String, 'Path to certificate chain file'
155
+ c.action do |args, options|
156
+ raise ArgumentError.new("--key is required") unless options.key
157
+ raise ArgumentError.new("--cert is required") unless options.cert
158
+ Qtc::Cli::Mar::SslCertificates.new.create(options)
159
+ end
160
+ end
161
+
162
+ command 'mar ssl:remove' do |c|
163
+ c.syntax = 'qtc-cli mar remove-ssl-cert'
164
+ c.description = 'Remove SSL certificate from app'
165
+ c.option '--app APP', String, 'App instance id'
166
+ c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
167
+ c.action do |args, options|
168
+ Qtc::Cli::Mar::SslCertificates.new.destroy(options)
169
+ end
170
+ end
171
+
172
+ command 'mar repo:purge_cache' do |c|
173
+ c.syntax = 'qtc-cli mar repo:purge_cache'
174
+ c.description = 'Delete remote repository build cache contents'
175
+ c.option '--app APP', String, 'App instance id'
176
+ c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
177
+ c.action do |args, options|
178
+ Qtc::Cli::Mar::Repository.new.purge_cache(options)
179
+ end
180
+ end
181
+
182
+ command 'mar repo:reset' do |c|
183
+ c.syntax = 'qtc-cli mar repo:reset'
184
+ c.description = 'Reset remote git repository'
185
+ c.option '--app APP', String, 'App instance id'
186
+ c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
187
+ c.action do |args, options|
188
+ Qtc::Cli::Mar::Repository.new.reset(options)
189
+ end
190
+ end
191
+
192
+ command 'mar local:run' do |c|
193
+ c.syntax = 'qtc-cli mar local:run'
194
+ c.option '--clean', String, 'Force clean build'
195
+ c.option '--stack STRING', String, 'Define used stack (default: cedar-14)'
196
+ c.option '--branch STRING', String, 'Define used git branch (default: master)'
197
+ c.description = 'Debug mar app locally (requires docker)'
198
+ c.action do |args, options|
199
+ Qtc::Cli::Mar::Debug.new.local_debug(args, options)
200
+ end
201
+ end
202
+
203
+ command 'mar local:build_slug' do |c|
204
+ c.syntax = 'qtc-cli mar local:build_slug'
205
+ c.option '--stack STRING', String, 'Define used stack (default: cedar-14)'
206
+ c.option '--branch STRING', String, 'Define used git branch (default: master)'
207
+ c.description = 'Build mar app slug locally (requires docker)'
208
+ c.action do |args, options|
209
+ Qtc::Cli::Mar::Debug.new.local_build_slug(options)
210
+ end
211
+ end
212
+
213
+ command 'mar exec' do |c|
214
+ c.syntax = 'qtc-cli mar exec <cmd>'
215
+ c.description = 'Execute command inside app process'
216
+ c.option '--process PROCESS_ID', String, 'App process id'
217
+ c.option '--app APP', String, 'App instance id'
218
+ c.option '--remote REMOTE', String, 'Git remote to use, eg "staging"'
219
+ c.action do |args, options|
220
+ raise ArgumentError.new("command required") if args.size == 0
221
+ raise ArgumentError.new("--process is required") unless options.process
222
+ Qtc::Cli::Mar::Apps.new.exec(args.join(" "), options)
223
+ end
224
+ end
225
+
226
+ command 'mar slug:upload' do |c|
227
+ c.syntax = 'qtc-cli mar slug:upload --slug=<path to slug.tgz> --procfile=<path to Procfile> --tag <git hash or arbitrary unique tag>'
228
+ c.description = 'Upload ready made slug into app'
229
+ c.option '--app APP', String, 'App instance id'
230
+ c.option '--slug SLUG', String, 'The path to the slug file'
231
+ c.option '--procfile PROCFILE', String , 'The path to Procfile where the process types will be loaded'
232
+ c.option '--tag TAG', String, 'The tag to identify the slug. Could be e.g. commit hash if CD system is uploading the slug'
233
+ c.action do |args, options|
234
+ raise ArgumentError.new("--slug is required") unless options.slug
235
+ raise ArgumentError.new("--procfile is required") unless options.procfile
236
+ raise ArgumentError.new("--tag is required") unless options.tag
237
+ Qtc::Cli::Mar::Slugs.new.upload(options)
238
+ end
239
+ end
240
+
241
+ command 'mar slug:deploy' do |c|
242
+ c.syntax = 'qtc-cli mar slug:deploy <tag>'
243
+ c.description = 'Deploy slug into app'
244
+ c.option '--app APP', String, 'App instance id'
245
+ c.action do |args, options|
246
+ raise ArgumentError.new("Slug identifier tag required") if args.size == 0
247
+ Qtc::Cli::Mar::Slugs.new.deploy(args[0], options)
248
+ end
249
+ end
250
+
251
+ command 'mar slug:list' do |c|
252
+ c.syntax = 'qtc-cli mar slug:list'
253
+ c.description = 'Deploy slug into app'
254
+ c.option '--app APP', String, 'App instance id'
255
+ c.action do |args, options|
256
+ Qtc::Cli::Mar::Slugs.new.list(options)
257
+ end
258
+ end
259
+
260
+ command 'mar slug:remove' do |c|
261
+ c.syntax = 'qtc-cli mar slug:remove <id>'
262
+ c.description = 'Removes a slug from system'
263
+ c.option '--app APP', String, 'App instance id'
264
+ c.action do |args, options|
265
+ raise ArgumentError.new("Slug identifier tag required") if args.size == 0
266
+ Qtc::Cli::Mar::Slugs.new.remove(args[0], options)
267
+ end
268
+ end