covalence 0.9.4 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e582e052d83a662baeed4667865ec554342ec1f9577f8a64dc5f6aa392ba4fd7
4
- data.tar.gz: 1d7322252f3bda71c44da746ef0e7b287d2bf8f22dd1f175097ead702ca56e5f
3
+ metadata.gz: b372b94458c0383c9a9263aa100c6eeefac5272a368dc34cf6afd8c3257de854
4
+ data.tar.gz: ebff45449ebc015268d475cdc156e354fa5c7fd211d595c7c683f7b81d7e2895
5
5
  SHA512:
6
- metadata.gz: 7a67fb51176b299bf7ccf58683d4d1a9f33c1bc7c10c3b388e7c72103bbe40582b902b74c3d0419a262a80cfb1f37993792efafd4b3bb24fc2bf3a13ef17f5d1
7
- data.tar.gz: dbb26cb3f24ac7df90ff6068cb0121c0e03dadf8f0be530d160844e26b76608a07806790b56484169195fb503782e6c2b006e2da4ece79594b739527eea1a8a1
6
+ metadata.gz: 053e2a2ed3b5ada2f038b61e4befb2397212391de87eb88d8c5fe601afc830f3d5efc616026b24ac9ff75dc369e7992e774e2243f95267c5f1406281d0b4703b
7
+ data.tar.gz: 0b705e69d534e21c88919dda3fc2aa2dd9179fecff9e80548a0ff45172e373aea1680e8771175a13ba24adfbe66ce133abfa5c69ee72b56aeec770d96d03dd76
@@ -1,3 +1,9 @@
1
+ ## 0.9.5 (Sep 9, 2019)
2
+
3
+ IMPROVEMENTS:
4
+ - Issue [#86](https://github.com/unifio/covalence/issues/86) Add ability to export stacks to a stack_exports directory.
5
+
6
+
1
7
  ## 0.9.4 (Aug 30, 2019)
2
8
 
3
9
  FIXES:
@@ -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']
@@ -55,15 +55,15 @@ module Covalence
55
55
  config[name] = input.value
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 packer/#{Covalence::STACK_EXPORT}"
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 terraform/#{Covalence::STACK_EXPORT}"
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.5"
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.5
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: 2019-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deep_merge