consult 0.9.0 → 0.10.0.pre

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: 36965e0fbed738e72487cda4371047459b67bcc980b2926fc74e604feadbc712
4
- data.tar.gz: 6922f60403c25f25b944648319a3ad1dc3fb680c850688399559c34e0e0afaac
3
+ metadata.gz: 04de1a20dd8943a9c3740bcdd00a2b087c4dd8c706deb8ad47896f72a643ca6b
4
+ data.tar.gz: 03211311d716648cee6d9d42fb834919b616428015c860e48cbc0e04ae111e4b
5
5
  SHA512:
6
- metadata.gz: f1690e8cd6ae71d813e26c77e71ae37916c1b6e15c142f2c4cc34975e18e38c5622f006d9d1c840e98b35476c4b9c6b503fd73f482f495cc962c215eda7a0247
7
- data.tar.gz: e5013584ee2e288d2c75cb21ae746bb1409e598eeb2aba8499e58ea50d3a1c5db5ebb0b6389f94926df5e27ebab9fa9f0966e5c9073f331f2937717e8d8b063a
6
+ metadata.gz: c21b28fc79d2480d57e16aad107ecaf6d3e1f38609c781222263b1c98d6cd6e9dd903fc822a5e99ac89bd22f981ae19b9eb74f418ea62f1ec989ac9c6544948c
7
+ data.tar.gz: a9fa5fc6d4af723125ed276a69391036eef91a2eef94ffe4e46d1587fa5154b8ad6f5411ec51f6bc74ba0edfcf97a99b950b361d3a76462bea75b5df9a19202c
@@ -0,0 +1,78 @@
1
+ version: 2.1
2
+
3
+ jobs:
4
+ test:
5
+ parameters:
6
+ ruby_version:
7
+ type: string
8
+
9
+ docker:
10
+ - image: circleci/ruby:<< parameters.ruby_version >>
11
+ - image: consul:1.3.0
12
+ - image: vault:0.11.3
13
+ environment:
14
+ - VAULT_DEV_ROOT_TOKEN_ID=94e1a9ed-5d72-5677-27ab-ebc485cca368
15
+ # - SKIP_SETCAP=skip
16
+ # cap_add:
17
+ # - IPC_LOCK
18
+
19
+ working_directory: ~/repo
20
+
21
+ steps:
22
+ - checkout
23
+
24
+ - restore_cache:
25
+ name: restore gem cache
26
+ keys:
27
+ - v1-bundle-<< parameters.ruby_version >>-{{ .Branch }}-{{ checksum "consult.gemspec" }}
28
+ - v1-bundle-<< parameters.ruby_version >>-{{ .Branch }}-
29
+ - v1-bundle-<< parameters.ruby_version >>-
30
+
31
+ - run:
32
+ name: install dependencies
33
+ command: |
34
+ bundle check --path ./vendor/bundle || bundle install --jobs=3 --retry=3 --path vendor/bundle
35
+ bundle clean
36
+
37
+ - save_cache:
38
+ name: save gem cache
39
+ paths:
40
+ - ./vendor/bundle
41
+ key: v1-bundle-<< parameters.ruby_version >>-{{ .Branch }}-{{ checksum "consult.gemspec" }}
42
+
43
+ - run:
44
+ name: setup fixture data
45
+ command: |
46
+ ./spec/support/populate_consul.sh
47
+
48
+ - run:
49
+ name: run tests
50
+ command: |
51
+ mkdir /tmp/test-results
52
+
53
+ TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | \
54
+ circleci tests split --split-by=timings)"
55
+
56
+ bundle exec rspec \
57
+ --format progress \
58
+ --format RspecJunitFormatter \
59
+ --out /tmp/test-results/rspec.xml \
60
+ --format progress \
61
+ $TEST_FILES
62
+
63
+ - store_test_results:
64
+ path: /tmp/test-results
65
+
66
+ - store_artifacts:
67
+ path: ./coverage
68
+ destination: coverage
69
+
70
+ workflows:
71
+ test_supported_ruby_versions:
72
+ jobs:
73
+ - test:
74
+ matrix:
75
+ parameters:
76
+ ruby_version:
77
+ - '2.5'
78
+ - '2.7'
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ #### Unreleased
2
+
3
+ #### 0.10.0
4
+
5
+ * Switch from Travis to CircleCI, and set up testing for multiple Ruby versions ([#25](https://github.com/veracross/consult/pull/25) & [#34](https://github.com/veracross/consult/pull/34))
6
+ * Improve development on Windows ([#21](https://github.com/veracross/consult/pull/21))
7
+ * Normalize string encodings to UTF-8 ([#22](https://github.com/veracross/consult/pull/22))
8
+ * Remove dependency on ActiveSupport ([#27](https://github.com/veracross/consult/pull/27))
9
+
10
+ #### 0.9.0
11
+
12
+ * Add a CLI to render templates on demand ([#20](https://github.com/veracross/consult/pull/20))
13
+
1
14
  #### 0.8.2
2
15
 
3
16
  * Use `X-Consul-Token` header for Consul authentication. See the [Consul docs](https://www.consul.io/api/index.html#authentication) for details. ([#19](https://github.com/veracross/consult/pull/19))
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  Generate configuration and secrets for Rails apps automatically from [Consul](https://github.com/hashicorp/consul) & [Vault](https://github.com/hashicorp/vault).
4
4
 
5
5
  [![Gem Version](https://badge.fury.io/rb/consult.svg)](https://badge.fury.io/rb/consult)
6
- [![Build Status](https://travis-ci.org/veracross/consult.svg?branch=master)](https://travis-ci.org/veracross/consult)
6
+ [![CircleCI](https://circleci.com/gh/veracross/consult/tree/master.svg?style=svg)](https://circleci.com/gh/veracross/consult/tree/master)
7
7
  [![Maintainability](https://api.codeclimate.com/v1/badges/d7b048b7edd9f27c83b9/maintainability)](https://codeclimate.com/github/veracross/consult/maintainability)
8
8
 
9
9
  ## Background
@@ -14,8 +14,6 @@ We use Consul Template for server level configuration, but application level con
14
14
 
15
15
  With Consult the process is the same in all environments.
16
16
 
17
- This gem is considered _beta_. At Veracross, we are just beginning to use it in staging environments.
18
-
19
17
  ## Installation
20
18
 
21
19
  Add this line to your application's Gemfile:
@@ -299,7 +297,7 @@ production:
299
297
  Then reference secrets in your app with `Rails.application.secrets`.
300
298
 
301
299
  ```ruby
302
- # config/intiializers/rollbar.rb
300
+ # config/initializers/rollbar.rb
303
301
  Rollbar.configure do |config|
304
302
  config.access_token = Rails.application.secrets.rollbar_token
305
303
  end
data/bin/console CHANGED
File without changes
data/bin/consult CHANGED
File without changes
data/bin/setup CHANGED
File without changes
data/consult.gemspec CHANGED
@@ -24,15 +24,15 @@ Gem::Specification.new do |spec|
24
24
  spec.executables = ['consult']
25
25
  spec.require_paths = ['lib']
26
26
 
27
- spec.add_dependency 'activesupport', '> 4', '< 6'
28
27
  spec.add_dependency 'diplomat', '~> 2.0.2'
29
28
  spec.add_dependency 'vault', '>= 0.10.0', '< 1.0.0'
30
29
 
31
- spec.add_development_dependency 'bundler', '~> 1.16'
30
+ spec.add_development_dependency 'bundler'
32
31
  spec.add_development_dependency 'guard'
33
32
  spec.add_development_dependency 'guard-rspec'
34
33
  spec.add_development_dependency 'pry-byebug'
35
- spec.add_development_dependency 'rake', '~> 10.0'
34
+ spec.add_development_dependency 'rake'
36
35
  spec.add_development_dependency 'rspec', '~> 3.0'
37
- spec.add_development_dependency 'simplecov'
36
+ spec.add_development_dependency 'rspec_junit_formatter', '~> 0.4.1'
37
+ spec.add_development_dependency 'simplecov', '~> 0.16.1'
38
38
  end
data/lib/consult.rb CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  require 'pathname'
4
4
  require 'yaml'
5
- require 'active_support/core_ext/hash'
6
5
  require 'erb'
7
6
  require 'vault'
8
7
  require 'diplomat'
@@ -10,6 +9,7 @@ require 'diplomat'
10
9
  require 'consult/version'
11
10
  require 'consult/utilities'
12
11
  require 'consult/template'
12
+ require_relative './support/hash_extensions'
13
13
 
14
14
  module Consult
15
15
  @config = {}
@@ -24,8 +24,7 @@ module Consult
24
24
  root directory: config_dir
25
25
  yaml = root.join('config', 'consult.yml')
26
26
 
27
- @all_config = yaml.exist? ? YAML.safe_load(ERB.new(yaml.read).result, [], [], true).to_h : {}
28
- @all_config.deep_symbolize_keys!
27
+ @all_config = yaml.exist? ? YAML.safe_load(ERB.new(yaml.read).result, [], [], true, symbolize_names: true).to_h : {}
29
28
 
30
29
  @config = @all_config[:shared].to_h.deep_merge @all_config[env&.to_sym].to_h
31
30
  @templates = @config[:templates]&.map { |name, config| Template.new(name, config.merge(verbose: verbose)) } || []
@@ -45,7 +44,7 @@ module Consult
45
44
  @config[:consul][:url] = ENV['CONSUL_HTTP_ADDR'] || configured_address || @config[:consul][:url]
46
45
  # If a consul token exists, treat it as special
47
46
  # See https://github.com/WeAreFarmGeek/diplomat/pull/160
48
- (@config[:consul][:options] ||= {}).merge!(headers: {'X-Consul-Token' => consul_token}) if consul_token.present?
47
+ (@config[:consul][:options] ||= {}).merge!(headers: {'X-Consul-Token' => consul_token}) if consul_token.to_s.length > 0
49
48
 
50
49
  Diplomat.configure do |c|
51
50
  @config[:consul].each do |opt, val|
@@ -21,7 +21,7 @@ module Consult
21
21
  renderer = ERB.new(contents, nil, '-')
22
22
  result = renderer.result(binding)
23
23
 
24
- File.open(dest, 'w') { |f| f << result } if save
24
+ File.open(dest, 'wb') { |f| f << result } if save
25
25
  puts "Consult: Rendered #{name}" if verbose?
26
26
  result
27
27
  rescue StandardError => e
@@ -75,7 +75,7 @@ module Consult
75
75
 
76
76
  def consul_contents(location)
77
77
  [@config[location]].compact.flatten.map do |key|
78
- Diplomat::Kv.get(key, options: nil, not_found: :return, found: :return)
78
+ Diplomat::Kv.get(key, options: nil, not_found: :return, found: :return).force_encoding 'utf-8'
79
79
  end.join
80
80
  end
81
81
 
@@ -1,3 +1,3 @@
1
1
  module Consult
2
- VERSION = '0.9.0'
2
+ VERSION = '0.10.0.pre'
3
3
  end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ # ActiveSupport's corresponding methods
4
+ # - https://github.com/rails/rails/tree/master/activesupport/lib/active_support/core_ext/hash
5
+ module HashExtension
6
+ def deep_merge(other_hash, &block)
7
+ merge(other_hash) do |key, this_val, other_val|
8
+ if this_val.is_a?(Hash) && other_val.is_a?(Hash)
9
+ this_val.deep_merge other_val, &block
10
+ elsif block_given?
11
+ block.call key, this_val, other_val
12
+ else
13
+ other_val
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ Hash.send(:include, HashExtension)
metadata CHANGED
@@ -1,35 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: consult
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Fraser
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-02 00:00:00.000000000 Z
11
+ date: 2021-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: activesupport
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">"
18
- - !ruby/object:Gem::Version
19
- version: '4'
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '6'
23
- type: :runtime
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - ">"
28
- - !ruby/object:Gem::Version
29
- version: '4'
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '6'
33
13
  - !ruby/object:Gem::Dependency
34
14
  name: diplomat
35
15
  requirement: !ruby/object:Gem::Requirement
@@ -68,16 +48,16 @@ dependencies:
68
48
  name: bundler
69
49
  requirement: !ruby/object:Gem::Requirement
70
50
  requirements:
71
- - - "~>"
51
+ - - ">="
72
52
  - !ruby/object:Gem::Version
73
- version: '1.16'
53
+ version: '0'
74
54
  type: :development
75
55
  prerelease: false
76
56
  version_requirements: !ruby/object:Gem::Requirement
77
57
  requirements:
78
- - - "~>"
58
+ - - ">="
79
59
  - !ruby/object:Gem::Version
80
- version: '1.16'
60
+ version: '0'
81
61
  - !ruby/object:Gem::Dependency
82
62
  name: guard
83
63
  requirement: !ruby/object:Gem::Requirement
@@ -124,16 +104,16 @@ dependencies:
124
104
  name: rake
125
105
  requirement: !ruby/object:Gem::Requirement
126
106
  requirements:
127
- - - "~>"
107
+ - - ">="
128
108
  - !ruby/object:Gem::Version
129
- version: '10.0'
109
+ version: '0'
130
110
  type: :development
131
111
  prerelease: false
132
112
  version_requirements: !ruby/object:Gem::Requirement
133
113
  requirements:
134
- - - "~>"
114
+ - - ">="
135
115
  - !ruby/object:Gem::Version
136
- version: '10.0'
116
+ version: '0'
137
117
  - !ruby/object:Gem::Dependency
138
118
  name: rspec
139
119
  requirement: !ruby/object:Gem::Requirement
@@ -148,20 +128,34 @@ dependencies:
148
128
  - - "~>"
149
129
  - !ruby/object:Gem::Version
150
130
  version: '3.0'
131
+ - !ruby/object:Gem::Dependency
132
+ name: rspec_junit_formatter
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: 0.4.1
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
143
+ - !ruby/object:Gem::Version
144
+ version: 0.4.1
151
145
  - !ruby/object:Gem::Dependency
152
146
  name: simplecov
153
147
  requirement: !ruby/object:Gem::Requirement
154
148
  requirements:
155
- - - ">="
149
+ - - "~>"
156
150
  - !ruby/object:Gem::Version
157
- version: '0'
151
+ version: 0.16.1
158
152
  type: :development
159
153
  prerelease: false
160
154
  version_requirements: !ruby/object:Gem::Requirement
161
155
  requirements:
162
- - - ">="
156
+ - - "~>"
163
157
  - !ruby/object:Gem::Version
164
- version: '0'
158
+ version: 0.16.1
165
159
  description: Manage consul/vault backed template files in Ruby.
166
160
  email:
167
161
  - jeff.fraser@veracross.com
@@ -170,10 +164,11 @@ executables:
170
164
  extensions: []
171
165
  extra_rdoc_files: []
172
166
  files:
167
+ - ".circleci/config.yml"
173
168
  - ".gitignore"
174
169
  - ".rspec"
175
170
  - ".rubocop.yml"
176
- - ".travis.yml"
171
+ - ".ruby-version"
177
172
  - CHANGELOG.md
178
173
  - Gemfile
179
174
  - Guardfile
@@ -193,12 +188,13 @@ files:
193
188
  - lib/consult/template_functions.rb
194
189
  - lib/consult/utilities.rb
195
190
  - lib/consult/version.rb
191
+ - lib/support/hash_extensions.rb
196
192
  homepage: https://github.com/veracross/consult
197
193
  licenses:
198
194
  - MIT
199
195
  metadata:
200
196
  allowed_push_host: https://rubygems.org
201
- post_install_message:
197
+ post_install_message:
202
198
  rdoc_options: []
203
199
  require_paths:
204
200
  - lib
@@ -209,13 +205,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
209
205
  version: '0'
210
206
  required_rubygems_version: !ruby/object:Gem::Requirement
211
207
  requirements:
212
- - - ">="
208
+ - - ">"
213
209
  - !ruby/object:Gem::Version
214
- version: '0'
210
+ version: 1.3.1
215
211
  requirements: []
216
- rubyforge_project:
212
+ rubyforge_project:
217
213
  rubygems_version: 2.7.6
218
- signing_key:
214
+ signing_key:
219
215
  specification_version: 4
220
216
  summary: Manage consul/vault backed template files in Ruby.
221
217
  test_files: []
data/.travis.yml DELETED
@@ -1,15 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.5
5
- - 2.4
6
- - 2.3
7
-
8
- services:
9
- - docker
10
-
11
- before_install:
12
- - gem install bundler -v 1.16.2
13
- - docker-compose --version
14
- - docker-compose up -d
15
- - docker ps