-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* configuration-adjustments * add-option-storage-only * add-option-with-yaml-file * add-option-yaml-with-backup-to-storage * add-necessary-adjustments-for-redis * add-spec-option-storage-only * add-spec-option-with-yaml-file * add-spec-option-yaml-with-backup-to-storage * add-require * tests-adjustments * version and readme update * Update README.md Co-authored-by: Nando Sousa <nandosousafr@users.noreply.github.com> * Update README.md Co-authored-by: Nando Sousa <nandosousafr@users.noreply.github.com> * Update README.md Co-authored-by: Nando Sousa <nandosousafr@users.noreply.github.com> * Update README.md Co-authored-by: Nando Sousa <nandosousafr@users.noreply.github.com> * Update spec/feature_flagger/feature_spec.rb Co-authored-by: Nando Sousa <nandosousafr@users.noreply.github.com> * Update spec/feature_flagger/manager_spec.rb Co-authored-by: Nando Sousa <nandosousafr@users.noreply.github.com> * Update spec/feature_flagger/manager_spec.rb Co-authored-by: Nando Sousa <nandosousafr@users.noreply.github.com> * Update spec/feature_flagger/manager_spec.rb Co-authored-by: Nando Sousa <nandosousafr@users.noreply.github.com> * Update spec/feature_flagger/model_spec.rb Co-authored-by: Nando Sousa <nandosousafr@users.noreply.github.com> * Update spec/feature_flagger/model_spec.rb Co-authored-by: Nando Sousa <nandosousafr@users.noreply.github.com> * Update spec/feature_flagger/model_spec.rb Co-authored-by: Nando Sousa <nandosousafr@users.noreply.github.com> * Update spec/feature_flagger/storage/feature_keys_migration_spec.rb Co-authored-by: Nando Sousa <nandosousafr@users.noreply.github.com> * Update yaml_with_backup_to_storage_spec.rb * Update with_yaml_file_spec.rb * Update storage_only_spec.rb * Update feature_spec.rb Co-authored-by: Nando Sousa <nandosousafr@users.noreply.github.com>
- Loading branch information
Showing
16 changed files
with
177 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module FeatureFlagger | ||
module ManifestSources | ||
class StorageOnly | ||
def initialize(storage) | ||
@storage = storage | ||
end | ||
|
||
def resolved_info | ||
YAML.load(@storage.read_manifest_backup) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module FeatureFlagger | ||
module ManifestSources | ||
class WithYamlFile | ||
def initialize(yaml_path = nil) | ||
@yaml_path = yaml_path | ||
@yaml_path ||= "#{Rails.root}/config/rollout.yml" if defined?(Rails) | ||
end | ||
|
||
def resolved_info | ||
@resolved_info ||= ::YAML.load_file(@yaml_path) if @yaml_path | ||
end | ||
end | ||
end | ||
end |
18 changes: 18 additions & 0 deletions
18
lib/feature_flagger/manifest_sources/yaml_with_backup_to_storage.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module FeatureFlagger | ||
module ManifestSources | ||
class YAMLWithBackupToStorage | ||
def initialize(storage, yaml_path = nil) | ||
@yaml_path = yaml_path || ("#{Rails.root}/config/rollout.yml" if defined?(Rails)) | ||
@storage = storage | ||
end | ||
|
||
def resolved_info | ||
@resolved_info ||= begin | ||
yaml_data = YAML.load_file(@yaml_path) if @yaml_path | ||
@storage.write_manifest_backup(YAML.dump(yaml_data)) | ||
yaml_data | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module FeatureFlagger | ||
VERSION = "2.1.1" | ||
VERSION = "2.2.0" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require 'spec_helper' | ||
require 'feature_flagger/manifest_sources/storage_only' | ||
|
||
module FeatureFlagger | ||
module ManifestSources | ||
RSpec.describe StorageOnly do | ||
describe '.resolved_info' do | ||
context 'without local yaml file' do | ||
it 'returns a yaml file from storage' do | ||
|
||
storage = spy('Storage') | ||
yaml_path = File.expand_path('../../fixtures/rollout_example.yml', __FILE__) | ||
yaml_data = YAML.load_file(yaml_path) | ||
yaml_as_string = YAML.dump(yaml_data) | ||
allow(storage).to receive(:read_manifest_backup).and_return(yaml_as_string) | ||
|
||
manifest_source = StorageOnly.new(storage) | ||
expect(manifest_source.resolved_info).to eq(yaml_data) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require 'spec_helper' | ||
require 'feature_flagger/manifest_sources/with_yaml_file' | ||
|
||
module FeatureFlagger | ||
module ManifestSources | ||
RSpec.describe WithYamlFile do | ||
describe '.resolved_info' do | ||
context 'whit local yaml file' do | ||
it 'returns a yaml file from yaml_path' do | ||
yaml_path = File.expand_path('../../fixtures/rollout_example.yml', __FILE__) | ||
manifest_source = WithYamlFile.new(yaml_path) | ||
expect(manifest_source.resolved_info).to eq(YAML.load_file(yaml_path)) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require 'spec_helper' | ||
require 'feature_flagger/manifest_sources/yaml_with_backup_to_storage' | ||
|
||
module FeatureFlagger | ||
module ManifestSources | ||
RSpec.describe YAMLWithBackupToStorage do | ||
describe '.resolved_info' do | ||
context 'with local yaml file to storage' do | ||
it 'returns a yaml file from yaml_path with backup to storage' do | ||
storage = spy('Storage') | ||
yaml_path = File.expand_path('../../fixtures/rollout_example.yml', __FILE__) | ||
yaml_data = YAML.load_file(yaml_path) | ||
yaml_as_string = YAML.dump(yaml_data) | ||
|
||
manifest_source = YAMLWithBackupToStorage.new(storage, yaml_path) | ||
expect(manifest_source.resolved_info).to eq(yaml_data) | ||
|
||
expect(storage).to have_received(:write_manifest_backup).with(yaml_as_string) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |