doppler-client 0.1.1 → 0.1.2
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/README.md +20 -13
- data/doppler-client.gemspec +1 -1
- data/lib/doppler/client.rb +27 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9bb08eeff831da656b658d211696f8fc98b9c306
|
4
|
+
data.tar.gz: f80ffc0eee91e244d990bbc06bda63882ee46a4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7127af99279f088c652c1e90e4b1644c78a02d140729c0e52b4210e5bf4b4776e4c35f71635006899fd78a02ec471825497930862170b1f5d1c255006bfb79e2
|
7
|
+
data.tar.gz: 0d8c635f4911b7f92edf01b1754c200a60effe17665fe00e5a8ef5828f02b950822afd06bc891395120409186c94c169f8f27c67d41b461a4fb78c864929a55d
|
data/README.md
CHANGED
@@ -81,7 +81,7 @@ You can also set the priority globally on initialization:
|
|
81
81
|
doppler = Doppler::Client.new(
|
82
82
|
api_key = ENV["API_KEY"],
|
83
83
|
pipeline = ENV["PIPELINE_ID"],
|
84
|
-
environment = ENV["ENVIRONMENT_NAME"]
|
84
|
+
environment = ENV["ENVIRONMENT_NAME"],
|
85
85
|
priority = Doppler::Priority.local
|
86
86
|
)
|
87
87
|
|
@@ -90,32 +90,39 @@ doppler = Doppler::Client.new(
|
|
90
90
|
|
91
91
|
## Local Key Privacy
|
92
92
|
|
93
|
-
By default the Doppler client will
|
94
|
-
|
93
|
+
By default the Doppler client will only track the local environment keys that are used during `doppler.get()`.
|
94
|
+
Collecting only those local keys helps us automatically setup your pipelines
|
95
95
|
for immediate use. After setup we also use your keys to detect when your keys locally have
|
96
96
|
changed from what is on Doppler. We then provide a way for you to adopt or reject those changes
|
97
97
|
through our dashboard. This can help help when debugging silent bugs or build failures.
|
98
98
|
|
99
|
-
|
100
|
-
|
101
|
-
### Globally
|
102
|
-
To ensure all your local keys are not sent to Doppler, set the `send_local_keys` attribute to `false`.
|
99
|
+
### Track Additional Keys
|
100
|
+
The Doppler client can also track additional keys by providing an array of keys to the `track_keys` field.
|
103
101
|
|
104
102
|
``` ruby
|
105
103
|
doppler = Doppler::Client.new(
|
106
|
-
|
107
|
-
|
104
|
+
api_key = ENV["API_KEY"],
|
105
|
+
pipeline = ENV["PIPELINE_ID"],
|
106
|
+
environment = ENV["ENVIRONMENT_NAME"],
|
107
|
+
priority = Doppler::Priority.local,
|
108
|
+
track_keys = [
|
109
|
+
"KEY_TO_TRACK"
|
110
|
+
]
|
108
111
|
)
|
109
112
|
```
|
110
113
|
|
111
114
|
|
112
|
-
###
|
113
|
-
|
115
|
+
### Ignoring Specific Keys
|
116
|
+
Inversely, you can also ignore specific local keys by adding them to the `ignore_keys` array.
|
114
117
|
|
115
118
|
``` ruby
|
116
119
|
doppler = Doppler::Client.new(
|
117
|
-
|
118
|
-
|
120
|
+
api_key = ENV["API_KEY"],
|
121
|
+
pipeline = ENV["PIPELINE_ID"],
|
122
|
+
environment = ENV["ENVIRONMENT_NAME"],
|
123
|
+
priority = Doppler::Priority.local,
|
124
|
+
track_keys = [],
|
125
|
+
ignore_keys = [
|
119
126
|
"SUPER_SECRET_KEY"
|
120
127
|
]
|
121
128
|
)
|
data/doppler-client.gemspec
CHANGED
data/lib/doppler/client.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require "doppler/client/version"
|
2
1
|
require 'net/https'
|
3
2
|
require 'json'
|
4
3
|
require 'set'
|
@@ -22,17 +21,19 @@ module Doppler
|
|
22
21
|
@@environ_segment = '/environments/'
|
23
22
|
@@max_retries = 0
|
24
23
|
|
25
|
-
def initialize(api_key, pipeline, environment, priority = Priority.remote,
|
24
|
+
def initialize(api_key, pipeline, environment, priority = Priority.remote, track_keys = [], ignore_keys = [])
|
26
25
|
raise ArgumentError, 'api_key not string' unless api_key.is_a? String
|
27
26
|
raise ArgumentError, 'pipeline not string' unless pipeline.is_a? String
|
28
27
|
raise ArgumentError, 'api_key not string' unless environment.is_a? String
|
29
28
|
raise ArgumentError, 'priority not numeric' unless priority.is_a? Numeric
|
29
|
+
raise ArgumentError, 'track_keys not array' unless track_keys.is_a? Array
|
30
|
+
raise ArgumentError, 'ignore_keys not array' unless ignore_keys.is_a? Array
|
30
31
|
|
31
32
|
@api_key = api_key
|
32
33
|
@pipeline = pipeline
|
33
34
|
@environment = environment
|
34
35
|
@default_priority = priority
|
35
|
-
@
|
36
|
+
@track_keys = track_keys.to_set
|
36
37
|
@ignore_keys = ignore_keys.to_set
|
37
38
|
@host = ENV[@@host_key] ? ENV[@@host_key] : @@default_host
|
38
39
|
|
@@ -45,7 +46,7 @@ module Doppler
|
|
45
46
|
|
46
47
|
if @send_local_keys
|
47
48
|
local_keys.each do |key, value|
|
48
|
-
if
|
49
|
+
if @track_keys.include?(key)
|
49
50
|
keys_to_send[key] = value
|
50
51
|
end
|
51
52
|
end
|
@@ -60,22 +61,33 @@ module Doppler
|
|
60
61
|
|
61
62
|
def get(key_name, priority = nil)
|
62
63
|
priority = priority != nil ? priority : @default_priority
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
end
|
64
|
+
value = nil
|
65
|
+
|
66
|
+
if priority == Priority.local
|
67
|
+
value = ENV[key_name] ? ENV[key_name] : @remote_keys[key_name]
|
68
|
+
else
|
69
|
+
value = @remote_keys[key_name] ? @remote_keys[key_name] : ENV[key_name]
|
70
70
|
end
|
71
71
|
|
72
72
|
if not @ignore_keys.include?(key_name)
|
73
|
-
|
74
|
-
|
75
|
-
|
73
|
+
if value != nil
|
74
|
+
if ENV[key_name] != @remote_keys[key_name]
|
75
|
+
local_keys = {}
|
76
|
+
local_keys[key_name] = ENV[key_name]
|
77
|
+
|
78
|
+
_request('/track_key', {
|
79
|
+
'local_keys' => local_keys
|
80
|
+
})
|
81
|
+
end
|
82
|
+
else
|
83
|
+
_request('/missing_key', {
|
84
|
+
'key_name' => key_name
|
85
|
+
})
|
86
|
+
|
87
|
+
end
|
76
88
|
end
|
77
89
|
|
78
|
-
return
|
90
|
+
return value
|
79
91
|
end
|
80
92
|
|
81
93
|
def _request(endpoint, body, retry_count=0)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doppler-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Doppler Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|