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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cea581615465bd49b4a6ca4cfda20f283ecb6679269b1d33121e515044077d92
4
- data.tar.gz: e3d48f7e62a6dd0f1103065013d2ec976c19f054e655535d2a997983fe8c81e5
3
+ metadata.gz: 5cc10779a985a7a62ff7f57233212473988a76275b341138c99c733a03640f59
4
+ data.tar.gz: 59c8dbbf601c86df7a1d62af54b0f608172d127083e89be6d4c117f8deff3fc7
5
5
  SHA512:
6
- metadata.gz: f8084923ed4e6c547e31797ce976e282a3d2272e7bc1653b848827fe53ba71736fdb4bfd2c0fbee287ac9bad4b46f6514787ac1789e412337f464583ce38c3ed
7
- data.tar.gz: 8fe631437fe45712a44aa5f02709b2a632e737d12cc19aab57e464ab0ff915f8f1c64118eefbc0ce67f25e280bb95585991911e929700c6cb95891db5a1e5a6d
6
+ metadata.gz: c2c4286ba39d96159eeb926c05747dfeaac3a2509349f0fb56f8cc807799f5d94806fed2e2879b9dc56835268edb188693ae128da984ed4a06530c25db3abd8e
7
+ data.tar.gz: 660bd24ead2916720f9204e4d3d911f8bac0d01766abef3bcf4d09551cac88fb89303a71fe7c8b0f2f5451d9346ad12ee5b671520ad3ffc1922c04db82bbebd1
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Pleme
4
4
  module Gem
5
- VERSION = '0.0.9'
5
+ VERSION = '0.0.14'
6
6
  end
7
7
  end
@@ -9,7 +9,7 @@ class PlemecTranslator < AbstractTranslator
9
9
  attr_reader :resource_symbols
10
10
 
11
11
  def initialize
12
- @translation = ResourceTranslation.new
12
+ @translation = PlemecTranslation.new
13
13
  @resource_symbols = %i[pleme]
14
14
  end
15
15
 
@@ -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
- tf 'apply'
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pleme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''