covalence 0.9.4 → 0.9.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e582e052d83a662baeed4667865ec554342ec1f9577f8a64dc5f6aa392ba4fd7
4
- data.tar.gz: 1d7322252f3bda71c44da746ef0e7b287d2bf8f22dd1f175097ead702ca56e5f
3
+ metadata.gz: a1b7249a87a530a5f4fe459276b5a19a91a81ffc3c89dbae36ea04701c1b44d7
4
+ data.tar.gz: 280e25c48b7c45c91081f272c432ff10314f5b45b8437edf690abd6b068dd99b
5
5
  SHA512:
6
- metadata.gz: 7a67fb51176b299bf7ccf58683d4d1a9f33c1bc7c10c3b388e7c72103bbe40582b902b74c3d0419a262a80cfb1f37993792efafd4b3bb24fc2bf3a13ef17f5d1
7
- data.tar.gz: dbb26cb3f24ac7df90ff6068cb0121c0e03dadf8f0be530d160844e26b76608a07806790b56484169195fb503782e6c2b006e2da4ece79594b739527eea1a8a1
6
+ metadata.gz: 430b7d77796d29c5f12e6210176b9085eb09e99d668d0d8568d9c7a07e862ee3696eabe48613ecb6e789f33a9b3a3af7a33d0614dd4cbc2e050bcc898faf502c
7
+ data.tar.gz: 7458eb37454bff3aee3f73fae29df261e6e5e2f0390c6177aad9e9509166d3875bda84a6501757f83f1b024ee5cde8b0e54d6d2d5093b8f5da17e8afd20dea01
@@ -1,3 +1,30 @@
1
+ ## 0.9.9 (Sept 10, 2020)
2
+ IMPROVEMENTS:
3
+ - Updated all gems to the latest in the Gemfile.lock.
4
+
5
+ ## 0.9.8 (Jun 10, 2020)
6
+ IMPROVEMENTS:
7
+ - Updated all gems to the latest in the Gemfile.lock.
8
+
9
+ BACKWARDS INCOMPATIBILITIES:
10
+ - Issue [#90](https://github.com/unifio/covalence/issues/90) Removed prefixout dependency from covalence. Directory prefix will no longer be displayed in output. Directory is already output prior to execution.
11
+
12
+ FIXES:
13
+ - [activesupport](https://github.com/advisories/GHSA-2p68-f74v-9wc6) upgraded activesupport to version 5.2.4.3 or later.
14
+ - [nokogiri](https://github.com/advisories/GHSA-7553-jr98-vx47) Upgrade nokogiri to version 1.10.8 or later.
15
+
16
+ ## 0.9.7 (Sep 14, 2019)
17
+
18
+ IMPROVEMENTS:
19
+ - Issue [#88](https://github.com/unifio/covalence/issues/88) Add input processing to packer stacks. Allows for shell interpolation processing on inputs for packer stacks.
20
+ - Can use the shell interpolation in the template to generate AWS assume role temporary keys to populate template. This allows for role assumption since role assumption is not supported from `~/.aws/config` attributes.
21
+
22
+ ## 0.9.6 (Sep 9, 2019)
23
+
24
+ IMPROVEMENTS:
25
+ - Issue [#86](https://github.com/unifio/covalence/issues/86) Add ability to export stacks to a stack_exports directory.
26
+
27
+
1
28
  ## 0.9.4 (Aug 30, 2019)
2
29
 
3
30
  FIXES:
data/README.md CHANGED
@@ -106,7 +106,6 @@ $ bin/covalence spec
106
106
  ```
107
107
 
108
108
  To run the Rspec test locally without container, you will need to install the following:
109
- * prefixout -- https://github.com/WhistleLabs/prefixout
110
109
  * sops -- https://github.com/mozilla/sops
111
110
 
112
111
  ### UAT
@@ -502,7 +501,6 @@ You will probably need the following packages installed locally
502
501
  - Terraform
503
502
  - Packer
504
503
  - Sops
505
- - [prefixout](https://github.com/unifio/prefixout/releases)
506
504
 
507
505
  Execute the following to build the gem:
508
506
 
@@ -17,6 +17,7 @@ module Covalence
17
17
  # TODO: could use better naming
18
18
  PACKER = File.absolute_path(File.join(WORKSPACE, (ENV['COVALENCE_PACKER_DIR'] || '.')))
19
19
  TERRAFORM = File.absolute_path(File.join(WORKSPACE, (ENV['COVALENCE_TERRAFORM_DIR'] || '.')))
20
+ STACK_EXPORT = File.absolute_path(File.join(WORKSPACE, (ENV['COVALENCE_STACK_EXPORT_DIR'] || './stack-exports')))
20
21
  TEST_ENVS = (ENV['COVALENCE_TEST_ENVS'] || "").split(',')
21
22
  # Reserved namespace including default ci and spec
22
23
  RESERVED_NS = [(ENV['COVALENCE_RESERVED_NAMESPACE'] || "").split(','), 'ci', 'spec', 'sops']
@@ -77,9 +77,7 @@ module Covalence
77
77
  # so when the parent dies, child will know to terminate itself.
78
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" }
79
79
  wait_thread = nil
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|
80
+ Open3.popen3(env, *run_cmd, :chdir=>workdir) do |stdin, stdout, stderr, wait_thr|
83
81
  mappings = { stdin_io => stdin, stdout => stdout_io, stderr => stderr_io }
84
82
  wait_thread = wait_thr
85
83
 
@@ -28,6 +28,10 @@ module Covalence
28
28
  "#{name} = #{parse_input(value())}"
29
29
  end
30
30
 
31
+ def to_command_hash_elements
32
+ return name, parse_input(value()).delete_prefix('"').delete_suffix('"')
33
+ end
34
+
31
35
  private
32
36
 
33
37
  def get_value(input)
@@ -51,19 +51,19 @@ module Covalence
51
51
  File.open("#{path}/covalence-inputs.tfvars",'w') {|f| f.write(config)}
52
52
  elsif type == "packer"
53
53
  config = Hash.new
54
- inputs.each do |name, input|
55
- config[name] = input.value
54
+ inputs.values.map(&:to_command_hash_elements).each do |name, input|
55
+ config["#{name}"] = input
56
56
  end
57
57
  config_json = JSON.generate(config)
58
- logger.info "\nStack inputs:\n\n#{config_json}"
59
- File.open('covalence-inputs.json','w') {|f| f.write(config_json)}
58
+ logger.info "path: #{path} module_path: #{module_path}\nStack inputs:\n\n#{config_json}"
59
+ File.open("#{path}/covalence-inputs.json",'w') {|f| f.write(config_json)}
60
60
  end
61
61
  end
62
62
 
63
- def materialize_state_inputs(store: state_stores.first)
63
+ def materialize_state_inputs(store: state_stores.first, path: '.')
64
64
  config = store.get_config
65
65
  logger.info "\nState store configuration:\n\n#{config}"
66
- File.open('covalence-state.tf','w') {|f| f.write(config)}
66
+ File.open("#{path}/covalence-state.tf",'w') {|f| f.write(config)}
67
67
  end
68
68
 
69
69
  def logger
@@ -62,6 +62,14 @@ module Covalence
62
62
  end
63
63
  end
64
64
 
65
+ # :reek:TooManyStatements
66
+ def packer_stack_export()
67
+ packer_stack_export_init(File.expand_path(File.join(Covalence::STACK_EXPORT,'packer',stack.full_name))).each do |stackdir|
68
+ populate_workspace(stackdir)
69
+ stack.materialize_cmd_inputs(stackdir)
70
+ logger.info "Exported to #{stackdir}:"
71
+ end
72
+ end
65
73
  private
66
74
  attr_reader :template_path, :stack
67
75
 
@@ -97,6 +105,23 @@ module Covalence
97
105
  args.flatten.compact.reject(&:empty?).map(&:strip)
98
106
  end
99
107
 
108
+ # :reek:BooleanParameter
109
+ def packer_stack_export_init(stackdir, dry_run: false, verbose: true)
110
+ if(File.exist?(stackdir))
111
+ logger.info "Deleting before export: #{stackdir}"
112
+ FileUtils.rm_rf(stackdir, {
113
+ noop: dry_run,
114
+ verbose: verbose,
115
+ secure: true,
116
+ })
117
+ end
118
+ logger.info "Creating stack directory: #{stackdir}"
119
+ FileUtils.mkdir_p(stackdir, {
120
+ noop: dry_run,
121
+ verbose: verbose,
122
+ })
123
+ end
124
+
100
125
  def logger
101
126
  Covalence::LOGGER
102
127
  end
@@ -44,6 +44,18 @@ module Covalence
44
44
  end
45
45
  end
46
46
 
47
+ # :reek:TooManyStatements
48
+ def stack_export
49
+ stack_export_init(File.expand_path(File.join(Covalence::STACK_EXPORT,'terraform',stack.full_name))).each do |stackdir|
50
+ populate_workspace(stackdir)
51
+ stack.materialize_state_inputs(path: stackdir)
52
+ TerraformCli.terraform_get(path=@path, workdir=stackdir)
53
+ TerraformCli.terraform_init(path: @path, workdir: stackdir)
54
+ stack.materialize_cmd_inputs(stackdir)
55
+ logger.info "Exported to #{stackdir}:"
56
+ end
57
+ end
58
+
47
59
  # :reek:TooManyStatements
48
60
  def stack_verify(tmpdir)
49
61
  return false if !TerraformCli.terraform_check_style(@path)
@@ -229,6 +241,23 @@ module Covalence
229
241
  end
230
242
  end
231
243
 
244
+ # :reek:BooleanParameter
245
+ def stack_export_init(stackdir, dry_run: false, verbose: true)
246
+ if(File.exist?(stackdir))
247
+ logger.info "Deleting before export: #{stackdir}"
248
+ FileUtils.rm_rf(stackdir, {
249
+ noop: dry_run,
250
+ verbose: verbose,
251
+ secure: true,
252
+ })
253
+ end
254
+ logger.info "Creating stack directory: #{stackdir}"
255
+ FileUtils.mkdir_p(stackdir, {
256
+ noop: dry_run,
257
+ verbose: verbose,
258
+ })
259
+ end
260
+
232
261
  def logger
233
262
  Covalence::LOGGER
234
263
  end
@@ -126,6 +126,12 @@ module Covalence
126
126
  custom_opts = Slop.parse(get_runtime_args, { suppress_errors: true, banner: false })
127
127
  packer_tasks.context_validate(target_args, custom_opts.args)
128
128
  end
129
+
130
+ desc "Export the #{stack_name} stack of the #{environment_name} environment to #{Covalence::STACK_EXPORT}/packer"
131
+ task generate_rake_taskname(environment_name, stack_name, "packer_stack_export") do
132
+ packer_tasks.packer_stack_export()
133
+ end
134
+
129
135
  end
130
136
 
131
137
  # :reek:TooManyStatements
@@ -164,6 +170,12 @@ module Covalence
164
170
  task generate_rake_taskname(environment_name, stack_name, "shell") do
165
171
  tf_tasks.stack_shell
166
172
  end
173
+
174
+ desc "Export the #{stack_name} stack of the #{environment_name} environment to #{Covalence::STACK_EXPORT}/terraform"
175
+ task generate_rake_taskname(environment_name, stack_name, "stack_export") do
176
+ tf_tasks.stack_export
177
+ end
178
+
167
179
  end
168
180
 
169
181
  # :reek:TooManyStatements
@@ -1,3 +1,3 @@
1
1
  module Covalence
2
- VERSION = "0.9.4"
2
+ VERSION = "0.9.9"
3
3
  end
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.9.4
4
+ version: 0.9.9
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-31 00:00:00.000000000 Z
11
+ date: 2020-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deep_merge
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: json
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 2.1.0
47
+ version: 2.3.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 2.1.0
54
+ version: 2.3.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rest-client
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -254,14 +254,14 @@ dependencies:
254
254
  requirements:
255
255
  - - "~>"
256
256
  - !ruby/object:Gem::Version
257
- version: 2.4.0
257
+ version: 2.7.5
258
258
  type: :development
259
259
  prerelease: false
260
260
  version_requirements: !ruby/object:Gem::Requirement
261
261
  requirements:
262
262
  - - "~>"
263
263
  - !ruby/object:Gem::Version
264
- version: 2.4.0
264
+ version: 2.7.5
265
265
  - !ruby/object:Gem::Dependency
266
266
  name: byebug
267
267
  requirement: !ruby/object:Gem::Requirement