domed-city 1.6.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/dome +1 -1
- data/lib/dome.rb +2 -0
- data/lib/dome/environment.rb +30 -29
- data/lib/dome/settings.rb +16 -0
- data/lib/dome/terraform.rb +1 -1
- data/lib/dome/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed66b624e303da572cb9b8373540c31f87025733
|
4
|
+
data.tar.gz: 3c4439e4ede3d703dc60b0098e5cfabd0a6e5a4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90f0c2c2db637fd0946a507a8434990e37d44b6e6e103aa7eec7d89cd006a5647b4da252da6279eefab99132323b9b54fa1a5210ebe6416c37ac58f79649ab33
|
7
|
+
data.tar.gz: e9e87383b69a2e7bf938fb6ee3cac144e3219b8ab429e3b02e7625dd2295f06206dc482099e35e7fde51b377b3e4ef0cda76fdda072001f7342e2f6e1c2fe5d5
|
data/bin/dome
CHANGED
data/lib/dome.rb
CHANGED
data/lib/dome/environment.rb
CHANGED
@@ -1,26 +1,23 @@
|
|
1
1
|
module Dome
|
2
2
|
class Environment
|
3
|
-
attr_reader :environment, :account
|
3
|
+
attr_reader :environment, :account, :settings
|
4
4
|
|
5
5
|
def initialize(directories = Dir.pwd.split('/'))
|
6
6
|
@environment = directories[-1]
|
7
7
|
@account = directories[-2]
|
8
|
+
@settings = Dome::Settings.new
|
8
9
|
end
|
9
10
|
|
10
11
|
def team
|
11
|
-
@
|
12
|
+
@settings.parse['project']
|
12
13
|
end
|
13
14
|
|
14
15
|
def accounts
|
15
16
|
%W(#{team}-dev #{team}-prd)
|
16
17
|
end
|
17
18
|
|
18
|
-
def
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
def production_environments
|
23
|
-
%w(infraprd prd)
|
19
|
+
def environments
|
20
|
+
@settings.parse['environments']
|
24
21
|
end
|
25
22
|
|
26
23
|
def aws_credentials
|
@@ -40,38 +37,42 @@ module Dome
|
|
40
37
|
accounts.include? account_name
|
41
38
|
end
|
42
39
|
|
43
|
-
def valid_environment?(
|
40
|
+
def valid_environment?(environment_name)
|
44
41
|
puts "Environment: #{environment_name.colorize(:green)}"
|
45
|
-
|
46
|
-
non_production_environments.include? environment_name
|
47
|
-
else
|
48
|
-
production_environments.include? environment_name
|
49
|
-
end
|
42
|
+
environments.include? environment_name
|
50
43
|
end
|
51
44
|
|
52
45
|
def invalid_account_message
|
53
46
|
puts "\n'#{@account}' is not a valid account.\n".colorize(:red)
|
54
|
-
|
55
|
-
puts "The expected directory structure is '.../<account>/<environment>'\n".colorize(:red)
|
56
|
-
puts "Valid accounts are: #{accounts}."
|
57
|
-
puts "\nEither:"
|
58
|
-
puts '1. Set your .aws/config to one of the valid accounts above.'
|
59
|
-
puts '2. Ensure you are running this from the correct directory.'
|
47
|
+
generic_error_message
|
60
48
|
exit 1
|
61
49
|
end
|
62
50
|
|
63
51
|
def invalid_environment_message
|
64
|
-
puts "\n'#{@environment}' is not a valid environment
|
52
|
+
puts "\n'#{@environment}' is not a valid environment.\n".colorize(:red)
|
53
|
+
generic_error_message
|
54
|
+
exit 1
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
# rubocop:disable Metrics/MethodLength
|
60
|
+
# rubocop:disable Metrics/AbcSize
|
61
|
+
def generic_error_message
|
65
62
|
puts "The 'account' and 'environment' variables are assigned based on your current directory.\n".colorize(:red)
|
66
63
|
puts "The expected directory structure is '.../<account>/<environment>'\n".colorize(:red)
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
puts "
|
74
|
-
|
64
|
+
puts '============================================================================='
|
65
|
+
puts "Valid environments are defined using the 'environments' key in your itv.yaml."
|
66
|
+
puts "The environments you have defined are: #{environments}."
|
67
|
+
puts '============================================================================='
|
68
|
+
puts 'Valid accounts are of the format <project>-dev/prd and <project>-prd' \
|
69
|
+
" (where 'project' is defined using the 'project' key in your itv.yaml."
|
70
|
+
puts "The accounts you have defined are: #{accounts}."
|
71
|
+
puts '============================================================================='
|
72
|
+
puts 'To fix your issue, try the following:'
|
73
|
+
puts '1. Set your .aws/config to one of the valid accounts above.'
|
74
|
+
puts '2. Ensure you are running this from the correct directory.'
|
75
|
+
puts '3. Update your itv.yaml with the required environments or project.'
|
75
76
|
end
|
76
77
|
end
|
77
78
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Dome
|
2
|
+
class Settings
|
3
|
+
def parse
|
4
|
+
raise('[*] itv.yaml does not exist') unless File.exist? itv_yaml_path
|
5
|
+
load_yaml
|
6
|
+
end
|
7
|
+
|
8
|
+
def load_yaml
|
9
|
+
@parsed_yaml ||= YAML.load_file(itv_yaml_path)
|
10
|
+
end
|
11
|
+
|
12
|
+
def itv_yaml_path
|
13
|
+
'../../../itv.yaml'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/dome/terraform.rb
CHANGED
@@ -14,7 +14,7 @@ module Dome
|
|
14
14
|
environment = @environment.environment
|
15
15
|
account = @environment.account
|
16
16
|
@environment.invalid_account_message unless @environment.valid_account? account
|
17
|
-
@environment.invalid_environment_message unless @environment.valid_environment?
|
17
|
+
@environment.invalid_environment_message unless @environment.valid_environment? environment
|
18
18
|
puts "Team: #{@environment.team.colorize(:green)}"
|
19
19
|
puts '----------------------------------------------------------------'
|
20
20
|
@environment.populate_aws_access_keys
|
data/lib/dome/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: domed-city
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Snape
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -143,6 +143,7 @@ files:
|
|
143
143
|
- lib/dome.rb
|
144
144
|
- lib/dome/environment.rb
|
145
145
|
- lib/dome/helpers/shell.rb
|
146
|
+
- lib/dome/settings.rb
|
146
147
|
- lib/dome/state.rb
|
147
148
|
- lib/dome/terraform.rb
|
148
149
|
- lib/dome/version.rb
|