Skip to content

Let callers choose a runtime when creating a sprite - #45

Closed
dangra wants to merge 2 commits into
mainfrom
sprites-dedicated-hosts
Closed

dangra wants to merge 2 commits into
mainfrom
sprites-dedicated-hosts

Conversation

@dangra

@dangra dangra commented Sep 8, 2026

Copy link
Copy Markdown
Member

The create API accepts an optional runtime naming which runtime variant a sprite should be created on. The SDK had no way to send it, so callers were stuck with the default.

Shape

Rather than grow the signature of CreateSpriteWithOrg a third time, this adds CreateSpriteWithOptions taking a CreateSpriteOptions struct, so the next optional setting is a field rather than another positional argument:

sprite, err := client.CreateSpriteWithOptions(ctx, "my-sprite", sprites.CreateSpriteOptions{
    Runtime: "some-runtime",
})

CreateSprite and CreateSpriteWithOrg are untouched at the call site and delegate to it, so this is additive — no existing caller has to change.

The runtime is opaque on purpose

Which names are valid is the API's business, not the SDK's. Keeping it an unvalidated string means a new runtime works without an SDK release, and an unknown one comes back as a server error naming the set that is accepted — better than a client-side list that drifts out of date and rejects something the server would have taken.

An empty runtime is omitted from the request body entirely (omitempty), since sending "" would ask for a variant named "" rather than for the default. There is a test pinning that, because it is the kind of thing a later refactor silently breaks.

Tests

Three, driving a stub server and asserting on the JSON that actually goes out: the runtime is sent when set, omitted when empty, and CreateSpriteWithOrg still carries its config and labels through the new path. go test, go vet and gofmt are clean.

The create API accepts an optional `runtime` naming which runtime variant the
sprite should be created on; the SDK had no way to send it, so callers were
stuck with the default.

Rather than grow the signature of CreateSpriteWithOrg again, this adds
CreateSpriteWithOptions taking a CreateSpriteOptions struct, so the next
optional setting is a field instead of another positional argument. The two
existing constructors keep working and delegate to it.

The runtime is passed through as an opaque string. Which names are valid is
the API's business, not the SDK's, so a new runtime becomes usable without an
SDK release and an unknown one comes back as a server error naming the set
that is accepted. An empty runtime is omitted from the request body entirely:
sending "" would ask for a variant named "" rather than for the default.
Copilot AI lite review requested due to automatic review settings September 8, 2026 18:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

golangci-lint's nlreturn wants a blank line before a return that closes a
block of more than three statements.
@dangra

dangra commented Sep 8, 2026

Copy link
Copy Markdown
Member Author

Closing: this is the wrong approach and not something we want to expose in the SDK.

@dangra dangra closed this Sep 8, 2026
@dangra
dangra deleted the sprites-dedicated-hosts branch September 8, 2026 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants