Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2b52169

Browse files
committed
prevent duplicates
1 parent aa1ee2f commit 2b52169

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

cli/root.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,17 @@ func Root() *cobra.Command {
6565
SilenceUsage: true,
6666
Long: `Coder — A tool for provisioning self-hosted development environments.
6767
`,
68-
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
68+
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
6969
if varSuppressVersion {
7070
return nil
7171
}
7272

73+
// Login handles checking the versions itself since it
74+
// has a handle to an unauthenticated client.
75+
if cmd.Name() == "login" {
76+
return nil
77+
}
78+
7379
client, err := createClient(cmd)
7480
// If the client is unauthenticated we can ignore the check.
7581
// The child commands should handle an unauthenticated client.
@@ -357,6 +363,10 @@ func FormatCobraError(err error, cmd *cobra.Command) string {
357363
}
358364

359365
func checkVersions(cmd *cobra.Command, client *codersdk.Client) error {
366+
if varSuppressVersion {
367+
return nil
368+
}
369+
360370
clientVersion := buildinfo.Version()
361371

362372
info, err := client.BuildInfo(cmd.Context())

0 commit comments

Comments
 (0)