Skip to content

Commit caf6501

Browse files
committed
integrate inspec.yml.tmpl file if available.
1 parent 912e8fd commit caf6501

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

hooks/createstackmoduleoutputs.rb

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@
1818
require 'json'
1919
require 'open3'
2020

21-
CAPTUREFROMSTACK = 'terraform-config-inspect --json'
22-
ENVNAME = 'KITCHEN_SUITE_NAME'
23-
OUTPUTSTF = './stackmodulesoutputs.tf'
24-
BANNER = "# This file has been created automatically.\n\n"
25-
INSPEC_YMLHEAD = <<~MYYML
21+
CAPTUREFROMSTACK = 'terraform-config-inspect --json'
22+
ENVNAME = 'KITCHEN_SUITE_NAME'
23+
OUTPUTSTF = './stackmodulesoutputs.tf'
24+
BANNER = "# This file has been created automatically.\n\n"
25+
INSPECYMLTMPLFILE = './test/integration/default/inspec.yml.tmpl'
26+
INSPECYMLTMPLSTR = <<~MYYML
2627
---
2728
name: stackdefault
2829
supports:
@@ -31,10 +32,14 @@
3132
- name: inspec-aws
3233
git: https://github.com/inspec/inspec-aws
3334
tag: v1.33.0
34-
# Begin - blueprint inspec profiles
35-
#{' '}
3635
MYYML
3736

37+
INSPECYMLHEAD = if File.exist?(INSPECYMLTMPLFILE)
38+
File.read(INSPECYMLTMPLFILE)
39+
else
40+
INSPECYMLTMPLSTR
41+
end
42+
3843
stdout, _stderr, _status = Open3.capture3(CAPTUREFROMSTACK)
3944

4045
myEnv = ENV.fetch(ENVNAME, 'default')
@@ -56,7 +61,7 @@
5661
modoutTF.write(BANNER)
5762
allBPsRB.write(BANNER)
5863
inspecYML.write(BANNER)
59-
inspecYML.write(INSPEC_YMLHEAD)
64+
inspecYML.write(INSPECYMLHEAD)
6065

6166
# get module section from main.json
6267
allModules = JSON.parse(stdout)['module_calls']

0 commit comments

Comments
 (0)