nex_client 0.17.0 → 0.18.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nex_client.rb +6 -0
- data/lib/nex_client/addon.rb +15 -0
- data/lib/nex_client/app.rb +4 -0
- data/lib/nex_client/base_resource.rb +15 -0
- data/lib/nex_client/cli.rb +35 -124
- data/lib/nex_client/commands.rb +5 -0
- data/lib/nex_client/commands/addons.rb +11 -31
- data/lib/nex_client/commands/apps.rb +8 -44
- data/lib/nex_client/commands/cube_instances.rb +0 -21
- data/lib/nex_client/commands/events.rb +60 -0
- data/lib/nex_client/commands/helpers.rb +0 -50
- data/lib/nex_client/commands/ip_whitelisting.rb +124 -0
- data/lib/nex_client/commands/logs.rb +58 -0
- data/lib/nex_client/commands/policies.rb +184 -0
- data/lib/nex_client/commands/waf.rb +134 -0
- data/lib/nex_client/cube_instance.rb +9 -0
- data/lib/nex_client/exec_cmd.rb +17 -0
- data/lib/nex_client/faraday_middleware.rb +8 -0
- data/lib/nex_client/faraday_middleware/handle_nex_api_errors.rb +39 -0
- data/lib/nex_client/version.rb +1 -1
- data/spec/nex_client/app_spec.rb +2 -0
- data/spec/nex_client/cube_instance_spec.rb +2 -0
- data/spec/nex_client/exec_cmd_spec.rb +14 -0
- data/spec/shared/base_resource.rb +38 -0
- data/spec/spec_helper.rb +8 -53
- data/spec/support/is_expected_block.rb +5 -0
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66bd6974504b943354286cb011099b8253e2556b
|
4
|
+
data.tar.gz: 35dccc4896e4a3b77903803fcde4f828b4254d88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cec6f39591d8d9fcdc00b5f5c6c263c488daefa1cd537a15f7cefbaac547fd9e0c617f77e7a460c4eab26c7f755e7ba2062742b25903ce340eb38f18fbb52e61
|
7
|
+
data.tar.gz: 41b075642837ce12f28bb4da41695b327fe68c6e02429cd29cc9401d9486c01ee91db32a051ccb65d8a31ff2a259e794e6b7ae23802b750cbd8e0bfd0b9414d4
|
data/lib/nex_client.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
require 'json_api_client'
|
3
3
|
require 'active_support/all'
|
4
4
|
require 'nex_client/version'
|
5
|
+
require 'nex_client/faraday_middleware'
|
5
6
|
require 'launchy'
|
6
7
|
|
7
8
|
module NexClient
|
@@ -13,6 +14,7 @@ module NexClient
|
|
13
14
|
autoload :CubeTemplate, 'nex_client/cube_template'
|
14
15
|
autoload :Domain, 'nex_client/domain'
|
15
16
|
autoload :Event, 'nex_client/event'
|
17
|
+
autoload :ExecCmd, 'nex_client/exec_cmd'
|
16
18
|
autoload :ExecTask, 'nex_client/exec_task'
|
17
19
|
autoload :GatewayRack, 'nex_client/gateway_rack'
|
18
20
|
autoload :Me, 'nex_client/me'
|
@@ -21,4 +23,8 @@ module NexClient
|
|
21
23
|
autoload :SslCertificate, 'nex_client/ssl_certificate'
|
22
24
|
autoload :StorageRack, 'nex_client/storage_rack'
|
23
25
|
autoload :User, 'nex_client/user'
|
26
|
+
|
27
|
+
def self.interactive?
|
28
|
+
defined?(NexClient::Cli) && ENV['NEX_ENV'] != 'test'
|
29
|
+
end
|
24
30
|
end
|
data/lib/nex_client/addon.rb
CHANGED
@@ -15,5 +15,20 @@ module NexClient
|
|
15
15
|
|
16
16
|
# PATCH <api_root>/addons/:id/scale_down
|
17
17
|
custom_endpoint :scale_down, on: :member, request_method: :patch
|
18
|
+
|
19
|
+
def self.main_key
|
20
|
+
:name
|
21
|
+
end
|
22
|
+
|
23
|
+
def preferred_region
|
24
|
+
super
|
25
|
+
rescue
|
26
|
+
NexClient::Addon.includes(:app)
|
27
|
+
.with_params(fields: { apps: :preferred_region })
|
28
|
+
.find(id)
|
29
|
+
.first
|
30
|
+
.app
|
31
|
+
.preferred_region
|
32
|
+
end
|
18
33
|
end
|
19
34
|
end
|
data/lib/nex_client/app.rb
CHANGED
@@ -24,6 +24,10 @@ module NexClient
|
|
24
24
|
# GET <api_root>/apps/:id/logs
|
25
25
|
custom_endpoint :logs, on: :member, request_method: :get
|
26
26
|
|
27
|
+
def self.main_key
|
28
|
+
:name
|
29
|
+
end
|
30
|
+
|
27
31
|
def preferred_url
|
28
32
|
domain = self.domains.first rescue NexClient::Domain.find('origin.name' => self.name).first
|
29
33
|
if domain
|
@@ -12,10 +12,25 @@ module NexClient
|
|
12
12
|
API_HOST = ENV['NEX_ENDPOINT'] || HOST_MAPPING[ENVIRONMENT]
|
13
13
|
|
14
14
|
self.site = "#{API_HOST}#{API_ROOT_PATH}"
|
15
|
+
|
16
|
+
def self.entities_name
|
17
|
+
entity_name.pluralize
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.entity_name
|
21
|
+
to_s.split('::').last.parameterize
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.main_key
|
25
|
+
:id
|
26
|
+
end
|
15
27
|
end
|
16
28
|
end
|
17
29
|
|
18
30
|
NexClient::BaseResource.connection do |connection|
|
19
31
|
# Set Auth
|
20
32
|
connection.use Faraday::Request::BasicAuthentication, ENV['NEX_API_KEY'], ''
|
33
|
+
|
34
|
+
# Handle Response Errors including MFA authentication errors
|
35
|
+
connection.use NexClient::FaradayMiddleware::HandleNexApiErrors
|
21
36
|
end
|
data/lib/nex_client/cli.rb
CHANGED
@@ -38,7 +38,6 @@ module NexClient
|
|
38
38
|
c.example 'create redis addon for myapp', 'nex-cli addons:create redis myapp'
|
39
39
|
c.option '--size SIZE', Integer, 'specify container size (default: 2, min: 1, max: 20). Container will have N shares of CPU and N*128M of memory.'
|
40
40
|
c.option '--http-log-drain DRAIN_URL', String, 'specify the URL of a remote log drain'
|
41
|
-
c.option '--region-balancing REGIONS', String, 'specify how the addon should be proportionally distributed geographically. E.g. "all" or "ap-southeast-1,us-west-2" or "ap-southeast-1=1,us-west-2=2".'
|
42
41
|
c.action do |args, options|
|
43
42
|
NexClient::Commands::Addons.create(args,options)
|
44
43
|
end
|
@@ -68,16 +67,7 @@ module NexClient
|
|
68
67
|
end
|
69
68
|
|
70
69
|
command :'addons:events' do |c|
|
71
|
-
c
|
72
|
-
c.summary = 'Gather system events'
|
73
|
-
c.description = 'Gather system events for a given addon'
|
74
|
-
c.example 'display events for myaddon', 'nex-cli addons:events myaddon'
|
75
|
-
c.example 'display 100 events for myaddon', 'nex-cli addons:events --tail 100 myaddon'
|
76
|
-
c.option '--tail NUMBER', String, 'number of events to retrieve (default: 50)'
|
77
|
-
c.option '--type TYPE', String, 'filter events on type (e.g. status, container)'
|
78
|
-
c.action do |args, options|
|
79
|
-
NexClient::Commands::Addons.events(args,options)
|
80
|
-
end
|
70
|
+
NexClient::Commands::Events.configure(c, NexClient::Addon)
|
81
71
|
end
|
82
72
|
|
83
73
|
command :'addons:info' do |c|
|
@@ -92,15 +82,7 @@ module NexClient
|
|
92
82
|
end
|
93
83
|
|
94
84
|
command :'addons:logs' do |c|
|
95
|
-
c
|
96
|
-
c.summary = 'Gather addon logs'
|
97
|
-
c.description = 'Gather container logs for a given addon'
|
98
|
-
c.example 'gather logs for myaddon', 'nex-cli addons:logs myaddon'
|
99
|
-
c.example 'gather logs for myapp with a tail of 50', 'nex-cli addons:logs --tail 50 myaddon'
|
100
|
-
c.option '--tail NUMBER', String, 'number of lines to retrieve for each container'
|
101
|
-
c.action do |args, options|
|
102
|
-
NexClient::Commands::Addons.logs(args,options)
|
103
|
-
end
|
85
|
+
NexClient::Commands::Logs.configure(c, NexClient::Addon)
|
104
86
|
end
|
105
87
|
|
106
88
|
command :'addons:restart' do |c|
|
@@ -136,17 +118,17 @@ module NexClient
|
|
136
118
|
end
|
137
119
|
end
|
138
120
|
|
121
|
+
command :'addons:policies' do |c|
|
122
|
+
NexClient::Commands::Policies.configure(c, NexClient::Addon)
|
123
|
+
end
|
124
|
+
|
139
125
|
command :'addons:update' do |c|
|
140
126
|
c.syntax = 'nex-cli addons:update ADDON_NAME [options]'
|
141
127
|
c.summary = 'Update addon settings'
|
142
128
|
c.description = 'Update addon settings'
|
143
129
|
c.example 'change container size to 4', 'nex-cli addons:update myaddon --size 4'
|
144
|
-
c.example 'balance containers equally between regions', 'nex-cli apps:update myapp --region-balancing="ap-southeast-1,us-west-2"'
|
145
|
-
c.example 'deploy more containers in one region', 'nex-cli apps:update myapp --region-balancing="ap-southeast-1=1,us-west-2=2"'
|
146
|
-
c.example 'scale containers across all regions', 'nex-cli apps:update myapp --region-balancing=all'
|
147
130
|
c.option '--size SIZE', Integer, 'change container size (default: 2, min: 1, max: 20). Container will have N shares of CPU and N*128M of memory. [restart required]'
|
148
131
|
c.option '--http-log-drain DRAIN_URL', String, 'specify the URL of a remote log drain. [restart required]'
|
149
|
-
c.option '--region-balancing REGIONS', String, 'specify how scalability should be handled per region. E.g. "all" or "ap-southeast-1,us-west-2" or "ap-southeast-1=1,us-west-2=2".'
|
150
132
|
c.action do |args, options|
|
151
133
|
NexClient::Commands::Addons.update(args,options)
|
152
134
|
end
|
@@ -189,7 +171,6 @@ module NexClient
|
|
189
171
|
c.option '--desc DESCRIPTION', String, 'description for this application (140 characters max)'
|
190
172
|
c.option '--tags TAG_LIST', Array, 'comma separated list of tags describing this app'
|
191
173
|
c.option '--region REGION', String, 'default region to use deploy/scale this application'
|
192
|
-
c.option '--region-balancing REGIONS', String, 'specify how scalability should be handled per region. E.g. "all" or "ap-southeast-1,us-west-2" or "ap-southeast-1=1,us-west-2=2".'
|
193
174
|
c.action do |args, options|
|
194
175
|
NexClient::Commands::Apps.create(args,options)
|
195
176
|
end
|
@@ -219,16 +200,7 @@ module NexClient
|
|
219
200
|
end
|
220
201
|
|
221
202
|
command :'apps:events' do |c|
|
222
|
-
c
|
223
|
-
c.summary = 'Gather system events'
|
224
|
-
c.description = 'Gather system events for a given app'
|
225
|
-
c.example 'display events for myapp', 'nex-cli apps:events myapp'
|
226
|
-
c.example 'display 100 events for myapp', 'nex-cli apps:events --tail 100 myapp'
|
227
|
-
c.option '--tail NUMBER', String, 'number of events to retrieve (default: 50)'
|
228
|
-
c.option '--type TYPE', String, 'filter events on type (e.g. status, container)'
|
229
|
-
c.action do |args, options|
|
230
|
-
NexClient::Commands::Apps.events(args,options)
|
231
|
-
end
|
203
|
+
NexClient::Commands::Events.configure(c, NexClient::App)
|
232
204
|
end
|
233
205
|
|
234
206
|
command :'apps:info' do |c|
|
@@ -242,16 +214,12 @@ module NexClient
|
|
242
214
|
end
|
243
215
|
end
|
244
216
|
|
217
|
+
command :'apps:ip-rules' do |c|
|
218
|
+
NexClient::Commands::IpWhitelisting.configure(c)
|
219
|
+
end
|
220
|
+
|
245
221
|
command :'apps:logs' do |c|
|
246
|
-
c
|
247
|
-
c.summary = 'Gather app logs'
|
248
|
-
c.description = 'Gather container logs for a given app'
|
249
|
-
c.example 'gather logs for myapp', 'nex-cli apps:logs myapp'
|
250
|
-
c.example 'gather logs for myapp with a tail of 50', 'nex-cli apps:logs --tail 50 myapp'
|
251
|
-
c.option '--tail NUMBER', String, 'number of lines to retrieve for each container'
|
252
|
-
c.action do |args, options|
|
253
|
-
NexClient::Commands::Apps.logs(args,options)
|
254
|
-
end
|
222
|
+
NexClient::Commands::Logs.configure(c, NexClient::App)
|
255
223
|
end
|
256
224
|
|
257
225
|
command :'apps:restart' do |c|
|
@@ -316,6 +284,20 @@ module NexClient
|
|
316
284
|
end
|
317
285
|
end
|
318
286
|
|
287
|
+
command :'apps:open' do |c|
|
288
|
+
c.syntax = 'nex-cli apps:open APP_NAME'
|
289
|
+
c.summary = 'Open app url'
|
290
|
+
c.description = 'Open app in your browser'
|
291
|
+
c.example 'open app for myapp', 'nex-cli apps:open myapp'
|
292
|
+
c.action do |args, options|
|
293
|
+
NexClient::Commands::Apps.open(args,options)
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
command :'apps:policies' do |c|
|
298
|
+
NexClient::Commands::Policies.configure(c, NexClient::App)
|
299
|
+
end
|
300
|
+
|
319
301
|
command :'apps:up' do |c|
|
320
302
|
c.syntax = 'nex-cli apps:up APP_NAME [options]'
|
321
303
|
c.summary = 'Scale applications up'
|
@@ -337,71 +319,23 @@ module NexClient
|
|
337
319
|
|
338
320
|
Log drain:
|
339
321
|
----------
|
340
|
-
|
341
|
-
|
322
|
+
Use: --http-log-drain DRAIN_URL
|
323
|
+
The log drain is a HTTP(s) URL where application logs will be POSTed.
|
342
324
|
|
343
325
|
Default region:
|
344
326
|
---------------
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
Geo-Balancing:
|
350
|
-
---------------
|
351
|
-
Use: --region-balancing REGIONS
|
352
|
-
Specify how your containers should be distributed across the available Nex!™ regions. This is only relevant when the Nex!™ platform has been deployed
|
353
|
-
in multiple regions.
|
354
|
-
|
355
|
-
Options are the following:
|
356
|
-
- evenly distribute across all regions: --region-balancing=all
|
357
|
-
- eventy distribute across specified regions: --region-balancing="ap-southeast-1,us-west-2"
|
358
|
-
- distribute with relative weights: --region-balancing="ap-southeast-1=1,us-west-2=2"
|
359
|
-
|
360
|
-
Web Application Firewall (WAF)
|
361
|
-
------------------------------
|
362
|
-
Use: --waf-rules [PATH]
|
363
|
-
Specify a JSON (.json) or YAML (.yml) file describing the security rules to apply/ignore. If no files are specified you will be prompted to
|
364
|
-
paste rules in JSON format in the terminal.
|
365
|
-
The WAF always runs in SIMULATE mode by default - this means security events will be logged but no requests will be blocked.
|
366
|
-
|
367
|
-
The list of base rules applied by default is available here: https://github.com/p0pr0ck5/lua-resty-waf/tree/master/rules
|
368
|
-
|
369
|
-
The base WAF behaviour can be extended by passing a JSON (or YAML) manifest to '--waf-rules' with the following format:
|
370
|
-
{
|
371
|
-
// Whether the WAF should be enabled, disabled or do log-only
|
372
|
-
// 'ACTIVE', 'INACTIVE' or 'SIMULATE'
|
373
|
-
"mode": "SIMULATE",
|
374
|
-
|
375
|
-
// Array of rule IDs to ignore
|
376
|
-
"ignore_rule": [],
|
377
|
-
|
378
|
-
// Array of rulesets to ignore
|
379
|
-
"ignore_ruleset": [],
|
380
|
-
|
381
|
-
// Array of ['rulename','rule'] objects
|
382
|
-
"add_ruleset_string": [],
|
383
|
-
|
384
|
-
// Rules sieves allow you to apply/ignore rules based on a
|
385
|
-
// specific context such as request parameters
|
386
|
-
// Array of ['rule_id', [{ sieve_cond }, { sieve_cond }] ] objects
|
387
|
-
"sieve_rule": []
|
388
|
-
}
|
389
|
-
See this for more info: https://github.com/p0pr0ck5/lua-resty-waf
|
390
|
-
See this for rule sieves: https://github.com/p0pr0ck5/lua-resty-waf/wiki/Rule-Sieves
|
327
|
+
Use: --region REGION
|
328
|
+
Containers will be deployed in the specified region by default if no region-balancing
|
329
|
+
policies have been specified. This is only relevant when the Nex!™ platform has been deployed in multiple regions.
|
391
330
|
|
392
331
|
HEREDOC
|
393
332
|
c.example 'change container size to 4', 'nex-cli apps:update myapp --size 4'
|
394
|
-
c.example 'balance containers equally between regions', 'nex-cli apps:update myapp --region-balancing="ap-southeast-1,us-west-2"'
|
395
|
-
c.example 'deploy more containers in one region', 'nex-cli apps:update myapp --region-balancing="ap-southeast-1=1,us-west-2=2"'
|
396
|
-
c.example 'scale containers across all regions', 'nex-cli apps:update myapp --region-balancing=all'
|
397
333
|
c.option '--desc DESCRIPTION', String, 'update the application description'
|
398
334
|
c.option '--http-log-drain DRAIN_URL', String, 'specify the URL of a remote log drain. [restart required]'
|
399
335
|
c.option '--image-tag IMAGE_TAG', String, 'update the docker image tag [restart required]'
|
400
336
|
c.option '--size SIZE', Integer, 'change container size (default: 2, min: 1, max: 20). Container will have N shares of CPU and N*128M of memory. [restart required]'
|
401
337
|
c.option '--tags TAG_LIST', String, 'comma separated list of tags to use to describe the app'
|
402
338
|
c.option '--region REGION', String, 'default region to use deploy/scale this application'
|
403
|
-
c.option '--region-balancing REGIONS', String, 'specify how the app should be proportionally distributed geographically. E.g. "all" or "ap-southeast-1,us-west-2" or "ap-southeast-1=1,us-west-2=2". [restart required]'
|
404
|
-
c.option '--waf-rules [PATH]', String, 'specify web application firewall rules using JSON or YAML file (prompt will appear otherwise). [restart required]'
|
405
339
|
c.action do |args, options|
|
406
340
|
NexClient::Commands::Apps.update(args,options)
|
407
341
|
end
|
@@ -429,14 +363,8 @@ module NexClient
|
|
429
363
|
end
|
430
364
|
end
|
431
365
|
|
432
|
-
command :'apps:
|
433
|
-
c
|
434
|
-
c.summary = 'Open app url'
|
435
|
-
c.description = 'Open app in your browser'
|
436
|
-
c.example 'open app for myapp', 'nex-cli apps:open myapp'
|
437
|
-
c.action do |args, options|
|
438
|
-
NexClient::Commands::Apps.open(args,options)
|
439
|
-
end
|
366
|
+
command :'apps:waf' do |c|
|
367
|
+
NexClient::Commands::Waf.configure(c)
|
440
368
|
end
|
441
369
|
|
442
370
|
command :certs do |c|
|
@@ -509,16 +437,7 @@ module NexClient
|
|
509
437
|
end
|
510
438
|
|
511
439
|
command :'cubes:events' do |c|
|
512
|
-
c
|
513
|
-
c.summary = 'Gather system events'
|
514
|
-
c.description = 'Gather system events for a given cube'
|
515
|
-
c.example 'display events for mycube', 'nex-cli cubes:events mycube'
|
516
|
-
c.example 'display 100 events for mycube', 'nex-cli cubes:events --tail 100 mycube'
|
517
|
-
c.option '--tail NUMBER', String, 'number of events to retrieve (default: 50)'
|
518
|
-
c.option '--type TYPE', String, 'filter events on type (e.g. status, container)'
|
519
|
-
c.action do |args, options|
|
520
|
-
NexClient::Commands::CubeInstances.events(args,options)
|
521
|
-
end
|
440
|
+
NexClient::Commands::Events.configure(c, NexClient::CubeInstance)
|
522
441
|
end
|
523
442
|
|
524
443
|
command :'cubes:info' do |c|
|
@@ -532,15 +451,7 @@ module NexClient
|
|
532
451
|
end
|
533
452
|
|
534
453
|
command :'cubes:logs' do |c|
|
535
|
-
c
|
536
|
-
c.summary = 'Gather cube logs'
|
537
|
-
c.description = 'Gather container logs for a given cube'
|
538
|
-
c.example 'gather logs for mycube', 'nex-cli cubes:logs mycube'
|
539
|
-
c.example 'gather logs for mycube with a tail of 50', 'nex-cli cubes:logs --tail 50 mycube'
|
540
|
-
c.option '--tail NUMBER', String, 'number of lines to retrieve (default: 30)'
|
541
|
-
c.action do |args, options|
|
542
|
-
NexClient::Commands::CubeInstances.logs(args,options)
|
543
|
-
end
|
454
|
+
NexClient::Commands::Logs.configure(c, NexClient::CubeInstance)
|
544
455
|
end
|
545
456
|
|
546
457
|
command :'cubes:restart' do |c|
|
data/lib/nex_client/commands.rb
CHANGED
@@ -8,11 +8,16 @@ module NexClient
|
|
8
8
|
autoload :CubeInstances, 'nex_client/commands/cube_instances'
|
9
9
|
autoload :CubeTemplates, 'nex_client/commands/cube_templates'
|
10
10
|
autoload :Domains, 'nex_client/commands/domains'
|
11
|
+
autoload :Events, 'nex_client/commands/events'
|
11
12
|
autoload :ExecTasks, 'nex_client/commands/exec_tasks'
|
12
13
|
autoload :Helpers, 'nex_client/commands/helpers'
|
14
|
+
autoload :IpWhitelisting, 'nex_client/commands/ip_whitelisting'
|
15
|
+
autoload :Logs, 'nex_client/commands/logs'
|
13
16
|
autoload :Organizations, 'nex_client/commands/organizations'
|
17
|
+
autoload :Policies, 'nex_client/commands/policies'
|
14
18
|
autoload :Racks, 'nex_client/commands/racks'
|
15
19
|
autoload :SslCertificates, 'nex_client/commands/ssl_certificates'
|
16
20
|
autoload :Users, 'nex_client/commands/users'
|
21
|
+
autoload :Waf, 'nex_client/commands/waf'
|
17
22
|
end
|
18
23
|
end
|
@@ -60,21 +60,6 @@ module NexClient
|
|
60
60
|
Apps.display_apps(e.app)
|
61
61
|
end
|
62
62
|
|
63
|
-
def self.logs(args,opts)
|
64
|
-
name = args.first
|
65
|
-
e = NexClient::Addon.find(name: name).first
|
66
|
-
|
67
|
-
# Display error
|
68
|
-
unless e
|
69
|
-
error("Error! Could not find addon: #{name}")
|
70
|
-
return false
|
71
|
-
end
|
72
|
-
|
73
|
-
# Retrieve logs and display them
|
74
|
-
logs = e.logs(tail: opts.tail).first
|
75
|
-
self.display_logs(logs.log_ret)
|
76
|
-
end
|
77
|
-
|
78
63
|
# SSH to the addon
|
79
64
|
def self.ssh(args,opts)
|
80
65
|
name = args.first
|
@@ -105,8 +90,8 @@ module NexClient
|
|
105
90
|
attrs[:service] = svc_name
|
106
91
|
attrs[:container_size] = opts.size if opts.size.present?
|
107
92
|
|
108
|
-
#
|
109
|
-
attrs[:opts] =
|
93
|
+
# Option: http_log_drain
|
94
|
+
attrs[:opts] = { 'http_log_drain' => opts.http_log_drain } if opts.http_log_drain.present?
|
110
95
|
|
111
96
|
addon = NexClient::Addon.new(attrs)
|
112
97
|
addon.relationships.attributes = { app: { data: { type: 'apps', id: app.id } } }
|
@@ -136,9 +121,11 @@ module NexClient
|
|
136
121
|
attrs = {}
|
137
122
|
attrs[:container_size] = opts.size if opts.size.present?
|
138
123
|
|
139
|
-
#
|
140
|
-
|
141
|
-
|
124
|
+
# Option: http_log_drain
|
125
|
+
if opts.http_log_drain.present?
|
126
|
+
attrs[:opts] = (e.opts || {}).dup
|
127
|
+
attrs[:opts]['http_log_drain'] = opts.http_log_drain
|
128
|
+
end
|
142
129
|
|
143
130
|
# Update
|
144
131
|
e.update_attributes(attrs)
|
@@ -240,7 +227,10 @@ module NexClient
|
|
240
227
|
def self.display_options(list)
|
241
228
|
table = Terminal::Table.new title: OPTS_TITLE, headings: OPTS_HEADERS do |t|
|
242
229
|
[list].flatten.compact.each do |e|
|
243
|
-
e.each
|
230
|
+
e.each do |k,v|
|
231
|
+
val = v.is_a?(Hash) || v.is_a?(Array) ? JSON.pretty_generate(v) : v
|
232
|
+
t.add_row([k,val])
|
233
|
+
end
|
244
234
|
end
|
245
235
|
end
|
246
236
|
puts table
|
@@ -269,16 +259,6 @@ module NexClient
|
|
269
259
|
return '-' unless record.node_count && record.max_node_count
|
270
260
|
"#{record.node_count}/#{record.max_node_count}"
|
271
261
|
end
|
272
|
-
|
273
|
-
def self.extract_config_options(cli_opts)
|
274
|
-
hash = {}
|
275
|
-
%w(http_log_drain region_balancing).each do |opt_name|
|
276
|
-
if cli_opts.method_missing(opt_name.to_sym).present?
|
277
|
-
hash[opt_name.to_s] = cli_opts.method_missing(opt_name.to_sym)
|
278
|
-
end
|
279
|
-
end
|
280
|
-
return hash
|
281
|
-
end
|
282
262
|
end
|
283
263
|
end
|
284
264
|
end
|
@@ -92,22 +92,6 @@ module NexClient
|
|
92
92
|
Launchy.open(url)
|
93
93
|
end
|
94
94
|
|
95
|
-
# Retrieve application logs from all containers
|
96
|
-
def self.logs(args,opts)
|
97
|
-
name = args.first
|
98
|
-
e = NexClient::App.find(name: name).first
|
99
|
-
|
100
|
-
# Display error
|
101
|
-
unless e
|
102
|
-
error("Error! Could not find app: #{name}")
|
103
|
-
return false
|
104
|
-
end
|
105
|
-
|
106
|
-
# Retrieve logs and display them
|
107
|
-
logs = e.logs(tail: opts.tail).first
|
108
|
-
self.display_logs(logs.log_ret)
|
109
|
-
end
|
110
|
-
|
111
95
|
# SSH to the app
|
112
96
|
def self.ssh(args,opts)
|
113
97
|
name = args.first
|
@@ -135,8 +119,8 @@ module NexClient
|
|
135
119
|
attrs[:tag_list] = opts.tags if opts.tags.present?
|
136
120
|
attrs[:preferred_region] = opts.region if opts.region.present?
|
137
121
|
|
138
|
-
#
|
139
|
-
attrs[:opts] =
|
122
|
+
# Option: http_log_drain
|
123
|
+
attrs[:opts] = { 'http_log_drain' => opts.http_log_drain } if opts.http_log_drain.present?
|
140
124
|
|
141
125
|
# Env variables via command line
|
142
126
|
if opts.env.present?
|
@@ -199,20 +183,10 @@ module NexClient
|
|
199
183
|
attrs[:image_tag] = opts.image_tag if opts.image_tag.present?
|
200
184
|
attrs[:preferred_region] = opts.region if opts.region.present?
|
201
185
|
|
202
|
-
#
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
if opts.waf_rules
|
207
|
-
waf_rules = begin
|
208
|
-
if opts.waf_rules.is_a?(String)
|
209
|
-
hash_from_file(opts.waf_rules)
|
210
|
-
else
|
211
|
-
val = ask("Copy/paste your WAF configuration below in JSON format:") { |q| q.gather = "" }
|
212
|
-
JSON.parse(val.join(""))
|
213
|
-
end
|
214
|
-
end
|
215
|
-
attrs[:opts]['waf_rules'] = waf_rules
|
186
|
+
# Option: http_log_drain
|
187
|
+
if opts.http_log_drain.present?
|
188
|
+
attrs[:opts] = (e.opts || {}).dup
|
189
|
+
attrs[:opts]['http_log_drain'] = opts.http_log_drain
|
216
190
|
end
|
217
191
|
|
218
192
|
# Update
|
@@ -445,7 +419,7 @@ module NexClient
|
|
445
419
|
table = Terminal::Table.new title: OPTS_TITLE, headings: OPTS_HEADERS, style: { all_separators: true} do |t|
|
446
420
|
[list].flatten.compact.each do |e|
|
447
421
|
e.each do |k,v|
|
448
|
-
val = v.is_a?(Hash) ? JSON.pretty_generate(v) : v
|
422
|
+
val = v.is_a?(Hash) || v.is_a?(Array) ? JSON.pretty_generate(v) : v
|
449
423
|
t.add_row([k,val])
|
450
424
|
end
|
451
425
|
end
|
@@ -453,7 +427,7 @@ module NexClient
|
|
453
427
|
puts table
|
454
428
|
puts "\n"
|
455
429
|
end
|
456
|
-
|
430
|
+
|
457
431
|
def self.display_scm(list)
|
458
432
|
table = Terminal::Table.new title: SCM_TITLE, headings: SCM_HEADERS do |t|
|
459
433
|
[list].flatten.compact.each do |e|
|
@@ -495,16 +469,6 @@ module NexClient
|
|
495
469
|
return '-' unless record.node_count && record.max_node_count
|
496
470
|
"#{record.node_count}/#{record.max_node_count}"
|
497
471
|
end
|
498
|
-
|
499
|
-
def self.extract_config_options(cli_opts)
|
500
|
-
hash = {}
|
501
|
-
%w(http_log_drain region_balancing).each do |opt_name|
|
502
|
-
if cli_opts.method_missing(opt_name.to_sym).present?
|
503
|
-
hash[opt_name.to_s] = cli_opts.method_missing(opt_name.to_sym)
|
504
|
-
end
|
505
|
-
end
|
506
|
-
return hash
|
507
|
-
end
|
508
472
|
end
|
509
473
|
end
|
510
474
|
end
|