pleme 0.0.9 → 0.0.14
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/pleme/gem/version.rb +1 -1
- data/lib/pleme/plemec_translator.rb +1 -1
- data/lib/pleme/runner.rb +42 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5cc10779a985a7a62ff7f57233212473988a76275b341138c99c733a03640f59
|
4
|
+
data.tar.gz: 59c8dbbf601c86df7a1d62af54b0f608172d127083e89be6d4c117f8deff3fc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2c4286ba39d96159eeb926c05747dfeaac3a2509349f0fb56f8cc807799f5d94806fed2e2879b9dc56835268edb188693ae128da984ed4a06530c25db3abd8e
|
7
|
+
data.tar.gz: 660bd24ead2916720f9204e4d3d911f8bac0d01766abef3bcf4d09551cac88fb89303a71fe7c8b0f2f5451d9346ad12ee5b671520ad3ffc1922c04db82bbebd1
|
data/lib/pleme/gem/version.rb
CHANGED
data/lib/pleme/runner.rb
CHANGED
@@ -6,6 +6,8 @@
|
|
6
6
|
###############################################################################
|
7
7
|
|
8
8
|
require 'pleme/plemec_translator'
|
9
|
+
require 'yaml'
|
10
|
+
require 'json'
|
9
11
|
|
10
12
|
class Runner
|
11
13
|
def initialize
|
@@ -21,6 +23,12 @@ class Runner
|
|
21
23
|
exit 1 unless system(cmd)
|
22
24
|
end
|
23
25
|
|
26
|
+
# pipe hash to yaml without
|
27
|
+
# weird symbol issues
|
28
|
+
def yamilify(rhash)
|
29
|
+
YAML.safe_load(rhash.to_json).to_yaml
|
30
|
+
end
|
31
|
+
|
24
32
|
def run(spec)
|
25
33
|
@spec = spec if @spec.nil?
|
26
34
|
%i[dotfiles apply plan destroy].each do |cli_cmd|
|
@@ -28,28 +36,57 @@ class Runner
|
|
28
36
|
end
|
29
37
|
end
|
30
38
|
|
39
|
+
def read_config
|
40
|
+
@translator.eval_in_context(File.read(@config_path))
|
41
|
+
@translator.inspect
|
42
|
+
end
|
43
|
+
|
31
44
|
def dotfiles(_spec)
|
32
45
|
hax_portal
|
33
46
|
end
|
34
47
|
|
48
|
+
def docker_compose(cwd = :cache)
|
49
|
+
sh "mkdir -p #{cwd}" unless Dir.exist?(cwd)
|
50
|
+
end
|
51
|
+
|
52
|
+
# shell interface for docker-compose
|
53
|
+
def dc(cmd, cwd = :cache)
|
54
|
+
cmd = "cd #{cwd} && docker-compose #{cmd}"
|
55
|
+
sh "mkdir -p #{cwd}" unless Dir.exist?(cwd)
|
56
|
+
sh cmd
|
57
|
+
end
|
58
|
+
|
59
|
+
# shell interface for terraform
|
35
60
|
def tf(cmd, cwd = :cache)
|
36
61
|
sh "mkdir -p #{cwd}" unless Dir.exist?(cwd)
|
37
62
|
cmd = "cd #{cwd} && terraform #{cmd}"
|
38
63
|
@translator.eval_in_context(File.read(@config_path))
|
39
|
-
File.write(File.join(cwd, 'template.json'))
|
40
64
|
sh cmd
|
41
65
|
sh "rm -rf #{File.join(cmd, 'template.json')}"
|
42
66
|
end
|
43
67
|
|
44
|
-
def apply
|
45
|
-
|
68
|
+
def apply(_spec)
|
69
|
+
config = read_config
|
70
|
+
config[:pleme].keys.each do |pkey|
|
71
|
+
pkey = pkey.to_sym if pkey.instance_of?(String)
|
72
|
+
case pkey
|
73
|
+
when :compose
|
74
|
+
@translator.inspect[:pleme][:environment].keys.each do |env|
|
75
|
+
File.write(
|
76
|
+
yamilify(config[:pleme][:environment][env][:compose]),
|
77
|
+
File.join(cwd, 'docker-compose.yml')
|
78
|
+
)
|
79
|
+
dc 'up'
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
46
83
|
end
|
47
84
|
|
48
|
-
def plan
|
85
|
+
def plan(_spec)
|
49
86
|
tf 'plan'
|
50
87
|
end
|
51
88
|
|
52
|
-
def destroy
|
89
|
+
def destroy(_spec)
|
53
90
|
tf 'destroy'
|
54
91
|
end
|
55
92
|
|