dh-proteus 0.2.6 → 0.2.7
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/bin/proteus +1 -0
- data/lib/proteus/backend/backend.rb +17 -5
- data/lib/proteus/common.rb +6 -3
- data/lib/proteus/config/config.rb +6 -4
- data/lib/proteus/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84b2b69ce04378ef96f36162ba523acd0926398dd959b8e4d13ecf888803f06c
|
4
|
+
data.tar.gz: df48273ded3eab015226a485753753ce363e31826b23a63cd17e982cf0717163
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4f832d9e2c1578e758c961faad4da64dc0fc1c1fba84fa3f299f6984d6be781717b076122390d337dae19081821a868c1249cfa10e2e660757284c15db8f183
|
7
|
+
data.tar.gz: bdcaaec5de032a8eba1e112ad6b42240a685dcdd39cb96856ed8ad2114c5cd40729c2ab9bc3fb9e779e32d37141ee7c8ede68cb408520e5cd80b5d2e860c1577
|
data/bin/proteus
CHANGED
@@ -6,11 +6,23 @@ module Proteus
|
|
6
6
|
include Proteus::Helpers::PathHelpers
|
7
7
|
include Thor::Shell
|
8
8
|
|
9
|
+
attr_reader :backend_key
|
10
|
+
|
9
11
|
def initialize(config:, context:, environment:)
|
10
12
|
@config = config
|
11
13
|
@context = context
|
12
14
|
@environment = environment
|
13
|
-
|
15
|
+
|
16
|
+
@config[:providers].select {|p| p[:name] == 'aws' }.first[:environments].each do |env|
|
17
|
+
env[:match].each do |m|
|
18
|
+
if @environment == m
|
19
|
+
@provider_environment = env
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
@backend_key = @provider_environment[:backend]
|
25
|
+
end
|
14
26
|
|
15
27
|
def render
|
16
28
|
File.open(File.join(context_path(@context), 'backend.tf'), 'w') do |file|
|
@@ -28,10 +40,10 @@ module Proteus
|
|
28
40
|
<<~TEMPLATE
|
29
41
|
terraform {
|
30
42
|
backend "s3" {
|
31
|
-
bucket = "<%= @config[:backend][:bucket][:name] %>"
|
32
|
-
key = "<%= @config[:backend][:key_prefix] %>#{@context}-#{@environment}.tfstate"
|
33
|
-
region = "<%= @config[:backend][:bucket][:region] %>"
|
34
|
-
profile = "<%= @config[:backend][:bucket][:profile]%>"
|
43
|
+
bucket = "<%= @config[:backend][@backend_key][:bucket][:name] %>"
|
44
|
+
key = "<%= @config[:backend][@backend_key][:key_prefix] %>#{@context}-#{@environment}.tfstate"
|
45
|
+
region = "<%= @config[:backend][@backend_key][:bucket][:region] %>"
|
46
|
+
profile = "<%= @config[:backend][@backend_key][:bucket][:profile]%>"
|
35
47
|
}
|
36
48
|
}
|
37
49
|
TEMPLATE
|
data/lib/proteus/common.rb
CHANGED
@@ -30,14 +30,17 @@ module Proteus
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def render_backend
|
33
|
-
Proteus::Backend::Backend.new(config: config, context: context, environment: environment)
|
33
|
+
backend = Proteus::Backend::Backend.new(config: config, context: context, environment: environment)
|
34
|
+
backend.render
|
35
|
+
|
36
|
+
backend
|
34
37
|
end
|
35
38
|
|
36
39
|
def init(verbose: false)
|
37
40
|
say "initializing", :green
|
38
41
|
say "environment: #{environment}", :green
|
39
42
|
|
40
|
-
render_backend
|
43
|
+
backend = render_backend
|
41
44
|
|
42
45
|
`rm -rf #{context_path(context)}/.terraform/*.tf*`
|
43
46
|
`rm -rf #{context_path(context)}/.terraform/modules`
|
@@ -46,7 +49,7 @@ module Proteus
|
|
46
49
|
terraform_command = <<~TERRAFORM_COMMAND
|
47
50
|
cd #{context_path(context)} && \
|
48
51
|
terraform init \
|
49
|
-
-backend-config='key=#{config[:backend][:key_prefix]}#{context}-#{environment}.tfstate' \
|
52
|
+
-backend-config='key=#{config[:backend][backend.backend_key][:key_prefix]}#{context}-#{environment}.tfstate' \
|
50
53
|
#{aws_profile} \
|
51
54
|
#{context_path(context)}
|
52
55
|
TERRAFORM_COMMAND
|
@@ -26,7 +26,7 @@ module Proteus
|
|
26
26
|
ensure_uniqueness_across :match
|
27
27
|
|
28
28
|
each do
|
29
|
-
ensure_keys :profile
|
29
|
+
ensure_keys :profile, :backend
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -41,10 +41,12 @@ module Proteus
|
|
41
41
|
end
|
42
42
|
|
43
43
|
within :backend do
|
44
|
-
|
44
|
+
each_key do
|
45
|
+
ensure_presence :key_prefix
|
45
46
|
|
46
|
-
|
47
|
-
|
47
|
+
within :bucket do
|
48
|
+
ensure_keys :name, :region, :profile
|
49
|
+
end
|
48
50
|
end
|
49
51
|
end
|
50
52
|
end
|
data/lib/proteus/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dh-proteus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Albrecht
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|