feat: Configurably allow duplicates in FileDataSourceImpl #298
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related issues
N/A
Describe the solution you've provided
This PR modifies the
FileDataSourceImpl
to accept an additional value in the options hash calledallow_duplicates
.false
will be used if no value is provided which will cause this to operate exactly as it does prior to this change.Configuring
allow_duplicates
to betrue
will not raise an error when flag or segment values are loaded from multiple files and a subsequent file contains a key found in a previous file.The purpose of this is to allow a notion of a 'local' override during development. A project may have a
/config/feature_flags.yml
and a developer adds a flag to it for a feature they are developing. If they want to commit code with this feature, but don't want other developers encountering it yet, they will have to remember to turn the feature off prior to commiting their change.With this change, a project could have a
/config/feature_flags.yml
which contains the flag values other developers should see, and a/config/feature_flags.local.yml
file, ignored by source control and not checked in. As a developer is working on the new feature, they can have it enabled in the.local
file so they can see the feature and work with it, but disabled in the committed file so it does not impact other developers. As the files are processed in the order they are defined, the values defined in subsequent files would take precedence over duplicate values defined in prior files.Requirements
Describe alternatives you've considered
I considered trying to accomplish this via subclassing the
FileDataSourceImpl
but it is not really designed for extension based on the amount of private functionality and state that it maintains internally. As such, an upstream change to the implementation itself seemed like the path of least resistance.Additional context