Summary
SandboxInterface.Create() now takes 7 positional parameters plus variadic opts after the sandbox templates refactor in PR #2781:
Create(ctx context.Context, workspace, name string, workload *SandboxWorkloadConfig,
policy *SandboxPolicy, providers []string, labels map[string]string,
opts ...CreateOptions) (*Sandbox, error)
Four consecutive nilable parameters of different types makes call sites unreadable:
client.Sandboxes().Create(ctx, "default", "my-sandbox", nil, nil, nil, nil)
Proposed Change
Bundle the creation parameters into a CreateSandboxParams struct:
type CreateSandboxParams struct {
Workload *SandboxWorkloadConfig
Policy *SandboxPolicy
Providers []string
Labels map[string]string
}
The interface becomes:
Create(ctx context.Context, workspace, name string, params CreateSandboxParams, opts ...CreateOptions) (*Sandbox, error)
This follows the k8s client-go pattern this SDK models, where creation parameters are bundled into typed structs rather than passed as positional arguments. Since PR #2781 is already a breaking change, the migration cost for this improvement is minimal.
The same pattern should apply to CreateFromTemplate() if it has a similar parameter list.
Context
Identified during PR #2781 code review (comment). The parameter list grew from 5 to 7+opts when policy and providers were promoted to top-level request fields.
Summary
SandboxInterface.Create()now takes 7 positional parameters plus variadic opts after the sandbox templates refactor in PR #2781:Four consecutive nilable parameters of different types makes call sites unreadable:
Proposed Change
Bundle the creation parameters into a
CreateSandboxParamsstruct:The interface becomes:
This follows the k8s client-go pattern this SDK models, where creation parameters are bundled into typed structs rather than passed as positional arguments. Since PR #2781 is already a breaking change, the migration cost for this improvement is minimal.
The same pattern should apply to
CreateFromTemplate()if it has a similar parameter list.Context
Identified during PR #2781 code review (comment). The parameter list grew from 5 to 7+opts when
policyandproviderswere promoted to top-level request fields.