flipper-cloud 0.22.0 → 0.23.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 69bb21ad2d5ae7944825472e2d16fead9a99e3136331f2b9ad1b3a58a84d0340
4
- data.tar.gz: 7b049a433a94cb80aa8077507837b449bca2fef71d05153a6ea45a6959cbaded
3
+ metadata.gz: bdc9bab38dc9eda1a623130fc95ef4ea352b3acaaf83f8c36cdc013c8a5bc3c4
4
+ data.tar.gz: cea3e86dd52a6c74fbd01e93782456f42b5058631b377c58f7d7610b22d81cb3
5
5
  SHA512:
6
- metadata.gz: 050d427a9fcbe50168de8b46c822249bb71a843e55e24720ccbb7a13e075c0ebff0f8592a9cfa59e6fbbdcb2877afd21336c4f863f297e4ec41b0d7b71753027
7
- data.tar.gz: 3d671ce575cd6f50fe456cd372faa81de5cbe6ca39a397403d1801e8adb7e4b2fa1b035df69028144c8e22a77b04b0d232e34530e8068225f779a918b1516b51
6
+ metadata.gz: 6c5a1104978d3f190687d4374c44a1887953b2955c803eecb995d597662420d2b4edb5d4d5bcb420c444167669c709b8718d7966916034dcee1ddca408b6d6b3
7
+ data.tar.gz: 3e195dd488dcd230d0dd8f19162b05cac2b663f893b1f3509ffc681557ee3cd79e019d499d78295227d3603899e575daaad2a94c5878de2291ccac60dabcad45
@@ -1,5 +1,7 @@
1
1
  # Usage (from the repo root):
2
2
  # env FLIPPER_CLOUD_TOKEN=<token> bundle exec ruby examples/cloud/basic.rb
3
+
4
+ require_relative "./cloud_setup"
3
5
  require 'bundler/setup'
4
6
  require 'flipper/cloud'
5
7
 
@@ -0,0 +1,4 @@
1
+ if ENV["FLIPPER_CLOUD_TOKEN"].nil? || ENV["FLIPPER_CLOUD_TOKEN"].empty?
2
+ warn "FLIPPER_CLOUD_TOKEN missing so skipping cloud example."
3
+ exit
4
+ end
@@ -1,5 +1,7 @@
1
1
  # Usage (from the repo root):
2
2
  # env FLIPPER_CLOUD_TOKEN=<token> bundle exec ruby examples/cloud/import.rb
3
+
4
+ require_relative "./cloud_setup"
3
5
  require 'bundler/setup'
4
6
  require 'flipper'
5
7
  require 'flipper/cloud'
@@ -151,15 +151,11 @@ module Flipper
151
151
  debug_output: @debug_output,
152
152
  headers: {
153
153
  "Flipper-Cloud-Token" => @token,
154
- "Feature-Flipper-Token" => @token,
155
- "Client-Lang" => "ruby",
156
- "Client-Lang-Version" => "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})",
157
- "Client-Platform" => RUBY_PLATFORM,
158
- "Client-Engine" => defined?(RUBY_ENGINE) ? RUBY_ENGINE : "",
159
- "Client-Hostname" => Socket.gethostname,
160
154
  },
161
155
  })
162
156
  end
163
157
  end
164
158
  end
165
159
  end
160
+
161
+ # "FLIPPER_TIMESTAMP".freeze => Flipper::Timestamp.generate.to_s,
@@ -1,3 +1,3 @@
1
1
  module Flipper
2
- VERSION = '0.22.0'.freeze
2
+ VERSION = '0.23.1'.freeze
3
3
  end
@@ -1,4 +1,3 @@
1
- require 'helper'
2
1
  require 'flipper/cloud/configuration'
3
2
  require 'flipper/adapters/instrumented'
4
3
 
@@ -13,10 +12,9 @@ RSpec.describe Flipper::Cloud::Configuration do
13
12
  end
14
13
 
15
14
  it "can set token from ENV var" do
16
- with_modified_env "FLIPPER_CLOUD_TOKEN" => "from_env" do
17
- instance = described_class.new(required_options.reject { |k, v| k == :token })
18
- expect(instance.token).to eq("from_env")
19
- end
15
+ ENV["FLIPPER_CLOUD_TOKEN"] = "from_env"
16
+ instance = described_class.new(required_options.reject { |k, v| k == :token })
17
+ expect(instance.token).to eq("from_env")
20
18
  end
21
19
 
22
20
  it "can set instrumenter" do
@@ -31,10 +29,9 @@ RSpec.describe Flipper::Cloud::Configuration do
31
29
  end
32
30
 
33
31
  it "can set read_timeout from ENV var" do
