pleme 0.0.10 → 0.0.11
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 +37 -1
- 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: fcd0b3e57aafa2ca97c4fe4622e968d6a72bdd6fc26b52568f16a06b506beb42
|
4
|
+
data.tar.gz: 4bc9de4677a0fa82c6d8758b0a6777cfe7f5c67e3226a76919cbd65b04390a4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30d83c8767a7e4e37ad645d4d2b37f13ce4633a90d04ba19bdb0c55b97977a5c617e98ee618d46172bfc9949b8d4cdc2affe5151a40c5b5e47e67bfcbc088768
|
7
|
+
data.tar.gz: 8fc27ed834e664449948b4606b9d0e7a039362fb369206232d96538b8b90dd310c9ec408f2e56666bf250a38ca960979b5b778262153ac14215577e218b954a0
|
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,15 +36,43 @@ 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
|
+
sh "mkdir -p #{cwd}" unless Dir.exist?(cwd)
|
55
|
+
@translator.eval_in_context(File.read(@config_path))
|
56
|
+
cmd = "cd #{cwd} && docker-compose #{cmd}"
|
57
|
+
@translator.inspect[:pleme].keys.each do |pkey|
|
58
|
+
pkey = pkey.to_sym if pkey.instance_of?(String)
|
59
|
+
next unless pkey.eql? :compose
|
60
|
+
|
61
|
+
@translator.inspect[:pleme][:environment].keys.each do |env|
|
62
|
+
File.write(
|
63
|
+
yamilify(inspect[:pleme][:environment][env][:compose]),
|
64
|
+
File.join(cwd, 'docker-compose.yml')
|
65
|
+
)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
sh cmd
|
69
|
+
end
|
70
|
+
|
71
|
+
# shell interface for terraform
|
35
72
|
def tf(cmd, cwd = :cache)
|
36
73
|
sh "mkdir -p #{cwd}" unless Dir.exist?(cwd)
|
37
74
|
cmd = "cd #{cwd} && terraform #{cmd}"
|
38
75
|
@translator.eval_in_context(File.read(@config_path))
|
39
|
-
File.write(File.join(cwd, 'template.json'))
|
40
76
|
sh cmd
|
41
77
|
sh "rm -rf #{File.join(cmd, 'template.json')}"
|
42
78
|
end
|