nex_client 0.8.0 → 0.9.0
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.
- checksums.yaml +4 -4
- data/lib/nex_client/cli.rb +2 -1
- data/lib/nex_client/commands/apps.rb +28 -4
- data/lib/nex_client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3837e3133c42a8c3735aae86123e048b5ec939d0
|
4
|
+
data.tar.gz: 2942fc4186c219f2d5759528bad9d14ed8d12d02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68749c7e6061043bc4671add57f9d9cd4630cfa66df639b5332e318c1ed49e8779042f6bea0f1328fbff77780d10afd7caba75283578048feb2f7ce5a034f899
|
7
|
+
data.tar.gz: 28b49d85667fcde6ed8e08d036e601417aebac98ccd00a5c9ffb22c28f7c7f4bfe63475875b31c03c505cad5e8c8a7b1b22a0021bf38f0e82dfb25f06d5efe82
|
data/lib/nex_client/cli.rb
CHANGED
@@ -121,7 +121,7 @@ module NexClient
|
|
121
121
|
c.description = 'Create new docker applications'
|
122
122
|
c.example 'create new rails application', 'nex-cli apps:create rails'
|
123
123
|
c.option '--env MYVAR=value,MYVAR2=value,...', Array, 'comma separated list of env variables'
|
124
|
-
c.option '--env-file FILE', 'newline separated list of env variables'
|
124
|
+
c.option '--env-file FILE', String, 'newline separated list of env variables (MYVAR=1) or YAML file'
|
125
125
|
c.option '--no-ssl', 'disable SSL support (enabled by default)'
|
126
126
|
c.option '--storage', 'enable persistent storage (/!\ only one node allowed)'
|
127
127
|
c.option '--owner ORGANIZATION_HANDLE', 'specify an organisation as owner (organization admin only)'
|
@@ -238,6 +238,7 @@ module NexClient
|
|
238
238
|
c.example 'Delete env variables from myapp', 'nex-cli apps:vars myapp --delete MYVAR,MYVAR'
|
239
239
|
c.option '--add MYVAR=value,MYVAR2=value,...', Array, 'comma separated list of env variables'
|
240
240
|
c.option '--delete MYVAR,MYVAR2,...', Array, 'comma separated list of env variables'
|
241
|
+
c.option '--env-file FILE', String, 'newline separated list of env variables (MYVAR=1) or YAML file'
|
241
242
|
c.action do |args, options|
|
242
243
|
NexClient::Commands::Apps.manage_vars(args,options)
|
243
244
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
require 'yaml'
|
2
3
|
|
3
4
|
module NexClient
|
4
5
|
module Commands
|
@@ -109,10 +110,8 @@ module NexClient
|
|
109
110
|
|
110
111
|
# Env variables from file
|
111
112
|
if opts.env_file.present?
|
112
|
-
f = File.read(opts.env_file)
|
113
113
|
attrs[:vars] ||= {}
|
114
|
-
|
115
|
-
key,val = e.split('=',2)
|
114
|
+
self.vars_from_file(opts.env_file) do |key,val|
|
116
115
|
attrs[:vars][key] = val
|
117
116
|
end
|
118
117
|
end
|
@@ -260,7 +259,7 @@ module NexClient
|
|
260
259
|
end
|
261
260
|
|
262
261
|
# Add/Delete vars
|
263
|
-
if opts.add.present? || opts.delete.present?
|
262
|
+
if opts.add.present? || opts.delete.present? || opts.env_file.present?
|
264
263
|
vars = (e.vars || {}).dup
|
265
264
|
|
266
265
|
# Add vars
|
@@ -269,6 +268,13 @@ module NexClient
|
|
269
268
|
vars[key] = val
|
270
269
|
end
|
271
270
|
|
271
|
+
# Add vars from file
|
272
|
+
if opts.env_file.present?
|
273
|
+
self.vars_from_file(opts.env_file) do |key,val|
|
274
|
+
vars[key] = val
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
272
278
|
# Delete vars
|
273
279
|
(opts.delete || []).each { |k| vars.delete(k) }
|
274
280
|
|
@@ -367,6 +373,24 @@ module NexClient
|
|
367
373
|
return '-' unless record.node_count && record.max_node_count
|
368
374
|
"#{record.node_count}/#{record.max_node_count}"
|
369
375
|
end
|
376
|
+
|
377
|
+
def self.vars_from_file(file,&block)
|
378
|
+
# YAML file
|
379
|
+
if file =~ /(\.yml|\.yaml)$/
|
380
|
+
vars = YAML.load_file(file)
|
381
|
+
vars.each do |k,v|
|
382
|
+
yield(k,v)
|
383
|
+
end
|
384
|
+
else
|
385
|
+
f = File.read(file)
|
386
|
+
f.split("\n").each do |e|
|
387
|
+
line = e.strip
|
388
|
+
next if line.empty? || line.start_with?('#')
|
389
|
+
key,val = e.split('=',2)
|
390
|
+
yield(key,val)
|
391
|
+
end
|
392
|
+
end
|
393
|
+
end
|
370
394
|
end
|
371
395
|
end
|
372
396
|
end
|
data/lib/nex_client/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nex_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arnaud Lachaume
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json_api_client
|