covalence 0.7.9.rc1 → 0.8.0

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: 6996b380a260e1574dddef9841685368579573823dd9df81ee8b2e2049b17ad6
4
- data.tar.gz: 22b8030ef7c9ae4acd112fe3446958e04de60dc871e8c0582a7478ff972c3837
3
+ metadata.gz: 5182025f5f5eabe3341b2b1b96414d4392abfc57453018fbce9c4a6887d5a6e1
4
+ data.tar.gz: 4d0850fbd8211d219254dd585af563c6caed2e5e06605dee272f2e4ef91a7bce
5
5
  SHA512:
6
- metadata.gz: 432db3aa484713ec86a56970402789b3e3b3b0c71877a16e7d5840b3546a40a56d5246b57b50514b1e85da5504a3f992c06b18f02bc975a33671f2d9654f633a
7
- data.tar.gz: 9bd16e47bbab6d00b73c5ef87d61f5720b7e767380a21afdd82a9b31e49c2d02ce28d97d134c157371a0bf2cc2a089c339409e04ce9728d7706bf364b460e276
6
+ metadata.gz: 23f0b2e254b8f7bfae871be474a9a309fac6e51903e23d341dd060bf73f708e8d4384c57c865733b63f99ada4f739b78bf72f4934adb2c0565b9e1a34b59b8a3
7
+ data.tar.gz: cf5a2c8e35821c4b086549eede664ade69d610ad18c8cac19404fb92b13b38088832e542f83257590514b94a184ea7aa6587634d80ca0e43fafcbed63c35e2c8
data/README.md CHANGED
@@ -504,8 +504,11 @@ vpc_id:
504
504
 
505
505
  Covalence is packaged as a Ruby Gem.
506
506
 
507
+ You will probably need the following packages installed locally
508
+ - Terraform
509
+ - Packer
510
+ - Sops
511
+
507
512
  Execute the following to build the gem:
508
513
 
509
514
  `$ gem build covalence.gemspec`
510
-
511
- Gem artifacts are hosted at https://repo.fury.io/unifio/.
@@ -26,6 +26,11 @@ module Covalence
26
26
 
27
27
  PACKER_CMD = ENV['PACKER_CMD'] || "packer"
28
28
 
29
+ SOPS_CMD = ENV['SOPS_CMD'] || "sops"
30
+ SOPS_VERSION = ENV['SOPS_VERSION'] || (`#{SOPS_CMD} --version`.gsub(/[^\d\.]/, '') rescue "0.0.0")
31
+ SOPS_ENCRYPTED_SUFFIX = ENV['SOPS_ENCRYPTED_SUFFIX'] || "-encrypted"
32
+ SOPS_DECRYPTED_SUFFIX = ENV['SOPS_DECRYPTED_SUFFIX'] || "-decrypted"
33
+
29
34
  # No-op shell command. Should not need to modify for most unix shells.
30
35
  DRY_RUN_CMD = (ENV['COVALENCE_DRY_RUN_CMD'] || ":")
31
36
  DEBUG_CLI = (ENV['COVALENCE_DEBUG'] || 'false') =~ (/(true|t|yes|y|1)$/i)
