consul_application_settings 0.1.0 → 0.1.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/.codeclimate.yml +3 -0
- data/.github/workflows/main.yml +79 -0
- data/CHANGELOG.md +9 -1
- data/Gemfile.lock +3 -3
- data/README.md +36 -14
- data/bin/rspec +4 -0
- data/lib/consul_application_settings/configuration.rb +1 -0
- data/lib/consul_application_settings/defaults.rb +1 -0
- data/lib/consul_application_settings/options.rb +7 -1
- data/lib/consul_application_settings/utils.rb +1 -1
- data/lib/consul_application_settings/version.rb +1 -1
- metadata +4 -3
- data/.travis.yml +0 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9af6fab64f896c6b73c82ed78561f870968460c4cdb41990cac1032030baf3fa
|
4
|
+
data.tar.gz: 2108b97a57db3a42008960887cf1c1e17962cd7a6f10bd694412d1836536d461
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cba0e8a105b7974e18d58e37daec38d830882c74fc3bc4e76e341cababc5497298d142c2a934bf826699b27af6b316aa6675974c35b04725a53716f4829c47b
|
7
|
+
data.tar.gz: fd68775e59908f91f947a4154413203cd98b278ab31807637fc504aff7a8499bbf4e2d94fa0feb1bf2cee8c9a6e70b6b4762c2b10f1283ca3dde7c14b22e1945
|
data/.codeclimate.yml
CHANGED
@@ -0,0 +1,79 @@
|
|
1
|
+
name: ci
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches:
|
5
|
+
- master
|
6
|
+
pull_request:
|
7
|
+
branches:
|
8
|
+
- master
|
9
|
+
release:
|
10
|
+
types: [published]
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
build:
|
14
|
+
runs-on: ubuntu-latest
|
15
|
+
strategy:
|
16
|
+
matrix:
|
17
|
+
ruby: [ '2.5.x', '2.6.x' ]
|
18
|
+
services:
|
19
|
+
redis:
|
20
|
+
image: consul:1.6
|
21
|
+
ports:
|
22
|
+
- '8500:8500'
|
23
|
+
steps:
|
24
|
+
- name: Checkout
|
25
|
+
uses: actions/checkout@v1
|
26
|
+
- name: Cache dependencies
|
27
|
+
uses: actions/cache@v1
|
28
|
+
with:
|
29
|
+
path: vendor/bundle
|
30
|
+
key: ${{ runner.OS }}-ruby-${{ matrix.ruby }}
|
31
|
+
restore-keys: ${{ runner.OS }}-
|
32
|
+
|
33
|
+
- name: Set up Ruby
|
34
|
+
uses: actions/setup-ruby@v1
|
35
|
+
with:
|
36
|
+
ruby-version: ${{ matrix.ruby }}
|
37
|
+
- name: Set up Bundler
|
38
|
+
run: gem install bundler:2.0.1
|
39
|
+
- name: Set up Dependencies
|
40
|
+
run: bundle install --path vendor/bundle
|
41
|
+
|
42
|
+
- name: Run Tests
|
43
|
+
uses: paambaati/codeclimate-action@v2.3.0
|
44
|
+
env:
|
45
|
+
COVERAGE: true
|
46
|
+
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
|
47
|
+
with:
|
48
|
+
coverageCommand: ./bin/rspec
|
49
|
+
|
50
|
+
release:
|
51
|
+
runs-on: ubuntu-latest
|
52
|
+
needs: build
|
53
|
+
if: github.event_name == 'release' && github.event.action == 'published'
|
54
|
+
steps:
|
55
|
+
- name: Checkout
|
56
|
+
uses: actions/checkout@v1
|
57
|
+
|
58
|
+
- name: Set up Ruby
|
59
|
+
uses: actions/setup-ruby@v1
|
60
|
+
with:
|
61
|
+
ruby-version: 2.6.x
|
62
|
+
- name: Set up Bundler
|
63
|
+
run: gem install bundler:2.0.1
|
64
|
+
- name: Set up credentials
|
65
|
+
run: |
|
66
|
+
mkdir -p $HOME/.gem
|
67
|
+
touch $HOME/.gem/credentials
|
68
|
+
chmod 0600 $HOME/.gem/credentials
|
69
|
+
printf -- "---\n:rubygems_api_key: ${{secrets.RUBYGEMS_AUTH_TOKEN}}\n" > $HOME/.gem/credentials
|
70
|
+
|
71
|
+
- name: Get version
|
72
|
+
run: echo "${GITHUB_REF/refs\/tags\//}" > release.tag
|
73
|
+
- name: Set version
|
74
|
+
run: sed -i "s/0.0.0/$(<release.tag)/g" */**/version.rb
|
75
|
+
|
76
|
+
- name: Build gem
|
77
|
+
run: gem build *.gemspec
|
78
|
+
- name: Push gem
|
79
|
+
run: gem push *.gem
|
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,19 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.1.1]
|
4
|
+
### New features
|
5
|
+
- Allow Operations without Consul
|
6
|
+
### Tech debt
|
7
|
+
- Replace CI to GitHub Actions
|
8
|
+
|
3
9
|
## [0.1.0]
|
10
|
+
### New features
|
4
11
|
- Gem init
|
5
12
|
- Reading settings from consul
|
6
13
|
- Reading settings from defaults
|
7
14
|
- Support deep settings search
|
8
15
|
- Support nested configs
|
9
16
|
|
10
|
-
[Unreleased]: https://github.com/matic-insurance/consul_application_settings/compare/0.1.
|
17
|
+
[Unreleased]: https://github.com/matic-insurance/consul_application_settings/compare/0.1.1...HEAD
|
18
|
+
[0.1.1]: https://github.com/matic-insurance/consul_application_settings/compare/0.1.0...0.1.1
|
11
19
|
[0.1.0]: https://github.com/matic-insurance/consul_application_settings/compare/cb7194f...0.1.0
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
consul_application_settings (0.
|
4
|
+
consul_application_settings (0.0.0)
|
5
5
|
diplomat (~> 2.1.3)
|
6
6
|
|
7
7
|
GEM
|
@@ -14,11 +14,11 @@ GEM
|
|
14
14
|
deep_merge (~> 1.0, >= 1.0.1)
|
15
15
|
faraday (~> 0.9)
|
16
16
|
docile (1.3.1)
|
17
|
-
faraday (0.
|
17
|
+
faraday (0.17.1)
|
18
18
|
multipart-post (>= 1.2, < 3)
|
19
19
|
jaro_winkler (1.5.2)
|
20
20
|
json (2.2.0)
|
21
|
-
multipart-post (2.
|
21
|
+
multipart-post (2.1.1)
|
22
22
|
parallel (1.16.2)
|
23
23
|
parser (2.6.2.0)
|
24
24
|
ast (~> 2.4.0)
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# ConsulApplicationSettings
|
2
2
|
|
3
|
-
|
3
|
+

|
4
4
|
[](https://codeclimate.com/github/matic-insurance/consul_application_settings/test_coverage)
|
5
5
|
[](https://codeclimate.com/github/matic-insurance/consul_application_settings/maintainability)
|
6
6
|
|
@@ -37,7 +37,7 @@ gem 'consul_application_settings'
|
|
37
37
|
|
38
38
|
### Initialization
|
39
39
|
|
40
|
-
At the load of application
|
40
|
+
At the load of application:
|
41
41
|
```ruby
|
42
42
|
ConsulApplicationSettings.configure do |config|
|
43
43
|
# Specify path to defaults file
|
@@ -57,23 +57,25 @@ APP_SETTINGS = ConsulApplicationSettings.load
|
|
57
57
|
|
58
58
|
Assuming your defaults file in repository `config/settings.yml` looks like:
|
59
59
|
```yaml
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
60
|
+
staging:
|
61
|
+
my_cool_app:
|
62
|
+
app_name: 'MyCoolApp'
|
63
|
+
hostname: 'http://localhost:3001'
|
64
|
+
|
65
|
+
integrations:
|
66
|
+
database:
|
67
|
+
domain: localhost
|
68
|
+
user: app
|
69
|
+
password: password1234
|
70
|
+
slack:
|
71
|
+
enabled: false
|
72
|
+
webhook_url: 'https://hooks.slack.com/services/XXXXXX/XXXXX/XXXXXXX'
|
71
73
|
```
|
72
74
|
|
73
75
|
And consul has following settings
|
74
76
|
```json
|
75
77
|
{
|
76
|
-
"
|
78
|
+
"staging": {
|
77
79
|
"my_cool_app": {
|
78
80
|
"hostname": "https://mycoolapp.com",
|
79
81
|
"integrations": {
|
@@ -123,6 +125,26 @@ slack_settings.enabled # true
|
|
123
125
|
slack_settings.get('webhook_url') # "https://hooks.slack.com/services/XXXXXX/XXXXX/XXXXXXX"
|
124
126
|
```
|
125
127
|
|
128
|
+
### Gem Configuration
|
129
|
+
You can configure gem with block:
|
130
|
+
```ruby
|
131
|
+
ConsulApplicationSettings.configure do |config|
|
132
|
+
config.namespace = 'staging/my_cool_app'
|
133
|
+
end
|
134
|
+
```
|
135
|
+
or one option at a time
|
136
|
+
```ruby
|
137
|
+
ConsulApplicationSettings.config.namespace = 'staging/my_cool_app'
|
138
|
+
```
|
139
|
+
|
140
|
+
All Gem configurations
|
141
|
+
|
142
|
+
| Configuration | Required | Default | Type | Description |
|
143
|
+
|----------------------------------|----------|---------|---------|------------------------------------------------------------------------------|
|
144
|
+
| defaults | yes | | String | Path to the file with default settings |
|
145
|
+
| namespace | no | | String | Base path to read settings from in consul and defaults |
|
146
|
+
| disable_consul_connection_errors | no | false | Boolean | Do not raise exception when consul is not available (useful for development) |
|
147
|
+
|
126
148
|
## Development
|
127
149
|
|
128
150
|
1. [Install Consul](https://www.consul.io/docs/install/index.html)
|
data/bin/rspec
ADDED
@@ -16,7 +16,7 @@ module ConsulApplicationSettings
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def get(name)
|
19
|
-
consul_value =
|
19
|
+
consul_value = key_value(name)
|
20
20
|
if consul_value.nil? || consul_value.empty?
|
21
21
|
defaults.get(name)
|
22
22
|
else
|
@@ -40,6 +40,12 @@ module ConsulApplicationSettings
|
|
40
40
|
|
41
41
|
private
|
42
42
|
|
43
|
+
def key_value(name)
|
44
|
+
Diplomat::Kv.get(key_path(name), {}, :return)
|
45
|
+
rescue Faraday::ConnectionFailed => e
|
46
|
+
raise e unless ConsulApplicationSettings.config.disable_consul_connection_errors
|
47
|
+
end
|
48
|
+
|
43
49
|
def key_path(name)
|
44
50
|
ConsulApplicationSettings::Utils.generate_path(path, name)
|
45
51
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: consul_application_settings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Volodymyr Mykhailyk
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: diplomat
|
@@ -118,11 +118,11 @@ extensions: []
|
|
118
118
|
extra_rdoc_files: []
|
119
119
|
files:
|
120
120
|
- ".codeclimate.yml"
|
121
|
+
- ".github/workflows/main.yml"
|
121
122
|
- ".gitignore"
|
122
123
|
- ".rspec"
|
123
124
|
- ".rubocop.yml"
|
124
125
|
- ".simplecov"
|
125
|
-
- ".travis.yml"
|
126
126
|
- CHANGELOG.md
|
127
127
|
- CODE_OF_CONDUCT.md
|
128
128
|
- Gemfile
|
@@ -131,6 +131,7 @@ files:
|
|
131
131
|
- README.md
|
132
132
|
- Rakefile
|
133
133
|
- bin/console
|
134
|
+
- bin/rspec
|
134
135
|
- bin/setup
|
135
136
|
- consul_application_settings.gemspec
|
136
137
|
- lib/consul_application_settings.rb
|
data/.travis.yml
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
---
|
2
|
-
sudo: false
|
3
|
-
language: ruby
|
4
|
-
cache: bundler
|
5
|
-
|
6
|
-
rvm:
|
7
|
-
- 2.5.1
|
8
|
-
|
9
|
-
env:
|
10
|
-
- CONSUL_VERSION=1.4.4
|
11
|
-
|
12
|
-
before_install:
|
13
|
-
# Install bundler 2.x
|
14
|
-
- gem update --system
|
15
|
-
- gem install bundler
|
16
|
-
# Install Code Climate
|
17
|
-
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
18
|
-
- chmod +x ./cc-test-reporter
|
19
|
-
- ./cc-test-reporter before-build
|
20
|
-
# Install consul
|
21
|
-
- curl -sLo consul.zip https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip
|
22
|
-
- unzip "consul.zip"
|
23
|
-
- ./consul --version
|
24
|
-
|
25
|
-
install:
|
26
|
-
- bin/setup
|
27
|
-
|
28
|
-
before_script:
|
29
|
-
# Run consul
|
30
|
-
- ./consul agent -dev -node travis &
|
31
|
-
|
32
|
-
script:
|
33
|
-
- COVERAGE=true bundle exec rspec
|
34
|
-
- gem build consul_application_settings
|
35
|
-
|
36
|
-
after_script:
|
37
|
-
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
38
|
-
|
39
|
-
deploy:
|
40
|
-
provider: rubygems
|
41
|
-
api_key: "$RUBY_GEMS_API_KEY"
|
42
|
-
on:
|
43
|
-
tags: true
|
44
|
-
|
45
|
-
branches:
|
46
|
-
only:
|
47
|
-
- master
|
48
|
-
- /^\d+\.\d+\.\d+$/
|