34
- with_modified_env "FLIPPER_CLOUD_READ_TIMEOUT" => "9" do
35
- instance = described_class.new(required_options.reject { |k, v| k == :read_timeout })
36
- expect(instance.read_timeout).to eq(9)
37
- end
32
+ ENV["FLIPPER_CLOUD_READ_TIMEOUT"] = "9"
33
+ instance = described_class.new(required_options.reject { |k, v| k == :read_timeout })
34
+ expect(instance.read_timeout).to eq(9)
38
35
  end
39
36
 
40
37
  it "can set open_timeout" do
@@ -43,10 +40,9 @@ RSpec.describe Flipper::Cloud::Configuration do
43
40
  end
44
41
 
45
42
  it "can set open_timeout from ENV var" do
46
- with_modified_env "FLIPPER_CLOUD_OPEN_TIMEOUT" => "9" do
47
- instance = described_class.new(required_options.reject { |k, v| k == :open_timeout })
48
- expect(instance.open_timeout).to eq(9)
49
- end
43
+ ENV["FLIPPER_CLOUD_OPEN_TIMEOUT"] = "9"
44
+ instance = described_class.new(required_options.reject { |k, v| k == :open_timeout })
45
+ expect(instance.open_timeout).to eq(9)
50
46
  end
51
47
 
52
48
  it "can set write_timeout" do
@@ -55,10 +51,9 @@ RSpec.describe Flipper::Cloud::Configuration do
55
51
  end
56
52
 
57
53
  it "can set write_timeout from ENV var" do
58
- with_modified_env "FLIPPER_CLOUD_WRITE_TIMEOUT" => "9" do
59
- instance = described_class.new(required_options.reject { |k, v| k == :write_timeout })
60
- expect(instance.write_timeout).to eq(9)
61
- end
54
+ ENV["FLIPPER_CLOUD_WRITE_TIMEOUT"] = "9"
55
+ instance = described_class.new(required_options.reject { |k, v| k == :write_timeout })
56
+ expect(instance.write_timeout).to eq(9)
62
57
  end
63
58
 
64
59
  it "can set sync_interval" do
@@ -67,10 +62,9 @@ RSpec.describe Flipper::Cloud::Configuration do
67
62
  end
68
63
 
69
64
  it "can set sync_interval from ENV var" do
70
- with_modified_env "FLIPPER_CLOUD_SYNC_INTERVAL" => "5" do
71
- instance = described_class.new(required_options.reject { |k, v| k == :sync_interval })
72
- expect(instance.sync_interval).to eq(5)
73
- end
65
+ ENV["FLIPPER_CLOUD_SYNC_INTERVAL"] = "5"
66
+ instance = described_class.new(required_options.reject { |k, v| k == :sync_interval })
67
+ expect(instance.sync_interval).to eq(5)
74
68
  end
75
69
 
76
70
  it "passes sync_interval into sync adapter" do
@@ -121,10 +115,9 @@ RSpec.describe Flipper::Cloud::Configuration do
121
115
  end
122
116
 
123
117
  it "can override URL using ENV var" do
124
- with_modified_env "FLIPPER_CLOUD_URL" => "https://example.com" do
125
- instance = described_class.new(required_options.reject { |k, v| k == :url })
126
- expect(instance.url).to eq("https://example.com")
127
- end
118
+ ENV["FLIPPER_CLOUD_URL"] = "https://example.com"
119
+ instance = described_class.new(required_options.reject { |k, v| k == :url })
120
+ expect(instance.url).to eq("https://example.com")
128
121
  end
129
122
 
130
123
  it "defaults sync_method to :poll" do
@@ -143,12 +136,11 @@ RSpec.describe Flipper::Cloud::Configuration do
143
136
  end
144
137
 
145
138
  it "sets sync_method to :webhook if FLIPPER_CLOUD_SYNC_SECRET set" do
146
- with_modified_env "FLIPPER_CLOUD_SYNC_SECRET" => "abc" do
147
- instance = described_class.new(required_options)
139
+ ENV["FLIPPER_CLOUD_SYNC_SECRET"] = "abc"
140
+ instance = described_class.new(required_options)
148
141
 
149
- expect(instance.sync_method).to eq(:webhook)
150
- expect(instance.adapter).to be_instance_of(Flipper::Adapters::DualWrite)
151
- end
142
+ expect(instance.sync_method).to eq(:webhook)
143
+ expect(instance.adapter).to be_instance_of(Flipper::Adapters::DualWrite)
152
144
  end
153
145
 
154
146
  it "can set sync_secret" do
@@ -157,10 +149,9 @@ RSpec.describe Flipper::Cloud::Configuration do
157
149
  end
158
150
 
159
151
  it "can override sync_secret using ENV var" do
