feat: scaffold OpenFeature Go SDK feature-flag support#146
Conversation
Wire the portable OpenFeature Go SDK (v1.17.2, GA) in pkg/featureflag as the standard runtime flag API so services generated from the template can land every feature behind a flag, default-off, per the feature-flag-first delivery convention. Ships the in-memory provider (example evaluates with no backend; swap for flagd/a managed backend in a real service), one example flag gating a sample path, and a table-driven test asserting both states plus the missing-flag default-off safety. AGENTS.md documents the convention + mandatory flag lifecycle; the SDK is the single allowance in depguard's strict allow-list, the rest of the non-test scaffold stays stdlib-only. Fixes #145 Part of devantler-tech/monorepo#2059 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughThis pull request adds a feature-flag-first scaffold for Go templates. It introduces ChangesRelated issues: Suggested labels: enhancement, dependencies, documentation Suggested reviewers: devantler Sequence Diagram(s)sequenceDiagram
participant Caller
participant ExampleFeature
participant Enabled
participant OpenFeatureClient
participant InMemoryProvider
Caller->>ExampleFeature: ExampleFeature(ctx, client)
ExampleFeature->>Enabled: Enabled(ctx, client, ExampleFlag)
Enabled->>OpenFeatureClient: Boolean(ctx, ExampleFlag, false, ...)
OpenFeatureClient->>InMemoryProvider: evaluate flag
InMemoryProvider-->>OpenFeatureClient: variant value
OpenFeatureClient-->>Enabled: boolean result
Enabled-->>ExampleFeature: true/false
ExampleFeature-->>Caller: "new feature output" or "default output"
Poem Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (1 error)
✅ Passed checks (4 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@AGENTS.md`:
- Around line 93-105: The feature-flag guidance only documents the OpenFeature
path and is missing the CLI-only exception for lightweight static boolean flags.
Update the AGENTS.md guidance near the feature-flag section to explicitly
mention the cobra Hidden / --experimental route, and clarify that templates
needing only static CLI gating should use that dependency-free approach instead
of the OpenFeature SDK. Refer to the feature-flag-first delivery section and its
package guidance so the exception is clearly tied to the existing flag policy.
In `@README.md`:
- Line 12: The README feature-flag bullet only mentions the OpenFeature SDK
flow; update that bullet to also mention the non-SDK Cobra path using the Hidden
or --experimental option so readers understand when a generated CLI can stay
dependency-free. Keep the existing Feature-flag-first entry in the README, but
expand its wording to cover both the pkg/featureflag/OpenFeature approach and
the cobra Hidden/--experimental alternative.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 62ba90e6-d6cd-47cf-83e3-81f91a9b978a
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (6)
.golangci.ymlAGENTS.mdREADME.mdgo.modpkg/featureflag/featureflag.gopkg/featureflag/featureflag_test.go
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
devantler-tech/actions(auto-detected)
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
- GitHub Check: zizmor
🧰 Additional context used
📓 Path-based instructions (3)
{go.mod,.github/workflows/copilot-setup-steps.yml,README.md}
📄 CodeRabbit inference engine (AGENTS.md)
Do not hard-code a second Go version elsewhere;
copilot-setup-steps.ymlmust read the version fromgo.mod, and the README should refer togo.modinstead of duplicating the floor.
Files:
README.mdgo.mod
pkg/featureflag/**/*.go
📄 CodeRabbit inference engine (AGENTS.md)
New features should be guarded behind
pkg/featureflag.Enabled, default to the old path when the flag is off or errors, and include table-driven tests covering both enabled and disabled states.
Files:
pkg/featureflag/featureflag_test.gopkg/featureflag/featureflag.go
go.mod
📄 CodeRabbit inference engine (AGENTS.md)
Keep the Go minimum version in
go.modas the single source of truth, and raise it only when a shared tooling requirement or security/EOL reason forces it.
Files:
go.mod
🔇 Additional comments (7)
.golangci.yml (1)
38-41: LGTM!pkg/featureflag/featureflag.go (4)
1-32: LGTM!
40-57: LGTM!
59-70: LGTM!
72-89: LGTM!pkg/featureflag/featureflag_test.go (1)
1-52: LGTM! Table-driven subtests correctly cover enabled, disabled, and absent-flag default-off states, and per-subtest unique domain names avoid provider registration collisions undert.Parallel().go.mod (1)
4-10: 🗄️ Data Integrity & IntegrationCheck the
godirective against the new SDK’s Go 1.24 floor.github.com/open-feature/go-sdk v1.17.2requires Go 1.24, sogo.modshould still be the single source of truth for the minimum supported version.
Address CodeRabbit: issue #145 asks for CLI experimental-flag guidance too. Document that the OpenFeature SDK is for services needing runtime evaluation, while a generated CLI should stay dependency-free by gating experimental commands behind cobra Hidden + an --experimental opt-in, reaching for the SDK only when richer evaluation is needed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@coderabbitai review
|
|
✅ Action performedReview finished.
|
Superseded: every requested change was addressed in a80f196 (concrete memprovider return + un-inlined error + CLI experimental-flag guidance in AGENTS.md/README) and all review threads are resolved. CodeRabbit's subsequent reviews on the current head are COMMENTED-only with no new change requests. Dismissing this stale review from commit 3417964.
Why
The Go template ships no feature-flag scaffolding, so every service generated from it starts without a standard way to land features behind a flag — the opposite of the portfolio-wide feature-flag-first delivery direction.
What
Wires the portable OpenFeature Go SDK as the standard flag API in a small, replaceable
pkg/featureflagpackage: an example feature gated default-off, with tests covering both states. Ships with an in-memory provider so it works out of the box; a real service swaps in flagd or a managed backend without touching call sites.AGENTS.mddocuments the convention and the mandatory flag lifecycle (release flags are removed after rollout). Dependency footprint stays minimal.Fixes #145
Part of devantler-tech/monorepo#2059