Skip to content

feat: add version checking to CLI #2643

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Jun 29, 2022
Prev Previous commit
Next Next commit
use install script link
  • Loading branch information
sreya committed Jun 24, 2022
commit 6e8c3c0260b7368585f4bc22122b10eab346b84c
5 changes: 3 additions & 2 deletions cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,13 @@ func checkVersions(cmd *cobra.Command, client *codersdk.Client) error {
fmtWarningText := `client/server versions do not match
client version: %s
server version: %s
download the appropriate version from https://github.com/coder/coder/releases/tag/%s
to download the appropriate version run 'curl -L https://coder.com/install.sh | sh -s -- --version %s'
`

if !buildinfo.VersionsMatch(clientVersion, info.Version) {
warn := cliui.Styles.Warn.Copy().Align(lipgloss.Left)
_, _ = fmt.Fprintf(cmd.OutOrStdout(), warn.Render(fmtWarningText), clientVersion, info.Version, info.TrimmedVersion())
// Trim the leading 'v', our install.sh script does not handle this case well.
_, _ = fmt.Fprintf(cmd.OutOrStdout(), warn.Render(fmtWarningText), clientVersion, info.Version, info.TrimmedVersion()[1:])
_, _ = fmt.Fprintln(cmd.OutOrStdout())
}

Expand Down