Skip to content

feat: implement Go OpenFeature provider for feature flag evaluation#598

Closed
kevwilliams wants to merge 3 commits into
mainfrom
feat/openfeature-provider
Closed

feat: implement Go OpenFeature provider for feature flag evaluation#598
kevwilliams wants to merge 3 commits into
mainfrom
feat/openfeature-provider

Conversation

@kevwilliams
Copy link
Copy Markdown
Contributor

Summary

  • Add pkg/featureflags package with an OpenFeature FeatureProvider backed by the Milo AllowanceBucket API
  • A flag is enabled for an org when an AllowanceBucket exists with status.available > 0 for the (org, features.miloapis.com/<flagKey>) pair
  • Add table-driven unit tests covering all scenarios with a stub lister (no real kube client required)
  • Fix fmt.Errorf non-literal format string vet errors in the project webhook, surfaced by the Go 1.25 upgrade required by the openfeature SDK

Details

Provider design

  • AllowanceBucketLister interface wraps client.List — any controller-runtime/pkg/client.Client satisfies it
  • BooleanEvaluation queries by spec.consumerRef.name and spec.resourceType field selectors (both indexed)
  • Non-boolean evaluations return TYPE_MISMATCH — feature flags are boolean entitlements only
  • API errors return defaultValue with DEFAULT reason; the provider never panics
  • Missing or empty targetingKey returns defaultValue with DEFAULT reason

Dependency

Added github.com/open-feature/go-sdk v1.17.2. The SDK requires Go 1.25, which required bumping the module's go directive from 1.23.1 to 1.25.0.

Test plan

  • go test -race ./pkg/featureflags/... passes — all table-driven scenarios covered
  • go test -race ./... passes — no regressions introduced
  • Integration test against a real cluster with an AllowanceBucket provisioned for a feature flag

Closes #577

Related: datum-cloud/enhancements#695, datum-cloud/enhancements#711

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
@joggrbot
Copy link
Copy Markdown
Contributor

joggrbot Bot commented May 5, 2026

📝 Documentation Analysis

All docs are up to date! 🎉


✅ Latest commit analyzed: 4181f81 | Powered by Joggr

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.
@kevwilliams kevwilliams requested a review from scotwells May 5, 2026 19:06
@scotwells
Copy link
Copy Markdown
Contributor

How / where is this used?

@kevwilliams
Copy link
Copy Markdown
Contributor Author

We decided we arent going to need this as part of the initial implementation.

@kevwilliams kevwilliams closed this May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: implement Go OpenFeature provider for feature flag evaluation

2 participants