160
- with_modified_env "FLIPPER_CLOUD_SYNC_SECRET" => "from_env" do
161
- instance = described_class.new(required_options.reject { |k, v| k == :sync_secret })
162
- expect(instance.sync_secret).to eq("from_env")
163
- end
152
+ ENV["FLIPPER_CLOUD_SYNC_SECRET"] = "from_env"
153
+ instance = described_class.new(required_options.reject { |k, v| k == :sync_secret })
154
+ expect(instance.sync_secret).to eq("from_env")
164
155
  end
165
156
 
166
157
  it "can sync with cloud" do
@@ -1,4 +1,3 @@
1
- require 'helper'
2
1
  require 'flipper/cloud/configuration'
3
2
  require 'flipper/cloud/dsl'
4
3
  require 'flipper/adapters/operation_logger'
@@ -1,4 +1,3 @@
1
- require 'helper'
2
1
  require 'rails'
3
2
  require 'flipper/cloud'
4
3
 
@@ -19,6 +18,8 @@ RSpec.describe Flipper::Cloud::Engine do
19
18
 
20
19
  before do
21
20
  Rails.application = nil
21
+ ActiveSupport::Dependencies.autoload_paths = ActiveSupport::Dependencies.autoload_paths.dup
22
+ ActiveSupport::Dependencies.autoload_once_paths = ActiveSupport::Dependencies.autoload_once_paths.dup
22
23
 
23
24
  # Force loading of flipper to configure itself
24
25
  load 'flipper/cloud.rb'
@@ -27,12 +28,11 @@ RSpec.describe Flipper::Cloud::Engine do
27
28
  it "initializes cloud configuration" do
28
29
  stub_request(:get, /flippercloud\.io/).to_return(status: 200, body: "{}")
29
30
 
30
- with_modified_env env do
31
- application.initialize!
31
+ ENV.update(env)
32
+ application.initialize!
32
33
 
33
- expect(Flipper.instance).to be_a(Flipper::Cloud::DSL)
34
- expect(Flipper.instance.instrumenter).to be(ActiveSupport::Notifications)
35
- end
34
+ expect(Flipper.instance).to be_a(Flipper::Cloud::DSL)
35
+ expect(Flipper.instance.instrumenter).to be(ActiveSupport::Notifications)
36
36
  end
37
37
 
38
38
  context "with CLOUD_SYNC_SECRET" do
@@ -57,42 +57,39 @@ RSpec.describe Flipper::Cloud::Engine do
57
57
  }
58
58
 
59
59
  it "configures webhook app" do
60
- with_modified_env env do
61
- application.initialize!
60
+ ENV.update(env)
61
+ application.initialize!
62
62
 
63
- stub = stub_request(:get, "https://www.flippercloud.io/adapter/features").with({
64
- headers: { "Flipper-Cloud-Token" => ENV["FLIPPER_CLOUD_TOKEN"] },
65
- }).to_return(status: 200, body: JSON.generate({ features: {} }), headers: {})
63
+ stub = stub_request(:get, "https://www.flippercloud.io/adapter/features").with({
64
+ headers: { "Flipper-Cloud-Token" => ENV["FLIPPER_CLOUD_TOKEN"] },
65
+ }).to_return(status: 200, body: JSON.generate({ features: {} }), headers: {})
66
66
 
67
- post "/_flipper", request_body, { "HTTP_FLIPPER_CLOUD_SIGNATURE" => signature_header_value }
67
+ post "/_flipper", request_body, { "HTTP_FLIPPER_CLOUD_SIGNATURE" => signature_header_value }
68
68
 
69
- expect(last_response.status).to eq(200)
70
- expect(stub).to have_been_requested
71
- end
69
+ expect(last_response.status).to eq(200)
70
+ expect(stub).to have_been_requested
72
71
  end
73
72
  end
74
73
 
75
74
  context "without CLOUD_SYNC_SECRET" do
76
75
  it "does not configure webhook app" do
77
- with_modified_env env do
78
- application.initialize!
76
+ ENV.update(env)
77
+ application.initialize!
79
78
 
80
- post "/_flipper"
81
- expect(last_response.status).to eq(404)
82
- end
79
+ post "/_flipper"
80
+ expect(last_response.status).to eq(404)
83
81
  end
84
82
  end
85
83
 
86
84
  context "without FLIPPER_CLOUD_TOKEN" do
87
85
  it "gracefully skips configuring webhook app" do
88
- with_modified_env "FLIPPER_CLOUD_TOKEN" => nil do
89
- application.initialize!
90
- expect(silence { Flipper.instance }).to match(/Missing FLIPPER_CLOUD_TOKEN/)
91
- expect(Flipper.instance).to be_a(Flipper::DSL)
92
-
93
- post "/_flipper"
94
- expect(last_response.status).to eq(404)
95
- end
86
+ ENV["FLIPPER_CLOUD_TOKEN"] = nil
87
+ application.initialize!
88
+ expect(silence { Flipper.instance }).to match(/Missing FLIPPER_CLOUD_TOKEN/)
89
+ expect(Flipper.instance).to be_a(Flipper::DSL)
90
+
91
+ post "/_flipper"
92
+ expect(last_response.status).to eq(404)
96
93
  end
97
94
  end
98
95
  end
@@ -1,4 +1,3 @@
1
- require 'helper'
2
1
  require 'flipper/cloud/message_verifier'
3
2
 
4
3
  RSpec.describe Flipper::Cloud::MessageVerifier do
@@ -1,5 +1,4 @@
1
1
  require 'securerandom'
2
- require 'helper'
3
2
  require 'flipper/cloud'
4
3
  require 'flipper/cloud/middleware'
5
4
  require 'flipper/adapters/operation_logger'
@@ -1,4 +1,3 @@
1
- require 'helper'
2
1
  require 'flipper/cloud'
3
2
  require 'flipper/adapters/instrumented'
4
3
  require 'flipper/instrumenters/memory'
@@ -68,9 +67,8 @@ RSpec.describe Flipper::Cloud do
68
67
  end
69
68
 
70
69
  it 'can initialize with no token explicitly provided' do
71
- with_modified_env "FLIPPER_CLOUD_TOKEN" => "asdf" do
72
- expect(described_class.new).to be_instance_of(Flipper::Cloud::DSL)
73
- end
70
+ ENV['FLIPPER_CLOUD_TOKEN'] = 'asdf'
71
+ expect(described_class.new).to be_instance_of(Flipper::Cloud::DSL)
74
72
  end
75
73
 
76
74
  it 'can set instrumenter' do
@@ -117,10 +115,7 @@ RSpec.describe Flipper::Cloud do
117
115
 
118
116
  it 'can import' do
119
117
  stub_request(:post, /www\.flippercloud\.io\/adapter\/features.*/).
120
- with(headers: {
121
- 'Feature-Flipper-Token'=>'asdf',
122
- 'Flipper-Cloud-Token'=>'asdf',
123
- }).to_return(status: 200, body: "{}", headers: {})
118
+ with(headers: {'Flipper-Cloud-Token'=>'asdf'}).to_return(status: 200, body: "{}", headers: {})
124
119
 
125
120
  flipper = Flipper.new(Flipper::Adapters::Memory.new)
126
121
 
@@ -146,10 +141,7 @@ RSpec.describe Flipper::Cloud do
146
141
 
147
142
  it 'raises error for failure while importing' do
148
143
  stub_request(:post, /www\.flippercloud\.io\/adapter\/features.*/).
149
- with(headers: {
150
- 'Feature-Flipper-Token'=>'asdf',
151
- 'Flipper-Cloud-Token'=>'asdf',
152
- }).to_return(status: 500, body: "{}")
144
+ with(headers: {'Flipper-Cloud-Token'=>'asdf'}).to_return(status: 500, body: "{}")
153
145
 
154
146
  flipper = Flipper.new(Flipper::Adapters::Memory.new)
155
147
 
@@ -174,10 +166,7 @@ RSpec.describe Flipper::Cloud do
174
166
 
175
167
  it 'raises error for timeout while importing' do
176
168
  stub_request(:post, /www\.flippercloud\.io\/adapter\/features.*/).
177
- with(headers: {
178
- 'Feature-Flipper-Token'=>'asdf',
179
- 'Flipper-Cloud-Token'=>'asdf',
180
- }).to_timeout
169
+ with(headers: {'Flipper-Cloud-Token'=>'asdf'}).to_timeout
181
170
 
182
171
  flipper = Flipper.new(Flipper::Adapters::Memory.new)
183
172
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flipper-cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.0
4
+ version: 0.23.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-08 00:00:00.000000000 Z
11
+ date: 2022-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: flipper
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.22.0
19
+ version: 0.23.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.22.0
26
+ version: 0.23.1
27
27
  description:
28
28
  email:
29
29
  - nunemaker@gmail.com
@@ -34,6 +34,7 @@ files:
34
34
  - docs/images/flipper_cloud.png
35
35
  - examples/cloud/app.ru
36
36
  - examples/cloud/basic.rb
37
+ - examples/cloud/cloud_setup.rb
37
38
  - examples/cloud/import.rb
38
39
  - flipper-cloud.gemspec
39
40
  - lib/flipper-cloud.rb
@@ -71,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
72
  - !ruby/object:Gem::Version
72
73
  version: '0'
73
74
  requirements: []
74
- rubygems_version: 3.0.3
75
+ rubygems_version: 3.1.2
75
76
  signing_key:
76
77
  specification_version: 4
77
78
  summary: FlipperCloud.io adapter for Flipper