doppler-client 0.1.1 → 0.1.2

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
  SHA1:
3
- metadata.gz: 3d7f6b03743332da764917f49710df2b127cb344
4
- data.tar.gz: 29877f453214135f86556bed11be6991fe329ff6
3
+ metadata.gz: 9bb08eeff831da656b658d211696f8fc98b9c306
4
+ data.tar.gz: f80ffc0eee91e244d990bbc06bda63882ee46a4d
5
5
  SHA512:
6
- metadata.gz: 433a86772655ccfd58e78f3ba29d058c5a23c1671a242d2667dfd1a312cb87bed2a9876f5ab2c46912e564d4628b28794c3f2b5143dbbc4895dd270e0ac8f048
7
- data.tar.gz: 9a890472004451d05d85f8d20694cb0eac73839be203aecf92da59f66f3412b73bd46b2794714f25f124727196928366f6aea5d0771704f3a61ee640a7a71c9b
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 send all your local environment keys on `init`. This
94
- is done for 2 reasons. Collecting your local keys helps us automatically setup your pipelines
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
- If you would like the Doppler client to not send your keys we provide 2 ways to do it.
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
- send_local_keys = false # DEFAUTLS => True
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
- ### Individual Key
113
- You can also ignore specific local keys by adding them to the `ignore_keys` array.
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
- ignore_keys: [
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
  )
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = "doppler-client"
6
- spec.version = "0.1.1"
6
+ spec.version = "0.1.2"
7
7
  spec.authors = ["Doppler Team"]
8
8
  spec.email = "brian@doppler.market"
9
9
 
@@ -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, send_local_keys = true, ignore_keys = [])
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
- @send_local_keys = send_local_keys
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 not @ignore_keys.include?(key)
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
- if @remote_keys.key?(key_name)
65
- if priority == Priority.local
66
- return ENV[key_name] ? ENV[key_name] : @remote_keys[key_name]
67
- else
68
- return @remote_keys[key_name]
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
- _request('/missing_key', {
74
- 'key_name' => key_name
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 ENV[key_name]
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.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-04 00:00:00.000000000 Z
11
+ date: 2018-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler