Skip to content

feat(sdk/go): bundle Create() positional parameters into options struct #2807

Description

@rhuss

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    state:triage-neededOpened without agent diagnostics and needs triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions