From 335fd369f6903abbcb1d67a4afd3c56525d76344 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Wed, 14 Oct 2026 22:51:01 +1100 Subject: [PATCH] refactor: delete wrappers superseded by live entry points Remove controlplanerpc.NewClient (superseded by NewRPCClient), Loader.Overlay (-config-overlay reaches Resolve directly), and setup.Run (RunParams is the live entry point). Move ResolverFunc into a test file, since only tests adapt functions to the egress Resolver. --- internal/infrastructure/configuration/loader.go | 6 ------ internal/infrastructure/configuration/setup/setup.go | 9 +-------- internal/infrastructure/controlplanerpc/client.go | 5 ----- internal/infrastructure/egress/credentials.go | 7 ------- internal/infrastructure/egress/resolver_func_test.go | 10 ++++++++++ 5 files changed, 11 insertions(+), 26 deletions(-) create mode 100644 internal/infrastructure/egress/resolver_func_test.go diff --git a/internal/infrastructure/configuration/loader.go b/internal/infrastructure/configuration/loader.go index a4206d9e1..64afabd54 100644 --- a/internal/infrastructure/configuration/loader.go +++ b/internal/infrastructure/configuration/loader.go @@ -135,12 +135,6 @@ func validateOverlayPath(overlayPath, basePath string, baseIsDir bool) error { return nil } -// Overlay loads basePath, then replaces only the fields overlayPath sets. An -// empty overlayPath is equivalent to File. -func (l *Loader) Overlay(basePath, overlayPath string) (*Document, error) { - return l.overlayFile(basePath, overlayPath) -} - func (l *Loader) overlayFile(basePath, overlayPath string) (*Document, error) { doc := &Document{} diff --git a/internal/infrastructure/configuration/setup/setup.go b/internal/infrastructure/configuration/setup/setup.go index dea21377b..2817f0621 100644 --- a/internal/infrastructure/configuration/setup/setup.go +++ b/internal/infrastructure/configuration/setup/setup.go @@ -70,14 +70,7 @@ type Params struct { // SecretSink. } -// Run drives the setup flow and returns the TOML edits to apply. It writes no -// files; the caller must load the result before installing it or committing -// secrets. -func Run(ctx context.Context, p Prompter, discovery ModelDiscovery, secrets SecretSink, existing ExistingValues) ([]tomlwrite.Edit, error) { - return RunParams(ctx, p, discovery, secrets, existing, Params{}) -} - -// RunParams is Run with the question sites pre-answered from params. A zero +// RunParams drives the setup flow with the question sites pre-answered from params. A zero // Params behaves exactly like Run. func RunParams(ctx context.Context, p Prompter, discovery ModelDiscovery, secrets SecretSink, existing ExistingValues, params Params) ([]tomlwrite.Edit, error) { var edits []tomlwrite.Edit diff --git a/internal/infrastructure/controlplanerpc/client.go b/internal/infrastructure/controlplanerpc/client.go index 32a67375b..250964b4b 100644 --- a/internal/infrastructure/controlplanerpc/client.go +++ b/internal/infrastructure/controlplanerpc/client.go @@ -9,7 +9,6 @@ import ( "fmt" "time" - "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -36,10 +35,6 @@ var ( type Client struct{ rpc pb.ControlPlaneServiceClient } -func NewClient(conn grpc.ClientConnInterface) *Client { - return &Client{rpc: pb.NewControlPlaneServiceClient(conn)} -} - func NewRPCClient(client pb.ControlPlaneServiceClient) *Client { return &Client{rpc: client} } // ResourceReader is the read side of the control-plane client: one resource diff --git a/internal/infrastructure/egress/credentials.go b/internal/infrastructure/egress/credentials.go index 6e8e8c95f..4e4f789a2 100644 --- a/internal/infrastructure/egress/credentials.go +++ b/internal/infrastructure/egress/credentials.go @@ -40,13 +40,6 @@ type Resolver interface { Resolve(ctx context.Context, credential, service string) (string, error) } -// ResolverFunc adapts a function to Resolver. -type ResolverFunc func(ctx context.Context, credential, service string) (string, error) - -func (f ResolverFunc) Resolve(ctx context.Context, credential, service string) (string, error) { - return f(ctx, credential, service) -} - // injection is one compiled credential@1 apiKey inject rule. type injection struct { service string diff --git a/internal/infrastructure/egress/resolver_func_test.go b/internal/infrastructure/egress/resolver_func_test.go new file mode 100644 index 000000000..92857ac16 --- /dev/null +++ b/internal/infrastructure/egress/resolver_func_test.go @@ -0,0 +1,10 @@ +package egress + +import "context" + +// ResolverFunc adapts a function to Resolver for tests. +type ResolverFunc func(ctx context.Context, credential, service string) (string, error) + +func (f ResolverFunc) Resolve(ctx context.Context, credential, service string) (string, error) { + return f(ctx, credential, service) +}