canzea 0.1.54 → 0.1.55

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 61fc6c085e9b8ccf352dff98ba1bf5cb1ed681f3
4
- data.tar.gz: 50be7b982e52f3b127878f7e5c37ce1c88f4ec37
3
+ metadata.gz: cce9704401be639be72063717b47d776a9b1cdd1
4
+ data.tar.gz: 68a790bf026914a2d38232d4575abcf84fa870e0
5
5
  SHA512:
6
- metadata.gz: 46a9a451ee1ac1f49d2a3c3de00d2286a590bc869f952750c6b5ee98bb39b75971a17f6849c4562d4d511a8fe0d4b7615734586bd0eae45df90ac0a2f9a3e398
7
- data.tar.gz: f6bef28cac056c5f3d49b124770ca3dc73772a56d9881e57293082e7a1ad3828224dad83be960a4277663a824aa82f4dd303656a8eb2228d3cbd0702e5b8bf03
6
+ metadata.gz: d0de7f805d78039473cbd95a173f16d47480115c90f89c4d3810697d11a86e192ee628d3be6057997891b185ff3e74b772628259cec3c67084563623ca3a35b6
7
+ data.tar.gz: 4d5e45b66fbddb5dea10aea277e3716669e7a4869206ccde37956f72b95e236fe918c8b57e9cbff6e1e0385cea5df7d204fcaae8b879ba271b9d5f59de54b62a
@@ -1,3 +1,3 @@
1
1
  module Canzea
2
- VERSION = "0.1.54"
2
+ VERSION = "0.1.55"
3
3
  end
data/lib/canzea.rb CHANGED
@@ -16,6 +16,7 @@ require "commands/remote-bootstrap"
16
16
  require "commands/gen-user"
17
17
  require "commands/update-config"
18
18
  require "commands/apply-config"
19
+ require "commands/add-env"
19
20
 
20
21
  module Canzea
21
22
  command = Cri::Command.define do
@@ -95,6 +96,12 @@ module Canzea
95
96
 
96
97
  if (opts[:util])
97
98
  util = opts[:util]
99
+ if (util == "add-env")
100
+ AddEnv.new.add(args[0], args[1])
101
+ end
102
+ if (util == "add-env-secret")
103
+ AddEnv.new.addSecret(args[0], args[1])
104
+ end
98
105
 
99
106
  if (util == "gen-user")
100
107
  GenUser.new.do(args[0])
@@ -0,0 +1,49 @@
1
+ require 'json'
2
+ require 'plan-step-class'
3
+
4
+ class AddEnv
5
+
6
+ def add (key, value)
7
+ extraConfig = Canzea::config[:catalog_location] + "/env.json"
8
+ envs = loadFile()
9
+ envs["vars"][key] = value
10
+ File.write(extraConfig, JSON.generate(envs))
11
+ end
12
+
13
+ def addSecret (key, value)
14
+ extraConfig = Canzea::config[:catalog_location] + "/env.json"
15
+ envs = loadFile()
16
+ envs['secrets'][key] = value
17
+ File.write(extraConfig, JSON.generate(envs))
18
+ end
19
+
20
+ def loadFile()
21
+ extraConfig = Canzea::config[:catalog_location] + "/env.json"
22
+ if File.exists?(extraConfig)
23
+ file = File.read(extraConfig)
24
+ envs = JSON.parse(file)
25
+ else
26
+ envs = {"vars"=>{}, "secrets"=>{}}
27
+ end
28
+ return envs
29
+ end
30
+
31
+ def injectEnvironmentVariables()
32
+ extraConfig = Canzea::config[:catalog_location] + "/env.json"
33
+ if File.exists?(extraConfig)
34
+ puts "-- Reading #{extraConfig}"
35
+ file = File.read(extraConfig)
36
+ envs = JSON.parse(file)
37
+ envs['vars'].keys.each { | key |
38
+ val = envs['vars'][key]
39
+ puts "-- #{key} == #{val}"
40
+ ENV.store(key, val)
41
+ }
42
+ envs['secrets'].keys.each { | key |
43
+ val = envs['secrets'][key]
44
+ puts "-- #{key} == XXXXXX"
45
+ ENV.store(key, val)
46
+ }
47
+ end
48
+ end
49
+ end
@@ -1,4 +1,5 @@
1
1
  require 'json'
2
+ require 'commands/add-env'
2
3
  require 'plan-step-class'
3
4
 
4
5
  class ApplyConfig
@@ -14,7 +15,7 @@ class ApplyConfig
14
15
  index = 1
15
16
  steps["steps"].each { | step |
16
17
 
17
- injectEnvironmentVariables()
18
+ AddEnv.new.injectEnvironmentVariables()
18
19
 
19
20
  role = step['role']
20
21
  solution = step['solution']
@@ -28,18 +29,4 @@ class ApplyConfig
28
29
  }
29
30
  end
30
31
 
31
- def injectEnvironmentVariables()
32
- extraConfig = Canzea::config[:catalog_location] + "/env.json"
33
- if File.exists?(extraConfig)
34
- puts "-- Reading #{extraConfig}"
35
- file = File.read(extraConfig)
36
- envs = JSON.parse(file)
37
- envs.keys.each { | key |
38
- puts "#{key} == #{envs[key]}"
39
- ENV.store(key, envs[key])
40
- }
41
- end
42
-
43
- end
44
-
45
32
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canzea
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.54
4
+ version: 0.1.55
5
5
  platform: ruby
6
6
  authors:
7
7
  - Canzea Technologies
@@ -165,6 +165,7 @@ files:
165
165
  - lib/canzea/config.rb
166
166
  - lib/canzea/environment.rb
167
167
  - lib/canzea/version.rb
168
+ - lib/commands/add-env.rb
168
169
  - lib/commands/apply-config.rb
169
170
  - lib/commands/config-git-commit.rb
170
171
  - lib/commands/gen-user.rb