@@ -0,0 +1,27 @@
1
+ require 'rake'
2
+ require 'consul_loader'
3
+ require_relative '../covalence'
4
+
5
+ module Covalence
6
+ class ConsulTasks
7
+ extend Rake::DSL
8
+
9
+ def self.run
10
+ desc 'Load K/V data into Consul service'
11
+ task 'consul_load' do
12
+ load_yaml("#{ENV['CONSUL_KV_FILE']}")
13
+ end
14
+ end
15
+
16
+ class << self
17
+ private
18
+ def load_yaml(filename)
19
+ consul_loader = ConsulLoader::Loader.new(ConsulLoader::ConfigParser.new)
20
+ consul_server = "http://#{ENV['CONSUL_HTTP_ADDR']}"
21
+ consul_loader.load_config(filename, consul_server)
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ Covalence::ConsulTasks.run
@@ -0,0 +1,82 @@
1
+ require 'semantic'
2
+ require 'fileutils'
3
+ require 'yaml'
4
+ require 'active_support/core_ext/object/blank'
5
+
6
+ module Covalence
7
+ class SopsCli
8
+
9
+ DIRECTION = {
10
+ encrypt: {
11
+ sops_option: "--encrypt",
12
+ file_search_suffix: "-decrypted",
13
+ file_replace_suffix: "-encrypted"
14
+ },
15
+ decrypt: {
16
+ sops_option: "--decrypt",
17
+ file_search_suffix: "-encrypted",
18
+ file_replace_suffix: "-decrypted"
19
+ }
20
+ }
21
+
22
+ def self.encrypt_path(path=default_data_dir, extension=".yaml")
23
+ modify_files(DIRECTION[:encrypt], path, extension)
24
+ end
25
+
26
+ def self.decrypt_path(path=default_data_dir, extension=".yaml")
27
+ modify_files(DIRECTION[:decrypt], path, extension)
28
+ end
29
+
30
+ # Clean targets all extensions by default, sounds like a more secure way to avoid commiting something accidentally
31
+ def self.clean_decrypt_path(path, extension="*", dry_run: false, verbose: true)
32
+ file_path = File.expand_path(path)
33
+
34
+ if File.file?(file_path)
35
+ files = [file_path]
36
+ else
37
+ files = Dir.glob(File.join(file_path, "**" , "*#{DIRECTION[:decrypt][:file_replace_suffix]}#{extension}"))
38
+ end
39
+
40
+ unless files.blank?
41
+ FileUtils.rm_f(files, {
42
+ noop: dry_run,
43
+ verbose: verbose
44
+ })
45
+ end
46
+ end
47
+
48
+ def self.default_data_dir
49
+ @default_data_dir ||= File.join(WORKSPACE, YAML.load_file(CONFIG).fetch(:yaml, {}).fetch(:datadir, ""))
50
+ end
51
+
52
+ class << self
53
+ private
54
+
55
+ # Intentionally unified the logic so that encryption and decryption would follow the
56
+ # same path and avoid logic forking
57
+ def modify_files(direction_hash, path, extension=".yaml")
58
+ if Semantic::Version.new(Covalence::SOPS_VERSION) < Semantic::Version.new("3.0.0")
59
+ raise "Sops v3.0.0 or newer required"
60
+ end
61
+
62
+ files = []
63
+ file_path = File.expand_path(path)
64
+ cmd = [Covalence::SOPS_CMD, direction_hash[:sops_option]]
65
+
66
+ if File.file?(file_path)
67
+ files = [file_path]
68
+ else
69
+ files = Dir.glob(File.join(file_path, "**" , "*#{direction_hash[:file_search_suffix]}#{extension}"))
70
+ end
71
+
72
+ files.map do |file|
73
+ dirname, basename = File.split(file)
74
+ new_file = File.join(dirname, basename.gsub(direction_hash[:file_search_suffix],direction_hash[:file_replace_suffix]))
75
+
76
+ break unless (PopenWrapper.run(cmd, file, "> #{new_file}") == 0)
77
+ new_file
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
@@ -6,7 +6,7 @@ module Covalence
6
6
 
7
7
  def self.parse_shell(input)
8
8
  Covalence::LOGGER.info "Evaluating requested interpolation: \"#{input}\""
9
- matches = input.scan(/.?\$\([^)]*\)/)
9
+ matches = input.scan(/.?\$\([^)]*\)+/)
10
10
 
11
11
  Covalence::LOGGER.debug "matches: #{matches}"
12
12
  matches.each do |cmd|
@@ -0,0 +1,33 @@
1
+ require 'rake'
2
+ require 'consul_loader'
3
+ require_relative '../covalence'
4
+ require_relative 'core/cli_wrappers/sops_cli'
5
+
6
+ module Covalence
7
+ class SopsTasks
8
+ extend Rake::DSL
9
+
10
+ def self.run
11
+ desc 'Decrypt files in [:path, :extension]'
12
+ task 'sops:decrypt_path', [:path, :extension] do |t, args|
13
+ # should have defaults in just one place but rake isn't a terribly great entrypoint to centralize on
14
+ SopsCli.decrypt_path(args[:path] || SopsCli.default_data_dir,
15
+ args[:extension] || ".yaml")
16
+ end
17
+
18
+ desc 'Encrypt files in [:path, :extension]'
19
+ task 'sops:encrypt_path', [:path, :extension] do |t, args|
20
+ SopsCli.encrypt_path(args[:path] || SopsCli.default_data_dir,
21
+ args[:extension] || ".yaml")
22
+ end
23
+
24
+ desc 'Clean decrypt files in [:path, :extension]'
25
+ task 'sops:clean_decrypt_path', [:path, :extension] do |t, args|
26
+ SopsCli.clean_decrypt_path(args[:path] || SopsCli.default_data_dir,
27
+ args[:extension] || "*")
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ Covalence::SopsTasks.run
@@ -1,3 +1,3 @@
1
1
  module Covalence
