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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b4cd808da9cf190dae73451425d2b8633fdea7c9131c5fc505d6d76ac40f2b1
4
- data.tar.gz: fd1fc07d943ec61586b0bcc3dc58b9b4747f3cbcf649f732a7f9e07458c9680a
3
+ metadata.gz: 84b2b69ce04378ef96f36162ba523acd0926398dd959b8e4d13ecf888803f06c
4
+ data.tar.gz: df48273ded3eab015226a485753753ce363e31826b23a63cd17e982cf0717163
5
5
  SHA512:
6
- metadata.gz: 1b982f923196565229bbf2e90fd8705b2fa57afe94d60da265f33f075ba05df33fba5d5bb4c3763382b7efe3ca8db6a531858bd3302b05090a6611d628f12fe5
7
- data.tar.gz: 1a2cf23aaa872cf602e19c85a3ba13323ef14dfefa1c31881fa3b15444be1865c99079b4da20638209384c4c4f107c437901607880a9109f67b1ee13a39b3718
6
+ metadata.gz: f4f832d9e2c1578e758c961faad4da64dc0fc1c1fba84fa3f299f6984d6be781717b076122390d337dae19081821a868c1249cfa10e2e660757284c15db8f183
7
+ data.tar.gz: bdcaaec5de032a8eba1e112ad6b42240a685dcdd39cb96856ed8ad2114c5cd40729c2ab9bc3fb9e779e32d37141ee7c8ede68cb408520e5cd80b5d2e860c1577
data/bin/proteus CHANGED
@@ -2,4 +2,5 @@
2
2
 
3
3
  require 'proteus'
4
4
 
5
+ $stdout.sync = true
5
6
  Proteus::App.start(ARGV)
@@ -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
- end
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
@@ -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).render
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
- ensure_presence :key_prefix
44
+ each_key do
45
+ ensure_presence :key_prefix
45
46
 
46
- within :bucket do
47
- ensure_keys :name, :region, :profile
47
+ within :bucket do
48
+ ensure_keys :name, :region, :profile
49
+ end
48
50
  end
49
51
  end
50
52
  end
@@ -1,5 +1,5 @@
1
1
  module Proteus
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.7"
3
3
  end
4
4
 
5
5
  if $0 == __FILE__
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.6
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-02-04 00:00:00.000000000 Z
11
+ date: 2020-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler