- Notifications
You must be signed in to change notification settings - Fork1.1k
feat(cli): display template version name in push output#21192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
Previously, when running `coder templates push` without specifying a`--name` flag, the backend would autogenerate a version name (e.g.,"kind_nightingale"), but the CLI never displayed this name to the user.This made it difficult to reference the version later.This change updates the success message to include the version name,whether it was autogenerated or user-specified.Output changes from: "Updated version at Jan 2 15:04:05!"to: "Updated version kind_nightingale at Jan 2 15:04:05!"Closes#21111🤖 Generated with [Claude Code](https://claude.com/claude-code)Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The test was expecting the old output format "Updated version at" butthe new format is "Updated version {name} at". Updated the test tomatch the beginning of the output string.The pty.Output() call was causing an error after the command completed.The test already verifies the output format with ExpectMatchContext,so we only need to verify the version was created in the database.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Pull request overview
This PR enhances thecoder templates push CLI command to display the template version name (whether autogenerated or user-specified) in the success message, making it easier for users to reference the version later.
Key Changes:
- Updated the success message format from "Updated version at {time}" to "Updated version {name} at {time}"
- Added version name styling with the Keyword style for visual consistency
- Added comprehensive test coverage for both autogenerated and user-specified version names
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| cli/templatepush.go | Modified success message to include version name with proper styling |
| cli/templatepush_test.go | Updated existing test assertion and added two new tests to verify version name display |
💡Add Copilot custom instructions for smarter, more guided reviews.Learn how to get started.
phorcys420 left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Looks good, and tests look fine, but i will let someone else cross check
| w:=clitest.StartWithWaiter(t,inv) | ||
| pty.ExpectNoMatchBefore(ctx,"Template message is longer than 72 characters","Updated version at") | ||
| pty.ExpectNoMatchBefore(ctx,"Template message is longer than 72 characters","Updated version") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Can we make sure that the template version matches the one exposed via API, and match the whole phraseUpdated version XYZ at?
EDIT:
I guess we could match the timestamp too, but it isn't crucial.
| assert.NotEmpty(t,templateVersions[1].Name) | ||
| }) | ||
| t.Run("DisplayUserSpecifiedVersionName",func(t*testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I guess we don't need a separate case for that, just modify "OK" test case :)
| w:=clitest.StartWithWaiter(t,inv) | ||
| // Expect the output to contain "Updated version" followed by the version name. | ||
| pty.ExpectMatchContext(ctx,"Updated version") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Same
Summary
Display the template version name in
coder templates pushCLI output.Problem
When running
coder templates pushwithout the--nameflag, the backend autogenerates a version name (e.g., "kind_nightingale") using Docker-style random names. However, the CLI never displayed this autogenerated name to the user, making it difficult to reference the version later.Fix
Updated the success message at
cli/templatepush.go:207to include the version name in the output. The version name is styled with theKeywordstyle for consistency with other CLI output (like template names).Before:
After:
This works for both autogenerated names and user-specified names (via
--nameflag).Test Plan
Added two new test cases in
cli/templatepush_test.go:TestTemplatePush/DisplayAutogeneratedVersionName- Verifies autogenerated names are displayedTestTemplatePush/DisplayUserSpecifiedVersionName- Verifies user-specified names are displayedBoth tests verify that:
Tests will run in CI (cannot run locally due to Docker requirements).
Closes#21111
🤖 Generated withClaude Code
Co-Authored-By: Claude Sonnet 4.5noreply@anthropic.com