feat: implement Go OpenFeature provider for feature flag evaluation#598
Closed
kevwilliams wants to merge 3 commits into
Closed
feat: implement Go OpenFeature provider for feature flag evaluation#598kevwilliams wants to merge 3 commits into
kevwilliams wants to merge 3 commits into
Conversation
Add pkg/featureflags package providing an OpenFeature-compatible FeatureProvider backed by the Milo AllowanceBucket API. A feature flag is enabled for an org when an AllowanceBucket with status.available > 0 exists for the (org, resourceType) pair where resourceType is "features.miloapis.com/<flagKey>". Key design decisions: - AllowanceBucketLister interface accepts any controller-runtime client, enabling easy injection and testing without a live API server - BooleanEvaluation queries by spec.consumerRef.name and spec.resourceType field selectors (both are indexed in the quota system) - Non-boolean evaluations return TYPE_MISMATCH; feature flags are boolean entitlements only - API errors return defaultValue with DEFAULT reason (no panics) - Missing or empty targetingKey returns defaultValue with DEFAULT reason Also fix fmt.Errorf with non-literal format strings in project webhook, surfaced as a vet error after upgrading to Go 1.25 (required by the openfeature SDK's go.mod minimum version). Closes #577
Contributor
go.mod requires go 1.25 (introduced by the openfeature go-sdk v1.17.2 dependency); update the builder stage to match.
golang.org/x/net/http2 < v0.51.0 is vulnerable to an uncaught exception via missing nil check on HTTP/2 frames with values 0x0a-0x0f (CVSS 6.9). Upgrade resolves the Snyk finding introduced by the openfeature SDK adding a fresh transitive path to the affected version.
Contributor
|
How / where is this used? |
Contributor
Author
|
We decided we arent going to need this as part of the initial implementation. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
pkg/featureflagspackage with an OpenFeatureFeatureProviderbacked by the MiloAllowanceBucketAPIAllowanceBucketexists withstatus.available > 0for the(org, features.miloapis.com/<flagKey>)pairfmt.Errorfnon-literal format string vet errors in the project webhook, surfaced by the Go 1.25 upgrade required by the openfeature SDKDetails
Provider design
AllowanceBucketListerinterface wrapsclient.List— anycontroller-runtime/pkg/client.Clientsatisfies itBooleanEvaluationqueries byspec.consumerRef.nameandspec.resourceTypefield selectors (both indexed)TYPE_MISMATCH— feature flags are boolean entitlements onlydefaultValuewithDEFAULTreason; the provider never panicstargetingKeyreturnsdefaultValuewithDEFAULTreasonDependency
Added
github.com/open-feature/go-sdk v1.17.2. The SDK requires Go 1.25, which required bumping the module'sgodirective from 1.23.1 to 1.25.0.Test plan
go test -race ./pkg/featureflags/...passes — all table-driven scenarios coveredgo test -race ./...passes — no regressions introducedAllowanceBucketprovisioned for a feature flagCloses #577
Related: datum-cloud/enhancements#695, datum-cloud/enhancements#711