covalence 0.8.4 → 0.9.1
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/CHANGELOG.md +12 -4
- data/README.md +1 -10
- data/lib/covalence.rb +4 -0
- data/lib/covalence/core/cli_wrappers/popen_wrapper.rb +38 -16
- data/lib/covalence/core/cli_wrappers/terraform_cli.rb +55 -8
- data/lib/covalence/core/entities/input.rb +14 -0
- data/lib/covalence/core/entities/stack.rb +3 -3
- data/lib/covalence/core/services/packer_stack_tasks.rb +2 -2
- data/lib/covalence/core/services/terraform_stack_tasks.rb +44 -15
- data/lib/covalence/core/state_stores/s3.rb +12 -4
- data/lib/covalence/environment_tasks.rb +7 -1
- data/lib/covalence/rake/rspec/envs_spec.rb +23 -59
- data/lib/covalence/version.rb +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01a6df525586ec948c89317d69451a4f8acc3e46bc80fb09b55833f6b91e9ba2
|
4
|
+
data.tar.gz: b20fd2249962484525305bc11f0fdf796276126c26a074e97322358b6da76622
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57f06cc073babb01bda236615fec3ef042b9f20165870b6468a2b9c1d9c9f25dcd1288ccbc21e78c38ed03bd703af79205fef1f83ed8fa03907516e184fda83c
|
7
|
+
data.tar.gz: 98ebbed71d2a26b88cc97784bc0006270ad211ef6e5398ac506cd78119e8d46f90067a415e6fe287ec5fcc38bc99596a5601bbe6d25e27276e051208461f7b0b
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,15 @@
|
|
1
|
-
##
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
## 0.9.1 (Aug 11, 2019)
|
2
|
+
|
3
|
+
BACKWARDS INCOMPATIBILITIES:
|
4
|
+
- The legacy Atlas Artifact backend is no longer supported.
|
5
|
+
|
6
|
+
IMPROVEMENTS:
|
7
|
+
* Ability to toggle primary state store
|
8
|
+
* Environment variable interpolation for input variables
|
9
|
+
* Support for sops encryption / decryption of hierarchy data
|
10
|
+
* Support for Terraform 0.12
|
11
|
+
* Support for parallel execution of process.
|
12
|
+
* A tool [prefixout](https://github.com/unifio/prefixout/releases/tag/v0.1.0) was added for additional logging.
|
5
13
|
|
6
14
|
## 0.7.8 (May 9, 2018)
|
7
15
|
IMPROVEMENTS:
|
data/README.md
CHANGED
@@ -406,16 +406,6 @@ Module for interacting with the Terraform Enterprise backend.
|
|
406
406
|
|
407
407
|
### Usage
|
408
408
|
|
409
|
-
Artifacts:
|
410
|
-
|
411
|
-
```yaml
|
412
|
-
ami:
|
413
|
-
type: 'atlas.artifact'
|
414
|
-
slug: 'unifio/app/amazon.ami'
|
415
|
-
version: 'latest'
|
416
|
-
key: 'region.us-east-1'
|
417
|
-
```
|
418
|
-
|
419
409
|
State Outputs:
|
420
410
|
|
421
411
|
```yaml
|
@@ -508,6 +498,7 @@ You will probably need the following packages installed locally
|
|
508
498
|
- Terraform
|
509
499
|
- Packer
|
510
500
|
- Sops
|
501
|
+
- [prefixout](https://github.com/unifio/prefixout/releases/tag/v0.1.0)
|
511
502
|
|
512
503
|
Execute the following to build the gem:
|
513
504
|
|
data/lib/covalence.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "covalence/version"
|
2
2
|
require "logger"
|
3
3
|
require 'active_support/core_ext/object/blank'
|
4
|
+
require 'etc'
|
4
5
|
|
5
6
|
if %w(development test).include?(ENV['RAKE_ENV'])
|
6
7
|
require 'byebug'
|
@@ -43,4 +44,7 @@ module Covalence
|
|
43
44
|
LOGGER = Logger.new(STDOUT)
|
44
45
|
LOG_LEVEL = String(ENV['COVALENCE_LOG'] || "warn").upcase
|
45
46
|
LOGGER.level = Logger.const_get(LOG_LEVEL)
|
47
|
+
|
48
|
+
# worker count
|
49
|
+
WORKER_COUNT = ENV.has_key?('WORKER_COUNT') ? ENV['WORKER_COUNT'].to_i : Etc.nprocessors
|
46
50
|
end
|
@@ -13,13 +13,14 @@ module Covalence
|
|
13
13
|
stderr_io: STDERR,
|
14
14
|
debug: Covalence::DEBUG_CLI,
|
15
15
|
dry_run: false,
|
16
|
-
ignore_exitcode: false
|
16
|
+
ignore_exitcode: false,
|
17
|
+
workdir: nil)
|
17
18
|
|
18
19
|
# TODO: implement path prefix for the docker runs, see @tf_cmd
|
19
20
|
cmd_string = [*cmds]
|
20
21
|
# TODO: cmd escape issues with -var.
|
21
22
|
cmd_string += [*args] unless args.blank?
|
22
|
-
cmd_string << path unless
|
23
|
+
cmd_string << path unless workdir
|
23
24
|
|
24
25
|
#TODO debug command string maybe
|
25
26
|
#TODO debug command args maybe
|
@@ -34,12 +35,27 @@ module Covalence
|
|
34
35
|
return 0 unless HighLine.new.agree('Execute? [y/n]')
|
35
36
|
end
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
if workdir
|
39
|
+
spawn_subprocess(ENV, run_cmd,
|
40
|
+
stdin_io: stdin_io,
|
41
|
+
stdout_io: stdout_io,
|
42
|
+
stderr_io: stderr_io,
|
43
|
+
ignore_exitcode: ignore_exitcode,
|
44
|
+
path: path,
|
45
|
+
workdir: workdir)
|
46
|
+
else
|
47
|
+
spawn_subprocess(ENV, run_cmd,
|
48
|
+
stdin_io: stdin_io,
|
49
|
+
stdout_io: stdout_io,
|
50
|
+
stderr_io: stderr_io,
|
51
|
+
ignore_exitcode: ignore_exitcode,
|
52
|
+
path: path)
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
def logger
|
58
|
+
Covalence::LOGGER
|
43
59
|
end
|
44
60
|
|
45
61
|
private
|
@@ -49,21 +65,27 @@ module Covalence
|
|
49
65
|
end
|
50
66
|
|
51
67
|
def spawn_subprocess(env, run_cmd,
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
68
|
+
stdin_io: STDIN,
|
69
|
+
stdout_io: STDOUT,
|
70
|
+
stderr_io: STDERR,
|
71
|
+
ignore_exitcode: false,
|
72
|
+
path: Dir.pwd,
|
73
|
+
workdir: Dir.pwd)
|
74
|
+
logger.info "path: #{path} workdir: #{workdir} run_cmd: #{run_cmd}"
|
75
|
+
## TODO one thing we can try is to use
|
76
|
+
# Prctl.call(Prctl::PR_SET_PDEATHSIG, Signal.list['TERM'], 0, 0, 0)
|
77
|
+
# so when the parent dies, child will know to terminate itself.
|
78
|
+
Signal.trap("INT") { logger.info "Trapped Ctrl-c. Disable parent process from exiting, orphaning the child fork below which may or may not work" }
|
57
79
|
wait_thread = nil
|
58
|
-
|
59
|
-
|
80
|
+
prefix=path.gsub(/^\/workspace*/,'')
|
81
|
+
whole_cmd=['prefixout', '-p', "#{prefix} ", '--'].concat(run_cmd.split)
|
82
|
+
Open3.popen3(env, *whole_cmd, :chdir=>workdir) do |stdin, stdout, stderr, wait_thr|
|
60
83
|
mappings = { stdin_io => stdin, stdout => stdout_io, stderr => stderr_io }
|
61
84
|
wait_thread = wait_thr
|
62
85
|
|
63
86
|
Signal.trap("INT") {
|
64
87
|
Process.kill("INT", wait_thr.pid)
|
65
88
|
Process.wait(wait_thr.pid, Process::WNOHANG)
|
66
|
-
|
67
89
|
exit(wait_thr.value.exitstatus)
|
68
90
|
} # let SIGINT drop into the child process
|
69
91
|
|
@@ -34,24 +34,68 @@ module Covalence
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def self.terraform_check_style(path)
|
37
|
-
|
38
|
-
|
39
|
-
output =
|
40
|
-
|
37
|
+
cmd = [Covalence::TERRAFORM_CMD, "fmt", "-check"]
|
38
|
+
|
39
|
+
output = PopenWrapper.run(
|
40
|
+
cmd,
|
41
|
+
path,
|
42
|
+
'',
|
43
|
+
ignore_exitcode: false)
|
44
|
+
(output == 0)
|
41
45
|
end
|
42
46
|
|
43
|
-
def self.terraform_init(path
|
47
|
+
def self.terraform_init(path: '', workdir: Dir.pwd, args: '', ignore_exitcode: false)
|
44
48
|
if ENV['TF_PLUGIN_LOCAL'] == 'true'
|
45
|
-
cmd = [Covalence::TERRAFORM_CMD, "init", "-get=false", "-input=false", "-plugin-dir=#{Covalence::TERRAFORM_PLUGIN_CACHE}"]
|
49
|
+
cmd = [Covalence::TERRAFORM_CMD, "init", "-get-plugins=false", "-get=false", "-input=false", "-plugin-dir=#{Covalence::TERRAFORM_PLUGIN_CACHE}"]
|
46
50
|
else
|
47
|
-
cmd = [Covalence::TERRAFORM_CMD, "init", "-get=false", "-input=false"]
|
51
|
+
cmd = [Covalence::TERRAFORM_CMD, "init", "-get-plugins=false", "-get=false", "-input=false"]
|
48
52
|
end
|
49
53
|
|
50
54
|
output = PopenWrapper.run(
|
51
55
|
cmd,
|
52
56
|
path,
|
53
57
|
args,
|
54
|
-
ignore_exitcode: ignore_exitcode
|
58
|
+
ignore_exitcode: ignore_exitcode,
|
59
|
+
workdir: workdir)
|
60
|
+
(output == 0)
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.terraform_get(path=Dir.pwd, workdir=Dir.pwd, args: '', ignore_exitcode: false)
|
64
|
+
cmd = [Covalence::TERRAFORM_CMD, "get", path]
|
65
|
+
|
66
|
+
output = PopenWrapper.run(
|
67
|
+
cmd,
|
68
|
+
path,
|
69
|
+
args,
|
70
|
+
ignore_exitcode: ignore_exitcode,
|
71
|
+
workdir: workdir)
|
72
|
+
|
73
|
+
(output == 0)
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.terraform_plan(path: '', workdir: Dir.pwd, args: '', ignore_exitcode: false)
|
77
|
+
cmd = [Covalence::TERRAFORM_CMD, "plan"]
|
78
|
+
|
79
|
+
output = PopenWrapper.run(
|
80
|
+
cmd,
|
81
|
+
path,
|
82
|
+
args,
|
83
|
+
ignore_exitcode: ignore_exitcode,
|
84
|
+
workdir: workdir)
|
85
|
+
|
86
|
+
(output == 0)
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.terraform_validate(path, workdir, args: '', ignore_exitcode: false)
|
90
|
+
cmd = [Covalence::TERRAFORM_CMD, "validate"]
|
91
|
+
|
92
|
+
output = PopenWrapper.run(
|
93
|
+
cmd,
|
94
|
+
path,
|
95
|
+
args,
|
96
|
+
ignore_exitcode: ignore_exitcode,
|
97
|
+
workdir: workdir)
|
98
|
+
|
55
99
|
(output == 0)
|
56
100
|
end
|
57
101
|
|
@@ -79,6 +123,9 @@ module Covalence
|
|
79
123
|
raise "TODO: implement me"
|
80
124
|
end
|
81
125
|
|
126
|
+
def self.logger
|
127
|
+
Covalence::LOGGER
|
128
|
+
end
|
82
129
|
|
83
130
|
class << self
|
84
131
|
private
|
@@ -83,13 +83,27 @@ module Covalence
|
|
83
83
|
|
84
84
|
# :reek:FeatureEnvy
|
85
85
|
def parse_type(input)
|
86
|
+
Covalence::LOGGER.debug("parse_type input=#{input.inspect}")
|
87
|
+
|
86
88
|
if input.stringify_keys.has_key?('type')
|
87
89
|
type = input.stringify_keys.fetch('type')
|
88
90
|
|
91
|
+
# HACK This only pays attention to the first element in:
|
92
|
+
# - map(string) -> ["map", "string"]
|
93
|
+
# - list(string) -> ["list", "string"]
|
94
|
+
# But then again, this is exactly how Terraform 0.11.x forced
|
95
|
+
# us to handle it, so eh, yolo.
|
96
|
+
if type.respond_to?('each')
|
97
|
+
type = type[0]
|
98
|
+
end
|
99
|
+
|
89
100
|
local_types = %w(
|
90
101
|
list
|
102
|
+
set
|
91
103
|
map
|
92
104
|
string
|
105
|
+
number
|
106
|
+
tuple
|
93
107
|
)
|
94
108
|
|
95
109
|
if local_types.any? {|local_type| type == local_type }
|
@@ -41,14 +41,14 @@ module Covalence
|
|
41
41
|
"#{environment_name}-#{name}"
|
42
42
|
end
|
43
43
|
|
44
|
-
def materialize_cmd_inputs
|
44
|
+
def materialize_cmd_inputs(path)
|
45
45
|
if type == "terraform"
|
46
46
|
config = ""
|
47
47
|
inputs.values.map(&:to_command_option).each do |input|
|
48
48
|
config += input + "\n"
|
49
49
|
end
|
50
|
-
logger.info "\nStack inputs:\n\n#{config}"
|
51
|
-
File.open(
|
50
|
+
logger.info "#{module_path} \nStack inputs:\n\n#{config}"
|
51
|
+
File.open("#{path}/covalence-inputs.tfvars",'w') {|f| f.write(config)}
|
52
52
|
elsif type == "packer"
|
53
53
|
config = Hash.new
|
54
54
|
inputs.each do |name, input|
|
@@ -25,7 +25,7 @@ module Covalence
|
|
25
25
|
Dir.chdir(tmpdir) do
|
26
26
|
logger.info "In #{tmpdir}:"
|
27
27
|
|
28
|
-
stack.materialize_cmd_inputs
|
28
|
+
stack.materialize_cmd_inputs(tmpdir)
|
29
29
|
args = collect_args(stack.args,
|
30
30
|
additional_args,
|
31
31
|
"-var-file=covalence-inputs.json")
|
@@ -52,7 +52,7 @@ module Covalence
|
|
52
52
|
Dir.chdir(tmpdir) do
|
53
53
|
logger.info "In #{tmpdir}:"
|
54
54
|
|
55
|
-
stack.materialize_cmd_inputs
|
55
|
+
stack.materialize_cmd_inputs(tmpdir)
|
56
56
|
args = collect_args(stack.args,
|
57
57
|
additional_args,
|
58
58
|
"-var-file=covalence-inputs.json")
|
@@ -26,27 +26,50 @@ module Covalence
|
|
26
26
|
end
|
27
27
|
|
28
28
|
# :reek:TooManyStatements
|
29
|
-
def
|
29
|
+
def stack_shell
|
30
30
|
Dir.mktmpdir do |tmpdir|
|
31
31
|
populate_workspace(tmpdir)
|
32
32
|
Dir.chdir(tmpdir) do
|
33
33
|
logger.info "In #{tmpdir}:"
|
34
34
|
|
35
|
+
stack.materialize_state_inputs
|
35
36
|
TerraformCli.terraform_get(@path)
|
36
37
|
TerraformCli.terraform_init
|
37
38
|
|
38
|
-
stack.materialize_cmd_inputs
|
39
|
-
args = collect_args("-input=false",
|
40
|
-
stack.args,
|
41
|
-
"-var-file=covalence-inputs.tfvars")
|
42
|
-
|
43
|
-
TerraformCli.terraform_validate(args: args)
|
39
|
+
stack.materialize_cmd_inputs(tmpdir)
|
44
40
|
|
45
|
-
|
41
|
+
shell = ENV.fetch('SHELL', 'sh')
|
42
|
+
system(shell)
|
46
43
|
end
|
47
44
|
end
|
48
45
|
end
|
49
46
|
|
47
|
+
# :reek:TooManyStatements
|
48
|
+
def stack_verify(tmpdir)
|
49
|
+
return false if !TerraformCli.terraform_check_style(@path)
|
50
|
+
|
51
|
+
return false if !TerraformCli.terraform_get(path=@path, workdir=tmpdir)
|
52
|
+
populate_workspace(tmpdir)
|
53
|
+
|
54
|
+
return false if !TerraformCli.terraform_init(path: @path, workdir: tmpdir)
|
55
|
+
stack.materialize_cmd_inputs(tmpdir)
|
56
|
+
args = collect_args("-input=false",
|
57
|
+
stack.args,
|
58
|
+
"-var-file=#{tmpdir}/covalence-inputs.tfvars")
|
59
|
+
|
60
|
+
tf_vers = Gem::Version.new(Covalence::TERRAFORM_VERSION)
|
61
|
+
|
62
|
+
if tf_vers >= Gem::Version.new('0.12.0')
|
63
|
+
# >= 0.12 does *not* support validating input vars
|
64
|
+
return false if !TerraformCli.terraform_validate(path=tmpdir, workdir=tmpdir, args: stack.args)
|
65
|
+
else
|
66
|
+
# < 0.12 supports validating input vars
|
67
|
+
return false if !TerraformCli.terraform_validate(path=tmpdir, workdir=tmpdir, args: args)
|
68
|
+
end
|
69
|
+
|
70
|
+
TerraformCli.terraform_plan(path: @path , workdir: tmpdir, args: args)
|
71
|
+
end
|
72
|
+
|
50
73
|
# :reek:TooManyStatements
|
51
74
|
def stack_refresh
|
52
75
|
Dir.mktmpdir do |tmpdir|
|
@@ -60,7 +83,12 @@ module Covalence
|
|
60
83
|
TerraformCli.terraform_get(@path)
|
61
84
|
TerraformCli.terraform_init
|
62
85
|
|
63
|
-
|
86
|
+
stack.materialize_cmd_inputs(tmpdir)
|
87
|
+
args = collect_args("-input=false",
|
88
|
+
stack.args,
|
89
|
+
"-var-file=covalence-inputs.tfvars")
|
90
|
+
|
91
|
+
TerraformCli.terraform_refresh(args: args)
|
64
92
|
end
|
65
93
|
end
|
66
94
|
end
|
@@ -79,6 +107,8 @@ module Covalence
|
|
79
107
|
TerraformCli.terraform_init
|
80
108
|
|
81
109
|
stack.state_stores.drop(1).each do |store|
|
110
|
+
Covalence::LOGGER.debug("Stack: #{store.inspect}")
|
111
|
+
|
82
112
|
stack.materialize_state_inputs(store: store)
|
83
113
|
TerraformCli.terraform_init("-force-copy")
|
84
114
|
end
|
@@ -99,13 +129,13 @@ module Covalence
|
|
99
129
|
TerraformCli.terraform_get(@path)
|
100
130
|
TerraformCli.terraform_init
|
101
131
|
|
102
|
-
stack.materialize_cmd_inputs
|
132
|
+
stack.materialize_cmd_inputs(tmpdir)
|
103
133
|
args = collect_args("-input=false",
|
104
134
|
stack.args,
|
105
135
|
additional_args,
|
106
136
|
"-var-file=covalence-inputs.tfvars")
|
107
137
|
|
108
|
-
TerraformCli.terraform_plan(args: args)
|
138
|
+
TerraformCli.terraform_plan(path: @path, workdir: tmpdir, args: args)
|
109
139
|
end
|
110
140
|
end
|
111
141
|
end
|
@@ -123,7 +153,7 @@ module Covalence
|
|
123
153
|
TerraformCli.terraform_get(@path)
|
124
154
|
TerraformCli.terraform_init
|
125
155
|
|
126
|
-
stack.materialize_cmd_inputs
|
156
|
+
stack.materialize_cmd_inputs(tmpdir)
|
127
157
|
args = collect_args("-destroy",
|
128
158
|
"-input=false",
|
129
159
|
stack.args,
|
@@ -148,7 +178,7 @@ module Covalence
|
|
148
178
|
TerraformCli.terraform_get(@path)
|
149
179
|
TerraformCli.terraform_init
|
150
180
|
|
151
|
-
stack.materialize_cmd_inputs
|
181
|
+
stack.materialize_cmd_inputs(tmpdir)
|
152
182
|
args = collect_args("-input=false",
|
153
183
|
"-auto-approve=true",
|
154
184
|
stack.args,
|
@@ -173,7 +203,7 @@ module Covalence
|
|
173
203
|
TerraformCli.terraform_get(@path)
|
174
204
|
TerraformCli.terraform_init
|
175
205
|
|
176
|
-
stack.materialize_cmd_inputs
|
206
|
+
stack.materialize_cmd_inputs(tmpdir)
|
177
207
|
args = collect_args("-input=false",
|
178
208
|
"-auto-approve=true",
|
179
209
|
stack.args,
|
@@ -194,7 +224,6 @@ module Covalence
|
|
194
224
|
|
195
225
|
# Copy any dependencies to the workspace
|
196
226
|
@stack.dependencies.each do |dep|
|
197
|
-
logger.info "Copying '#{dep}' dependency to #{workspace}"
|
198
227
|
dep_path = File.expand_path(File.join(Covalence::TERRAFORM, dep))
|
199
228
|
FileUtils.cp_r dep_path, workspace
|
200
229
|
end
|
@@ -53,11 +53,19 @@ module Covalence
|
|
53
53
|
end
|
54
54
|
|
55
55
|
# Determine whether the document is a Terraform state file
|
56
|
-
tf_state = true if parsed.has_key?('
|
56
|
+
tf_state = true if parsed.has_key?('terraform_version')
|
57
57
|
|
58
58
|
# Return ID for the key specified
|
59
59
|
if tf_state
|
60
|
-
|
60
|
+
tf_vers = Gem::Version.new(parsed.fetch('terraform_version'))
|
61
|
+
|
62
|
+
if tf_vers >= Gem::Version.new('0.12.0')
|
63
|
+
root = parsed
|
64
|
+
else
|
65
|
+
root = parsed.fetch('modules')[0]
|
66
|
+
end
|
67
|
+
|
68
|
+
outputs = root.fetch('outputs')
|
61
69
|
return outputs.fetch(name)
|
62
70
|
end
|
63
71
|
return parsed.fetch(name) if parsed.has_key?(name)
|
@@ -98,9 +106,9 @@ CONF
|
|
98
106
|
end
|
99
107
|
end
|
100
108
|
|
101
|
-
params.delete('name')
|
102
|
-
|
103
109
|
params.each do |k,v|
|
110
|
+
next if k == 'name'
|
111
|
+
|
104
112
|
v = Covalence::Helpers::ShellInterpolation.parse_shell(v) if v.to_s.include?("$(")
|
105
113
|
config += " #{k} = \"#{v}\"\n"
|
106
114
|
end
|
@@ -156,7 +156,13 @@ module Covalence
|
|
156
156
|
desc "Verify the #{stack_name} stack of the #{environment_name} environment"
|
157
157
|
# Maybe verify_local to highlight that it skips pulling in remote state
|
158
158
|
task generate_rake_taskname(environment_name, stack_name, "verify") do
|
159
|
-
|
159
|
+
_tmp_dir = Dir.mktmpdir
|
160
|
+
tf_tasks.stack_verify(_tmp_dir)
|
161
|
+
end
|
162
|
+
|
163
|
+
desc "Shell into the #{stack_name} stack of the #{environment_name} environment"
|
164
|
+
task generate_rake_taskname(environment_name, stack_name, "shell") do
|
165
|
+
tf_tasks.stack_shell
|
160
166
|
end
|
161
167
|
end
|
162
168
|
|
@@ -5,71 +5,35 @@ module Covalence
|
|
5
5
|
TEST_ENVS.include?(environ.name.to_s)
|
6
6
|
end
|
7
7
|
|
8
|
+
jobs = Queue.new
|
9
|
+
# populate the job queue
|
8
10
|
environments.each do |environment|
|
9
11
|
environment.stacks.each do |stack|
|
10
12
|
EnvironmentRepository.populate_stack(stack)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
it 'passes validation' do
|
31
|
-
tmp_dir = Dir.mktmpdir
|
32
|
-
# Copy module to the workspace
|
33
|
-
FileUtils.copy_entry path, tmp_dir
|
34
|
-
|
35
|
-
# Copy any dependencies to the workspace
|
36
|
-
stack.dependencies.each do |dep|
|
37
|
-
dep_path = File.expand_path(File.join(Covalence::TERRAFORM, dep))
|
38
|
-
FileUtils.cp_r dep_path, tmp_dir
|
39
|
-
end
|
40
|
-
|
41
|
-
Dir.chdir(tmp_dir) do
|
42
|
-
expect {
|
43
|
-
expect(TerraformCli.terraform_get(path)).to be true
|
44
|
-
}.to_not raise_error
|
45
|
-
|
46
|
-
expect {
|
47
|
-
expect(TerraformCli.terraform_init).to be true
|
48
|
-
}.to_not raise_error
|
49
|
-
|
50
|
-
stack.materialize_cmd_inputs
|
51
|
-
|
52
|
-
expect {
|
53
|
-
expect(TerraformCli.terraform_validate("-input=false -var-file=covalence-inputs.tfvars")).to be true
|
54
|
-
}.to_not raise_error
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'passes execution' do
|
59
|
-
expect {
|
60
|
-
expect(tf_tasks.stack_verify).to be true
|
61
|
-
}.to_not raise_error
|
62
|
-
end
|
63
|
-
|
64
|
-
elsif stack.type == 'packer'
|
65
|
-
|
66
|
-
it 'passes validation' do
|
67
|
-
expect {
|
68
|
-
expect(packer_tasks.context_validate(stack.contexts.first.to_packer_command_options)).to be true
|
69
|
-
}.to_not raise_error
|
13
|
+
jobs.push(stack)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
Covalence::LOGGER.info "jobs.length: #{jobs.length}"
|
17
|
+
|
18
|
+
# start the workers
|
19
|
+
myworkers = (Covalence::WORKER_COUNT).times.map do
|
20
|
+
Thread.new do
|
21
|
+
begin
|
22
|
+
while stack = jobs.pop(true)
|
23
|
+
case stack.type
|
24
|
+
when 'terraform'
|
25
|
+
_tmp_dir = Dir.mktmpdir
|
26
|
+
tf_tasks = TerraformStackTasks.new(stack)
|
27
|
+
exit false if !tf_tasks.stack_verify(_tmp_dir)
|
28
|
+
when 'packer'
|
29
|
+
packer_tasks = PackerStackTasks.new(stack)
|
30
|
+
exit false if !packer_tasks.context_validate(stack.contexts.first.to_packer_command_options)
|
70
31
|
end
|
71
32
|
end
|
33
|
+
rescue ThreadError => e
|
72
34
|
end
|
73
35
|
end
|
74
36
|
end
|
37
|
+
myworkers.map(&:join)
|
75
38
|
end
|
39
|
+
|
data/lib/covalence/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: covalence
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Unif.io
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deep_merge
|
@@ -318,6 +318,20 @@ dependencies:
|
|
318
318
|
- - "~>"
|
319
319
|
- !ruby/object:Gem::Version
|
320
320
|
version: 0.16.1
|
321
|
+
- !ruby/object:Gem::Dependency
|
322
|
+
name: solargraph
|
323
|
+
requirement: !ruby/object:Gem::Requirement
|
324
|
+
requirements:
|
325
|
+
- - ">="
|
326
|
+
- !ruby/object:Gem::Version
|
327
|
+
version: '0'
|
328
|
+
type: :development
|
329
|
+
prerelease: false
|
330
|
+
version_requirements: !ruby/object:Gem::Requirement
|
331
|
+
requirements:
|
332
|
+
- - ">="
|
333
|
+
- !ruby/object:Gem::Version
|
334
|
+
version: '0'
|
321
335
|
description:
|
322
336
|
email:
|
323
337
|
- support@unif.io
|
@@ -383,7 +397,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
383
397
|
version: '0'
|
384
398
|
requirements: []
|
385
399
|
rubyforge_project:
|
386
|
-
rubygems_version: 2.7.
|
400
|
+
rubygems_version: 2.7.6.2
|
387
401
|
signing_key:
|
388
402
|
specification_version: 4
|
389
403
|
summary: A tool for the management and orchestration of data used by HashiCorp infrastructure
|