dh-proteus 0.2.5 → 0.3.0
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 +19 -5
- data/lib/proteus/common.rb +7 -4
- data/lib/proteus/config/config.rb +6 -4
- data/lib/proteus/helpers.rb +9 -1
- data/lib/proteus/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 263b0afd288fa51a29ea54621b191dd8cb86a4337456226694bf8c8047dd2534
|
4
|
+
data.tar.gz: 202ba99d158dabcfb19db4bc583f9a7fe4657697f38f0f0923b240232f50524b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09320cdfeb939b664384449b04496fd649886df20adab89c947b1c89b82cc94b91d2f9afd8c4749de3c9c93202b9aa71bb403e3f0f2e36d7bada77d41fb9c8ff'
|
7
|
+
data.tar.gz: c2c3c0d51070d4db497cf14e1f3a1b00d8df9efc3e555c2f1feba7776e088436b066eca4f650615d02b44102a4a080b457610ba40814153b3aba45dae21b1cd9
|
data/bin/proteus
CHANGED
@@ -6,11 +6,25 @@ 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].each do |provider|
|
17
|
+
provider[:environments].each do |env|
|
18
|
+
env[:match].each do |m|
|
19
|
+
if @environment == m
|
20
|
+
@provider_environment = env
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
@backend_key = @provider_environment[:backend]
|
27
|
+
end
|
14
28
|
|
15
29
|
def render
|
16
30
|
File.open(File.join(context_path(@context), 'backend.tf'), 'w') do |file|
|
@@ -28,10 +42,10 @@ module Proteus
|
|
28
42
|
<<~TEMPLATE
|
29
43
|
terraform {
|
30
44
|
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]%>"
|
45
|
+
bucket = "<%= @config[:backend][@backend_key][:bucket][:name] %>"
|
46
|
+
key = "<%= @config[:backend][@backend_key][:key_prefix] %>#{@context}-#{@environment}.tfstate"
|
47
|
+
region = "<%= @config[:backend][@backend_key][:bucket][:region] %>"
|
48
|
+
profile = "<%= @config[:backend][@backend_key][:bucket][:profile]%>"
|
35
49
|
}
|
36
50
|
}
|
37
51
|
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
|
@@ -62,7 +65,7 @@ module Proteus
|
|
62
65
|
end
|
63
66
|
end
|
64
67
|
|
65
|
-
|
68
|
+
""
|
66
69
|
end
|
67
70
|
|
68
71
|
def dryrun
|
@@ -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/helpers.rb
CHANGED
@@ -33,7 +33,15 @@ module Proteus
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def current_user
|
36
|
-
|
36
|
+
user = ENV['CURRENT_USER_NAME'] ? ENV['CURRENT_USER_NAME'] : Etc.getpwnam(Etc.getlogin).gecos
|
37
|
+
if user.empty?
|
38
|
+
puts "Please set your git username properly:"
|
39
|
+
puts "git config --global user.name \"FIRST_NAME LAST_NAME\""
|
40
|
+
puts "git config --global user.email \"YOUR_NAME@example.com\""
|
41
|
+
exit 1
|
42
|
+
else
|
43
|
+
user
|
44
|
+
end
|
37
45
|
end
|
38
46
|
|
39
47
|
def slack_webhook
|
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Albrecht
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,7 +108,7 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 2.7.0
|
111
|
-
description:
|
111
|
+
description:
|
112
112
|
email:
|
113
113
|
- simon.albrecht@deliveryhero.com
|
114
114
|
executables:
|
@@ -184,7 +184,7 @@ metadata:
|
|
184
184
|
homepage_uri: https://github.com/deliveryhero/proteus
|
185
185
|
source_code_uri: https://github.com/deliveryhero/proteus
|
186
186
|
changelog_uri: https://github.com/deliveryhero/proteus/CHANGELOG
|
187
|
-
post_install_message:
|
187
|
+
post_install_message:
|
188
188
|
rdoc_options: []
|
189
189
|
require_paths:
|
190
190
|
- lib
|
@@ -199,9 +199,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
199
|
- !ruby/object:Gem::Version
|
200
200
|
version: '0'
|
201
201
|
requirements: []
|
202
|
-
rubyforge_project:
|
202
|
+
rubyforge_project:
|
203
203
|
rubygems_version: 2.7.6.2
|
204
|
-
signing_key:
|
204
|
+
signing_key:
|
205
205
|
specification_version: 4
|
206
206
|
summary: Proteus is a Terraform wrapper application.
|
207
207
|
test_files: []
|