2
- VERSION = "0.7.9.rc1"
2
+ VERSION = "0.8.0"
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.7.9.rc1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Unif.io
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-14 00:00:00.000000000 Z
11
+ date: 2018-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deep_merge
@@ -178,6 +178,20 @@ dependencies:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
180
  version: 1.7.10
181
+ - !ruby/object:Gem::Dependency
182
+ name: consul_loader
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: 1.0.0
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: 1.0.0
181
195
  - !ruby/object:Gem::Dependency
182
196
  name: ci_reporter_rspec
183
197
  requirement: !ruby/object:Gem::Requirement
@@ -262,20 +276,6 @@ dependencies:
262
276
  - - "~>"
263
277
  - !ruby/object:Gem::Version
264
278
  version: 10.0.2
265
- - !ruby/object:Gem::Dependency
266
- name: serverspec
267
- requirement: !ruby/object:Gem::Requirement
268
- requirements:
269
- - - "~>"
270
- - !ruby/object:Gem::Version
271
- version: 2.41.3
272
- type: :development
273
- prerelease: false
274
- version_requirements: !ruby/object:Gem::Requirement
275
- requirements:
276
- - - "~>"
277
- - !ruby/object:Gem::Version
278
- version: 2.41.3
279
279
  - !ruby/object:Gem::Dependency
280
280
  name: webmock
281
281
  requirement: !ruby/object:Gem::Requirement
@@ -290,20 +290,6 @@ dependencies:
290
290
  - - "~>"
291
291
  - !ruby/object:Gem::Version
292
292
  version: 3.4.1
293
- - !ruby/object:Gem::Dependency
294
- name: gemfury
295
- requirement: !ruby/object:Gem::Requirement
296
- requirements:
297
- - - "~>"
298
- - !ruby/object:Gem::Version
299
- version: 0.7.0
300
- type: :development
301
- prerelease: false
302
- version_requirements: !ruby/object:Gem::Requirement
303
- requirements:
304
- - - "~>"
305
- - !ruby/object:Gem::Version
306
- version: 0.7.0
307
293
  - !ruby/object:Gem::Dependency
308
294
  name: fabrication
309
295
  requirement: !ruby/object:Gem::Requirement
@@ -344,10 +330,12 @@ files:
344
330
  - README.md
345
331
  - TODO.md
346
332
  - lib/covalence.rb
333
+ - lib/covalence/consul_tasks.rb
347
334
  - lib/covalence/core/bootstrap.rb
348
335
  - lib/covalence/core/cli_wrappers/packer.yml
349
336
  - lib/covalence/core/cli_wrappers/packer_cli.rb
350
337
  - lib/covalence/core/cli_wrappers/popen_wrapper.rb
338
+ - lib/covalence/core/cli_wrappers/sops_cli.rb
351
339
  - lib/covalence/core/cli_wrappers/terraform.yml
352
340
  - lib/covalence/core/cli_wrappers/terraform_cli.rb
353
341
  - lib/covalence/core/data_stores/hiera.rb
@@ -372,6 +360,7 @@ files:
372
360
  - lib/covalence/helpers/spec_dependencies.rb
373
361
  - lib/covalence/rake/rspec/envs_spec.rb
374
362
  - lib/covalence/rake/rspec/yaml_spec.rb
363
+ - lib/covalence/sops_tasks.rb
375
364
  - lib/covalence/spec_tasks.rb
376
365
  - lib/covalence/version.rb
377
366
  homepage: https://unif.io
@@ -389,12 +378,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
389
378
  version: 2.0.0
390
379
  required_rubygems_version: !ruby/object:Gem::Requirement
391
380
  requirements:
392
- - - ">"
381
+ - - ">="
393
382
  - !ruby/object:Gem::Version
394
- version: 1.3.1
383
+ version: '0'
395
384
  requirements: []
396
385
  rubyforge_project:
397
- rubygems_version: 2.7.6
386
+ rubygems_version: 2.7.7
398
387
  signing_key:
399
388
  specification_version: 4
400
389
  summary: A tool for the management and orchestration of data used by HashiCorp infrastructure