dh-proteus 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +7 -3
- data/dh-proteus.gemspec +1 -0
- data/lib/proteus/app.rb +4 -0
- data/lib/proteus/backend/backend.rb +45 -12
- data/lib/proteus/backend_info.rb +19 -0
- data/lib/proteus/common.rb +6 -12
- data/lib/proteus/config/config.rb +6 -4
- data/lib/proteus/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10f66dcab397697c71838f79094e37d2222b1be3c9110bc31f3f6f07183fd5fa
|
4
|
+
data.tar.gz: 462eac3c33ffab2f47a8fa0ed0e3e4669c38a88d2b63f3478cdf63d8a9d8e2db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: add7493c81e4472bdadd9ce24aef06dcab1a3d56138ef653ad7eaa0a7fae5634c05fd8a8b551f450e6d22f36772e6bf4dc248b770a5898deccd9decfaeb9c30a
|
7
|
+
data.tar.gz: 9c5d32885ab3977f1d51e2f2288abf0680842b9f9291df614a3cef4bf883008e9607ac446590c0744d41cb6fbd5047ce40bfe81e404e0b8a940e586d144169c4
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dh-proteus (0.3.
|
4
|
+
dh-proteus (0.3.4)
|
5
5
|
activesupport (~> 5.1.1)
|
6
6
|
erubis (~> 2.7.0)
|
7
|
+
terminal-table (~> 3.0.0)
|
7
8
|
thor (~> 0.20.0)
|
8
9
|
|
9
10
|
GEM
|
@@ -18,10 +19,10 @@ GEM
|
|
18
19
|
concurrent-ruby (1.1.8)
|
19
20
|
diff-lcs (1.3)
|
20
21
|
erubis (2.7.0)
|
21
|
-
i18n (1.8.
|
22
|
+
i18n (1.8.9)
|
22
23
|
concurrent-ruby (~> 1.0)
|
23
24
|
method_source (0.8.2)
|
24
|
-
minitest (5.14.
|
25
|
+
minitest (5.14.4)
|
25
26
|
pry (0.10.4)
|
26
27
|
coderay (~> 1.1.0)
|
27
28
|
method_source (~> 0.8.1)
|
@@ -41,10 +42,13 @@ GEM
|
|
41
42
|
rspec-support (~> 3.8.0)
|
42
43
|
rspec-support (3.8.0)
|
43
44
|
slop (3.6.0)
|
45
|
+
terminal-table (3.0.0)
|
46
|
+
unicode-display_width (~> 1.1, >= 1.1.1)
|
44
47
|
thor (0.20.3)
|
45
48
|
thread_safe (0.3.6)
|
46
49
|
tzinfo (1.2.9)
|
47
50
|
thread_safe (~> 0.1)
|
51
|
+
unicode-display_width (1.7.0)
|
48
52
|
|
49
53
|
PLATFORMS
|
50
54
|
ruby
|
data/dh-proteus.gemspec
CHANGED
data/lib/proteus/app.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'proteus/common'
|
2
2
|
require 'proteus/generate'
|
3
3
|
require 'proteus/init'
|
4
|
+
require 'proteus/backend_info'
|
4
5
|
require 'proteus/global_commands/validate'
|
5
6
|
require 'proteus/global_commands/version'
|
6
7
|
require 'proteus/context_management/context'
|
@@ -113,6 +114,9 @@ module Proteus
|
|
113
114
|
desc 'init', 'Initializes a new proteus root directory in the current working directory'
|
114
115
|
subcommand('init', Proteus::Init)
|
115
116
|
|
117
|
+
desc 'backend_info', 'Shows information about backends'
|
118
|
+
subcommand('backend_info', Proteus::BackendInfo)
|
119
|
+
|
116
120
|
include Proteus::GlobalCommands::Validate
|
117
121
|
include Proteus::GlobalCommands::Version
|
118
122
|
end
|
@@ -13,17 +13,7 @@ module Proteus
|
|
13
13
|
@context = context
|
14
14
|
@environment = environment
|
15
15
|
|
16
|
-
|
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]
|
16
|
+
find_backend_key
|
27
17
|
end
|
28
18
|
|
29
19
|
def render
|
@@ -36,8 +26,51 @@ module Proteus
|
|
36
26
|
exit 1
|
37
27
|
end
|
38
28
|
|
29
|
+
def show_backends
|
30
|
+
require 'terminal-table'
|
31
|
+
table = Terminal::Table.new do |t|
|
32
|
+
t << ['Context', 'Environment', 'Profile', 'Bucket']
|
33
|
+
|
34
|
+
@config[:contexts].each do |ctx|
|
35
|
+
ctx[:environments].each do |env|
|
36
|
+
env[:match].each do |m|
|
37
|
+
t << [
|
38
|
+
ctx[:name],
|
39
|
+
m,
|
40
|
+
@config[:backend][env[:backend]][:profile],
|
41
|
+
@config[:backend][env[:backend]][:bucket][:name]
|
42
|
+
]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
say table, :green
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
def aws_profile
|
53
|
+
@config[:backend][@backend_key][:profile]
|
54
|
+
end
|
55
|
+
|
39
56
|
protected
|
40
57
|
|
58
|
+
def find_backend_key
|
59
|
+
@config[:contexts].each do |ctx|
|
60
|
+
if ctx[:name] == @context
|
61
|
+
ctx[:environments].each do |env|
|
62
|
+
env[:match].each do |m|
|
63
|
+
if @environment == m
|
64
|
+
@backend_key = env[:backend]
|
65
|
+
say "Using backend #{@backend_key}", :green
|
66
|
+
return
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
41
74
|
def template
|
42
75
|
<<~TEMPLATE
|
43
76
|
terraform {
|
@@ -45,7 +78,7 @@ module Proteus
|
|
45
78
|
bucket = "<%= @config[:backend][@backend_key][:bucket][:name] %>"
|
46
79
|
key = "<%= @config[:backend][@backend_key][:key_prefix] %>#{@context}-#{@environment}.tfstate"
|
47
80
|
region = "<%= @config[:backend][@backend_key][:bucket][:region] %>"
|
48
|
-
profile = "<%= @config[:backend][@backend_key][:
|
81
|
+
profile = "<%= @config[:backend][@backend_key][:profile]%>"
|
49
82
|
}
|
50
83
|
}
|
51
84
|
TEMPLATE
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'proteus/backend/backend'
|
2
|
+
|
3
|
+
module Proteus
|
4
|
+
class BackendInfo < Thor
|
5
|
+
include Thor::Actions
|
6
|
+
include Helpers
|
7
|
+
include Config
|
8
|
+
|
9
|
+
desc "backend-info", "Shows information about backend configuration"
|
10
|
+
long_desc <<-LONGDESC
|
11
|
+
Shows information about backend configuration
|
12
|
+
LONGDESC
|
13
|
+
def backend_info
|
14
|
+
Proteus::Backend::Backend.new(config: config, context: nil, environment: nil).show_backends
|
15
|
+
end
|
16
|
+
|
17
|
+
default_task :backend_info
|
18
|
+
end
|
19
|
+
end
|
data/lib/proteus/common.rb
CHANGED
@@ -30,17 +30,17 @@ module Proteus
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def render_backend
|
33
|
-
backend = Proteus::Backend::Backend.new(config: config, context: context, environment: environment)
|
34
|
-
backend.render
|
33
|
+
@backend = Proteus::Backend::Backend.new(config: config, context: context, environment: environment)
|
34
|
+
@backend.render
|
35
35
|
|
36
|
-
backend
|
36
|
+
@backend
|
37
37
|
end
|
38
38
|
|
39
39
|
def init(verbose: false)
|
40
40
|
say "initializing", :green
|
41
41
|
say "environment: #{environment}", :green
|
42
42
|
|
43
|
-
backend = render_backend
|
43
|
+
@backend = render_backend
|
44
44
|
|
45
45
|
`rm -rf #{context_path(context)}/.terraform/*.tf*`
|
46
46
|
`rm -rf #{context_path(context)}/.terraform/modules`
|
@@ -49,7 +49,7 @@ module Proteus
|
|
49
49
|
terraform_command = <<~TERRAFORM_COMMAND
|
50
50
|
cd #{context_path(context)} && \
|
51
51
|
terraform init \
|
52
|
-
-backend-config='key=#{config[:backend][backend.backend_key][:key_prefix]}#{context}-#{environment}.tfstate' \
|
52
|
+
-backend-config='key=#{config[:backend][@backend.backend_key][:key_prefix]}#{context}-#{environment}.tfstate' \
|
53
53
|
#{aws_profile} \
|
54
54
|
#{context_path(context)}
|
55
55
|
TERRAFORM_COMMAND
|
@@ -59,13 +59,7 @@ module Proteus
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def aws_profile
|
62
|
-
|
63
|
-
env[:match].each do |m|
|
64
|
-
return "-var 'aws_profile=#{env[:profile]}'" if environment == m
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
""
|
62
|
+
"-var 'aws_profile=#{@backend.aws_profile}'"
|
69
63
|
end
|
70
64
|
|
71
65
|
def dryrun
|
@@ -16,17 +16,19 @@ module Proteus
|
|
16
16
|
|
17
17
|
class ConfigValidator < Proteus::Validators::BaseValidator
|
18
18
|
def validate
|
19
|
-
within :
|
19
|
+
within :contexts do
|
20
20
|
ensure_data_type Array
|
21
|
+
ensure_uniqueness_across :name
|
21
22
|
|
22
23
|
each do
|
23
24
|
ensure_keys :name
|
25
|
+
ensure_uniqueness_across :name
|
24
26
|
|
25
27
|
within :environments do
|
26
28
|
ensure_uniqueness_across :match
|
27
29
|
|
28
30
|
each do
|
29
|
-
ensure_keys :
|
31
|
+
ensure_keys :backend
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
@@ -42,10 +44,10 @@ module Proteus
|
|
42
44
|
|
43
45
|
within :backend do
|
44
46
|
each_key do
|
45
|
-
|
47
|
+
ensure_keys :key_prefix, :profile
|
46
48
|
|
47
49
|
within :bucket do
|
48
|
-
ensure_keys :name, :region
|
50
|
+
ensure_keys :name, :region
|
49
51
|
end
|
50
52
|
end
|
51
53
|
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.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Albrecht
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 2.7.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: terminal-table
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 3.0.0
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 3.0.0
|
111
125
|
description:
|
112
126
|
email:
|
113
127
|
- simon.albrecht@deliveryhero.com
|
@@ -132,6 +146,7 @@ files:
|
|
132
146
|
- lib/proteus.rb
|
133
147
|
- lib/proteus/app.rb
|
134
148
|
- lib/proteus/backend/backend.rb
|
149
|
+
- lib/proteus/backend_info.rb
|
135
150
|
- lib/proteus/commands/apply.rb
|
136
151
|
- lib/proteus/commands/clean.rb
|
137
152
|
- lib/proteus/commands/destroy.rb
|