Skip to content

sandbox create: Support --output flag. - #5

Merged
enisoc merged 1 commit into
mainfrom
sandbox-create-output
Jun 9, 2022
Merged

enisoc merged 1 commit into
mainfrom
sandbox-create-output

Conversation

@enisoc

@enisoc enisoc commented Jun 3, 2022

Copy link
Copy Markdown
Contributor

This adds support for the --output flag to the sandbox create command.

As part of this, I separated log output and sent it to stderr so that it won't get combined with the output JSON/YAML. I also updated other commands to use the same convention of sending log output to stderr for consistency.

@enisoc
enisoc requested a review from jmsktm June 3, 2022 19:15
sbURL := cfg.SandboxDashboardURL(resp.SandboxID)
fmt.Fprintf(out, "\nDashboard page: %v\n\n", sbURL)
switch cfg.OutputFormat {
case config.OutputFormatDefault:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What value does cfg.OutputFormat get when:
a. When the flag is provided with just no value. Empty string?
b. When the --output flag is not provided. nil / empty?

Just trying to make sure it doesn't land in the default case if nil is a possibility causing it to error out.

I took a look at this and this. But I couldn't be certain.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To add to that, if it defaults to an empty string in absence of the --output flag, should we write to log in that case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

a. When the flag is provided with just no value.

The flag library will return an error if the user specifies --output without providing a value. If the user specifies an explicit empty string value like --output="" then that value will be passed through and will match config.OutputFormatDefault (which is "").

b. When the --output flag is not provided.

In this case, cfg.OutputFormat will be left at its Go zero value. Since the type is defined as type OutputFormat string, the Go zero value is the same as for string, which is "".

if it defaults to an empty string in absence of the --output flag, should we write to log in that case?

I debated that too. The rule I went with for now is that the "main output" of a command goes to stdout regardless of how we format the main output (human-readable vs. JSON), while the log (stderr) is used to report on the steps we went through to acquire the main output.

For example, if you redirect stdout to a file in human-readable mode, I figured you should still get the info about the sasndbox instead of getting nothing.

@jmsktm jmsktm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I've made a comment on the default value for the --output flag under two cases. Feel free to merge if it defaults to an empty string in both the cases.

@enisoc
enisoc merged commit 9daa47a into main Jun 9, 2022
@enisoc
enisoc deleted the sandbox-create-output branch June 9, 2022 15:20
scott-cotton added a commit that referenced this pull request May 21, 2026
…rnings)

Address findings #3, #4, #5, #6 from the versioned-resource-plugins UX pass.

#4 — apply immutable-version error: the previous code matched on
*ApplyResourcePluginConflict, but the go-sdk's transport middleware
(FixAPIErrors) intercepts every 4xx/5xx response before the per-endpoint
typed reader runs, so that type is never in the error chain and the
catch-and-rewrite was dead code. Users saw the generic '409 Conflict:
plugin version already exists'. Switch to errors.As against
*transport.APIError + Code==409 (the same pattern used in planexec/logs).

Also #11 — branch the message text on the bare-name vs. concrete-version
case: a bare-name author has no '@semver' suffix to bump, so the
'bump the version field' advice was a dead end; now they get a concrete
'add an @<semver> suffix to publish a new revision (e.g. [email protected])'.

#5 — apply success line: previously stayed silent on the version for
bare-name authors ('Created resource plugin my-plugin') while
explicit-version authors saw '@0.0.1'. The asymmetry hid the versioning
rule from exactly the population that most needed to learn it. Always
echo the explicit version on the apply success line (rendering '@0.0.0'
for bare publishes). The list/table/get-yaml output continues to bare
the default version for backward compatibility with pre-versioning
clients — this one message is explicit on purpose, as a teaching moment.

#3 — bare-form delete: previously silently removed only the latest
version with no indication that others remained, a footgun for users
who assumed 'delete my-plugin' meant 'delete the plugin'. Resolve the
latest version explicitly before the delete (one List call), then
report which version was removed and how many remain, e.g.
'Deleted resource plugin [email protected].
 1 other version(s) remain (use 'signadot resourceplugin versions my-plugin' to list).'

#6 — delete-in-use: previously surfaced the server's generic
'400 Bad Request: plugin is currently in use' with no hint about which
sandbox(es) were holding the version. Enrich client-side: on that
specific 400 we GET the plugin and surface Status.Resources sandbox
names: 'resource plugin [email protected] is still referenced by sandbox(es): a, b'.
Falls back to the original error if the enrichment can't be done.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@scott-cotton scott-cotton mentioned this pull request May 21, 2026
2 of 6 tasks
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