refactor(sdk/go): unify functional-option handling with shared applier - #3232
Merged
Conversation
rhuss
requested review from
a team,
derekwaynecarr,
mrunalp and
sjenning
as code owners
September 9, 2026 07:17
4 tasks
elezar
reviewed
Sep 9, 2026
elezar
reviewed
Sep 9, 2026
elezar
reviewed
Sep 9, 2026
elezar
reviewed
Sep 9, 2026
elezar
reviewed
Sep 9, 2026
Introduce a single generic applier, options.Apply[T any, O ~func(*T)], in a new leaf package openshell/v1/internal/options, and route all option-application sites through it. Nil option entries are now ignored uniformly instead of panicking; non-nil options still apply in order, and each site keeps its existing pre-seeding and defaulting. - Add internal/options package with Apply and unit tests - Route the 15 application sites (root, types, oidc, fake, gateway, edge) through options.Apply; exported types.Apply*Options keep their signatures and delegate to it - Add one nil-handling test per affected package - Document the nil-option rule in README.md and the docs book No public API signature changes. Closes NVIDIA#3213 Signed-off-by: Roland Huß <rhuss@redhat.com>
rhuss
force-pushed
the
6118-unify-go-sdk-options
branch
from
September 9, 2026 09:11
7275a08 to
32cd26f
Compare
4 tasks
elezar
approved these changes
Sep 9, 2026
elezar
left a comment
Member
There was a problem hiding this comment.
The updated PR is clean. The nil-option refactor preserves existing behavior for non-nil options, removes the unrelated ignore-file change, and the focused Go SDK suite passes. The remaining fake-client and OIDC defaulting discussions are appropriately tracked as follow-up work.
Member
|
/ok-to-test 32cd26f |
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
The Go SDK applied functional options with hand-copied
for _, o := range opts { o(&cfg) }loops at 15 sites across six areas. None guarded against a nil option, so a nil entry in an option list panicked everywhere. This unifies option application behind a single generic helper and adopts one rule: nil options are ignored.Related Issue
Closes #3213
Changes
openshell/v1/internal/options(new leaf package) withApply[T any, O ~func(*T)](target *T, opts []O)— skips nil entries, applies the rest in order.types,oidc,fake,gateway,edge)through
options.Apply. Exportedtypes.Apply*Optionshelpers keep their signatures and delegate.applyDefaults()ordering; only nil handling changes.sdk/go/README.mdand the docs book (docs/src/architecture.md).No public API signature changes; consumers compile unchanged.
Testing
mise run go:cigreen: build,golangci-lint,gofmt, fullgo test, proto-check, docs-check.Checklist