Skip to content

Conversation

@matifali
Copy link
Member

@matifali matifali commented Dec 9, 2025

Summary

Display the template version name in coder templates push CLI output.

Problem

When running coder templates push without the --name flag, 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:207 to include the version name in the output. The version name is styled with the Keyword style for consistency with other CLI output (like template names).

Before:

Updated version at Jan 2 15:04:05!

After:

Updated version kind_nightingale at Jan 2 15:04:05!

This works for both autogenerated names and user-specified names (via --name flag).

Test Plan

Added two new test cases in cli/templatepush_test.go:

  1. TestTemplatePush/DisplayAutogeneratedVersionName - Verifies autogenerated names are displayed
  2. TestTemplatePush/DisplayUserSpecifiedVersionName - Verifies user-specified names are displayed

Both tests verify that:

  • The output contains "Updated version {name}"
  • The version name in the output matches the database record

Tests will run in CI (cannot run locally due to Docker requirements).

Closes #21111

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com

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" but
the new format is "Updated version {name} at". Updated the test to
match 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.
Copy link
Contributor

Copilot AI left a 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 the coder 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.

@matifali matifali changed the title fix(cli): display template version name in push output feat(cli): display template version name in push output Dec 9, 2025
@matifali matifali marked this pull request as ready for review December 10, 2025 10:08
Copy link
Member

@phorcys420 phorcys420 left a 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

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.

feat(cli): display autogenerated template name when running coder templates push

3 participants