config_server_agent 0.3.2 → 0.3.3
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/.rubocop.yml +2 -0
- data/CHANGELOG.md +4 -0
- data/CODE_OF_CONDUCT.md +1 -1
- data/README.md +4 -0
- data/Rakefile +6 -6
- data/config_server_agent.gemspec +21 -22
- data/lib/config_server_agent.rb +27 -11
- data/lib/config_server_agent/version.rb +1 -1
- metadata +11 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 344ef40b40e8878b43c97010628fdc601e7cf743486105211c3ccf04d4a06c08
|
4
|
+
data.tar.gz: 24fcc8fd7e0316ce8bada8f5e7b51f5726fc38ea6ea953f900b38bc5b510d4e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b1eb8afd72531182a10cdd6db766ba94373fc0480283496a4575509e76cc42345d3c79d55f88eee83ac94a9cad25a329812d4e651b2e6c76a2ac57c273a289b
|
7
|
+
data.tar.gz: abf76b59135ce2368366c0a817741b22f8876451b19d7800eba97178cd90e39496c2ad1ae9cfe854ff2e88782b4a3a4c29513870ebea9b7415c0f9b68a03d8c5
|
data/.rubocop.yml
ADDED
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## 0.3.3 - 2019-06-03
|
8
|
+
### Changed
|
9
|
+
- Added get_selected_config helper method
|
10
|
+
|
7
11
|
## 0.3.2 - 2019-02-27
|
8
12
|
### Changed
|
9
13
|
- Added bundler-audit to CI/CD pipeline
|
data/CODE_OF_CONDUCT.md
CHANGED
@@ -23,7 +23,7 @@ include:
|
|
23
23
|
Examples of unacceptable behavior by participants include:
|
24
24
|
|
25
25
|
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
-
advances
|
26
|
+
advances
|
27
27
|
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
28
|
* Public or private harassment
|
29
29
|
* Publishing others' private information, such as a physical or electronic
|
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rake/testtask'
|
3
3
|
|
4
4
|
Rake::TestTask.new(:test) do |t|
|
5
|
-
t.libs <<
|
6
|
-
t.libs <<
|
7
|
-
t.test_files = FileList[
|
5
|
+
t.libs << 'test'
|
6
|
+
t.libs << 'lib'
|
7
|
+
t.test_files = FileList['test/**/*_test.rb']
|
8
8
|
end
|
9
9
|
|
10
10
|
task :default => :test
|
11
11
|
|
12
|
-
desc
|
12
|
+
desc 'Run an interactive Pry console'
|
13
13
|
task :console do
|
14
14
|
exec 'pry -I ./lib -r config_server_agent'
|
15
15
|
end
|
data/config_server_agent.gemspec
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
|
2
|
-
lib = File.expand_path(
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
4
|
+
require 'config_server_agent/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'config_server_agent'
|
8
8
|
spec.version = ConfigServerAgent::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['Aidan Samuel']
|
10
|
+
spec.email = ['aidan.samuel@supporterhub.com']
|
11
11
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
12
|
+
spec.summary = 'A thread-safe caching client for Config Server'
|
13
|
+
spec.description = <<~EOM
|
14
14
|
Use this client to retrieve your configuration from a Config Server.
|
15
15
|
The required parameters can either be supplied to the constructor, or
|
16
16
|
they will be pulled from environment variables. An ArgumentError will
|
@@ -18,20 +18,19 @@ Gem::Specification.new do |spec|
|
|
18
18
|
Parameters supplied to the constructor will take precedence over environment
|
19
19
|
variables.
|
20
20
|
EOM
|
21
|
-
spec.homepage =
|
22
|
-
spec.license =
|
21
|
+
spec.homepage = 'https://bitbucket.org/supporterhub/'
|
22
|
+
spec.license = 'MIT'
|
23
23
|
|
24
24
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
25
25
|
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
26
26
|
if spec.respond_to?(:metadata)
|
27
|
-
spec.metadata[
|
27
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
28
28
|
|
29
|
-
spec.metadata[
|
30
|
-
spec.metadata[
|
31
|
-
spec.metadata[
|
29
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
30
|
+
spec.metadata['source_code_uri'] = 'https://bitbucket.org/supporterhub/config_server_agent'
|
31
|
+
spec.metadata['changelog_uri'] = 'https://bitbucket.org/supporterhub/config_server_agent/src/master/CHANGELOG.md'
|
32
32
|
else
|
33
|
-
raise
|
34
|
-
"public gem pushes."
|
33
|
+
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
|
35
34
|
end
|
36
35
|
|
37
36
|
# Specify which files should be added to the gem when it is released.
|
@@ -41,14 +40,14 @@ Gem::Specification.new do |spec|
|
|
41
40
|
end
|
42
41
|
# spec.bindir = "exe"
|
43
42
|
# spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
44
|
-
spec.require_paths = [
|
43
|
+
spec.require_paths = ['lib']
|
45
44
|
|
46
45
|
spec.required_ruby_version = '>= 2.3.0'
|
47
46
|
|
48
|
-
spec.add_development_dependency
|
49
|
-
spec.add_development_dependency
|
50
|
-
spec.add_development_dependency
|
51
|
-
spec.add_development_dependency
|
52
|
-
spec.add_development_dependency
|
53
|
-
spec.add_development_dependency
|
47
|
+
spec.add_development_dependency 'bundler', '~> 1.17'
|
48
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
49
|
+
spec.add_development_dependency 'minitest', '~> 5.0'
|
50
|
+
spec.add_development_dependency 'pry', '~> 0.10'
|
51
|
+
spec.add_development_dependency 'webmock', '~> 2.0'
|
52
|
+
spec.add_development_dependency 'bundler-audit', '~> 0.6'
|
54
53
|
end
|
data/lib/config_server_agent.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require 'config_server_agent/version'
|
4
|
+
require 'net/http'
|
5
|
+
require 'json'
|
6
6
|
|
7
7
|
class ConfigServerAgent
|
8
8
|
class Error < StandardError; end
|
@@ -18,12 +18,12 @@ class ConfigServerAgent
|
|
18
18
|
user_agent_comment: nil,
|
19
19
|
token_ttl: 60 * 60 * 24
|
20
20
|
)
|
21
|
-
@auth0_client_id = auth0_client_id or raise ArgumentError,
|
22
|
-
@auth0_client_secret = auth0_client_secret or raise ArgumentError,
|
23
|
-
@auth0_host = auth0_host or raise ArgumentError,
|
24
|
-
@config_server_audience = config_server_audience or raise ArgumentError,
|
25
|
-
@config_server_api_key = config_server_api_key or raise ArgumentError,
|
26
|
-
@config_server_host = config_server_host or raise ArgumentError,
|
21
|
+
@auth0_client_id = auth0_client_id or raise ArgumentError, 'Missing auth0_client_id parameter'
|
22
|
+
@auth0_client_secret = auth0_client_secret or raise ArgumentError, 'Missing auth0_client_secret parameter'
|
23
|
+
@auth0_host = auth0_host or raise ArgumentError, 'Missing auth0_host parameter'
|
24
|
+
@config_server_audience = config_server_audience or raise ArgumentError, 'Missing config_server_audience parameter'
|
25
|
+
@config_server_api_key = config_server_api_key or raise ArgumentError, 'Missing config_server_api_key parameter'
|
26
|
+
@config_server_host = config_server_host or raise ArgumentError, 'Missing config_server_host parameter'
|
27
27
|
|
28
28
|
@config = nil
|
29
29
|
@mutex = Mutex.new
|
@@ -42,8 +42,25 @@ class ConfigServerAgent
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
+
def get_selected_config(area, item=nil, **options)
|
46
|
+
|
47
|
+
if options[:ignore_cache]
|
48
|
+
@config = nil
|
49
|
+
end
|
50
|
+
|
51
|
+
data = get_config.group_by { |x| x['area'] }
|
52
|
+
|
53
|
+
raise Error, "Area is missing: #{area}" unless data.key? area
|
54
|
+
|
55
|
+
if item
|
56
|
+
data.fetch(area, []).find { |row_item| break row_item["value"] if row_item["name"] == item }
|
57
|
+
else
|
58
|
+
data.fetch(area, [])
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
45
62
|
def set_config(values)
|
46
|
-
raise Error,
|
63
|
+
raise Error, 'values not found' if values.empty?
|
47
64
|
post_request('set_values', values)
|
48
65
|
end
|
49
66
|
|
@@ -114,7 +131,6 @@ class ConfigServerAgent
|
|
114
131
|
|
115
132
|
rescue JSON::ParserError
|
116
133
|
raise Error, "Invalid response from #{@auth0_host}"
|
117
|
-
|
118
134
|
end
|
119
135
|
|
120
136
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: config_server_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aidan Samuel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,11 +94,13 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0.6'
|
97
|
-
description:
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
97
|
+
description: |
|
98
|
+
Use this client to retrieve your configuration from a Config Server.
|
99
|
+
The required parameters can either be supplied to the constructor, or
|
100
|
+
they will be pulled from environment variables. An ArgumentError will
|
101
|
+
be raised if the parameters are not available from either source.
|
102
|
+
Parameters supplied to the constructor will take precedence over environment
|
103
|
+
variables.
|
102
104
|
email:
|
103
105
|
- aidan.samuel@supporterhub.com
|
104
106
|
executables: []
|
@@ -106,6 +108,7 @@ extensions: []
|
|
106
108
|
extra_rdoc_files: []
|
107
109
|
files:
|
108
110
|
- ".gitignore"
|
111
|
+
- ".rubocop.yml"
|
109
112
|
- ".travis.yml"
|
110
113
|
- CHANGELOG.md
|
111
114
|
- CODE_OF_CONDUCT.md
|
@@ -140,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
143
|
- !ruby/object:Gem::Version
|
141
144
|
version: '0'
|
142
145
|
requirements: []
|
143
|
-
rubygems_version: 3.0.
|
146
|
+
rubygems_version: 3.0.3
|
144
147
|
signing_key:
|
145
148
|
specification_version: 4
|
146
149
|
summary: A thread-safe caching client for Config Server
|