idlc-sdk-pfm 1.0.0.rc12 → 1.0.0.rc13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/idlc-sdk-pfm/command/apply.rb +19 -4
- data/lib/idlc-sdk-pfm/command/base.rb +35 -0
- data/lib/idlc-sdk-pfm/command/plan.rb +20 -5
- data/lib/idlc-sdk-pfm/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8ba8ceed47dcdc4995186b2eb8d947f11f989bc
|
4
|
+
data.tar.gz: 95b58c9409b4958a1521231920d73af4de539a94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3213b642518b3b9d54bee82e4b3b366212582a63b0ba806c183a2029f96b892014bbe4dabfddb54a116dd78e83349a2cdac9503bedd65c326d30b0a5d107597a
|
7
|
+
data.tar.gz: 93f9fa665c16878ad462a5a1685503f9333bf51cd4b0a0d7fa6407e945e7ba3c6eb6a7799423f101669a291c65e630d7a79e208e6a8796eca47ef678e4bcf98d
|
@@ -18,6 +18,16 @@ module Pfm
|
|
18
18
|
description: 'Server Build Number to Deploy',
|
19
19
|
default: ENV['SERVER_BUILD']
|
20
20
|
|
21
|
+
option :config_file,
|
22
|
+
long: '--config-file',
|
23
|
+
description: 'Optional environment metadata file',
|
24
|
+
default: ''
|
25
|
+
|
26
|
+
option :working_dir,
|
27
|
+
long: '--dir',
|
28
|
+
description: 'Optional directory of infrastructure configuration to use',
|
29
|
+
default: ''
|
30
|
+
|
21
31
|
def initialize
|
22
32
|
super
|
23
33
|
@params_valid = true
|
@@ -29,8 +39,13 @@ module Pfm
|
|
29
39
|
read_and_validate_params
|
30
40
|
|
31
41
|
if params_valid?
|
32
|
-
|
33
|
-
|
42
|
+
if (@config[:config_file])
|
43
|
+
deploy_setupv2
|
44
|
+
apply(@config[:working_dir])
|
45
|
+
else
|
46
|
+
deploy_setup
|
47
|
+
apply(@workspace.tmp_dir)
|
48
|
+
end
|
34
49
|
# @workspace.cleanup causing bundler issues
|
35
50
|
0
|
36
51
|
else
|
@@ -44,8 +59,8 @@ module Pfm
|
|
44
59
|
1
|
45
60
|
end
|
46
61
|
|
47
|
-
def apply
|
48
|
-
Terraform::Binary.apply(
|
62
|
+
def apply(dir)
|
63
|
+
Terraform::Binary.apply(dir.to_s) || raise
|
49
64
|
rescue
|
50
65
|
raise DeploymentFailure, 'Finished with errors'
|
51
66
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'mixlib/cli'
|
2
2
|
require 'idlc-sdk-pfm/helpers'
|
3
3
|
require 'securerandom'
|
4
|
+
require 'json'
|
4
5
|
|
5
6
|
module Pfm
|
6
7
|
module Command
|
@@ -158,6 +159,40 @@ module Pfm
|
|
158
159
|
config.configure_state(bucket_name, sub_bucket, @workspace.tmp_dir)
|
159
160
|
end
|
160
161
|
|
162
|
+
def deploy_setupv2
|
163
|
+
Terraform::Binary.configure do |config|
|
164
|
+
config.version = SETTINGS['TERRAFORM_VERSION']
|
165
|
+
config.download_path = "/tmp/#{SecureRandom.uuid}"
|
166
|
+
end
|
167
|
+
|
168
|
+
env_metadata = JSON.parse(open(@config[:config_file]).read)
|
169
|
+
env_metadata['account'].each do |key, value|
|
170
|
+
Idlc::Deploy::Config.add_deployment_var(key, value)
|
171
|
+
end
|
172
|
+
env_metadata['environment'].each do |key, value|
|
173
|
+
Idlc::Deploy::Config.add_deployment_var(key, value)
|
174
|
+
end
|
175
|
+
env_metadata['ec2'].each do |key, value|
|
176
|
+
Idlc::Deploy::Config.add_deployment_var(key, value)
|
177
|
+
end
|
178
|
+
|
179
|
+
# Pass some extra vars for Terraform
|
180
|
+
Idlc::Deploy::Config.add_deployment_var('environment_key', env_metadata['environment_key'])
|
181
|
+
Idlc::Deploy::Config.add_deployment_var('version', env_metadata['environment']['inf_version'])
|
182
|
+
Idlc::Deploy::Config.add_deployment_var('major_minor', Idlc::Utility.major_minor(env_metadata['environment']['inf_version']))
|
183
|
+
Idlc::Deploy::Config.add_deployment_var('major_minor_patch', Idlc::Utility.major_minor_patch(env_metadata['environment']['inf_version']))
|
184
|
+
Idlc::Deploy::Config.add_deployment_var('build', @config[:server_build])
|
185
|
+
Idlc::Deploy::Config.add_deployment_var('app_release', @config[:app_release])
|
186
|
+
|
187
|
+
Idlc::Deploy::Keypair.generate("#{@config[:working_dir]}/env/kp")
|
188
|
+
|
189
|
+
config.configure_state(
|
190
|
+
env_metadata['account']['tfstate_bucket'],
|
191
|
+
env_metadata['environment_key'],
|
192
|
+
@config[:working_dir]
|
193
|
+
)
|
194
|
+
end
|
195
|
+
|
161
196
|
def templates_dir
|
162
197
|
"#{__dir__}/templates/#{@build_metadata.attributes['build_stage'].value}"
|
163
198
|
end
|
@@ -25,6 +25,16 @@ module Pfm
|
|
25
25
|
boolean: true,
|
26
26
|
default: false
|
27
27
|
|
28
|
+
option :config_file,
|
29
|
+
long: '--config-file',
|
30
|
+
description: 'Optional environment metadata file',
|
31
|
+
default: ''
|
32
|
+
|
33
|
+
option :working_dir,
|
34
|
+
long: '--dir',
|
35
|
+
description: 'Optional directory of infrastructure configuration to use',
|
36
|
+
default: ''
|
37
|
+
|
28
38
|
def initialize
|
29
39
|
super
|
30
40
|
@params_valid = true
|
@@ -36,8 +46,13 @@ module Pfm
|
|
36
46
|
read_and_validate_params
|
37
47
|
|
38
48
|
if params_valid?
|
39
|
-
|
40
|
-
|
49
|
+
if (@config[:config_file])
|
50
|
+
deploy_setupv2
|
51
|
+
plan(@config[:working_dir])
|
52
|
+
else
|
53
|
+
deploy_setup
|
54
|
+
plan(@workspace.tmp_dir)
|
55
|
+
end
|
41
56
|
# @workspace.cleanup causing bundler issues
|
42
57
|
0
|
43
58
|
else
|
@@ -51,10 +66,10 @@ module Pfm
|
|
51
66
|
1
|
52
67
|
end
|
53
68
|
|
54
|
-
def plan
|
69
|
+
def plan(dir)
|
55
70
|
begin
|
56
|
-
Terraform::Binary.plan(
|
57
|
-
Terraform::Binary.plan("#{
|
71
|
+
Terraform::Binary.plan(dir.to_s) unless @config[:landscape]
|
72
|
+
Terraform::Binary.plan("#{dir} | landscape") if @config[:landscape]
|
58
73
|
rescue
|
59
74
|
raise DeploymentFailure, 'Finished with errors'
|
60
75
|
end
|
data/lib/idlc-sdk-pfm/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: idlc-sdk-pfm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.rc13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Cazell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|