Content-Length: 5337 | pFad | http://github.com/coder/coder/pull/17715.patch
thub.com
From 730b5ddfe3cc8fd2cd8b330c4ea3665a2ac4aac2 Mon Sep 17 00:00:00 2001
From: Callum Styan
Date: Wed, 7 May 2025 23:16:15 +0000
Subject: [PATCH 1/4] enrich the "not logged in" error message with the full
path to the coder executable
Signed-off-by: Callum Styan
---
cli/root.go | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/cli/root.go b/cli/root.go
index 1dba212316c74..8fec1a945b0b3 100644
--- a/cli/root.go
+++ b/cli/root.go
@@ -72,7 +72,7 @@ const (
varDisableDirect = "disable-direct-connections"
varDisableNetworkTelemetry = "disable-network-telemetry"
- notLoggedInMessage = "You are not logged in. Try logging in using 'coder login '."
+ notLoggedInMessage = "You are not logged in. Try logging in using '%s login '."
envNoVersionCheck = "CODER_NO_VERSION_WARNING"
envNoFeatureWarning = "CODER_NO_FEATURE_WARNING"
@@ -534,7 +534,11 @@ func (r *RootCmd) InitClient(client *codersdk.Client) serpent.MiddlewareFunc {
rawURL, err := conf.URL().Read()
// If the configuration files are absent, the user is logged out
if os.IsNotExist(err) {
- return xerrors.New(notLoggedInMessage)
+ binPath, err := os.Executable()
+ if err != nil {
+ binPath = "coder"
+ }
+ return xerrors.Errorf(notLoggedInMessage, binPath)
}
if err != nil {
return err
From d3d5e1e5784ef1a21bac50f4825cf9bfab2a9756 Mon Sep 17 00:00:00 2001
From: Callum Styan
Date: Thu, 8 May 2025 19:19:50 +0000
Subject: [PATCH 2/4] update tests that were failing due to login error message
changes
Signed-off-by: Callum Styan
---
cli/logout_test.go | 9 +++++++--
cli/userlist_test.go | 9 +++++++--
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/cli/logout_test.go b/cli/logout_test.go
index 62c93c2d6f81b..f8ce09460b6f6 100644
--- a/cli/logout_test.go
+++ b/cli/logout_test.go
@@ -1,6 +1,7 @@
package cli_test
import (
+ "fmt"
"os"
"runtime"
"testing"
@@ -90,9 +91,13 @@ func TestLogout(t *testing.T) {
logout.Stdout = pty.Output()
go func() {
+ executable, err := os.Executable()
+ require.NoError(t, err)
+ require.NotEqual(t, "", executable)
+
defer close(logoutChan)
- err := logout.Run()
- assert.ErrorContains(t, err, "You are not logged in. Try logging in using 'coder login '.")
+ err = logout.Run()
+ require.Contains(t, err.Error(), fmt.Sprintf("Try logging in using '%s login '.", executable))
}()
<-logoutChan
diff --git a/cli/userlist_test.go b/cli/userlist_test.go
index 1a4409bb898ac..2681f0d2a462e 100644
--- a/cli/userlist_test.go
+++ b/cli/userlist_test.go
@@ -4,6 +4,8 @@ import (
"bytes"
"context"
"encoding/json"
+ "fmt"
+ "os"
"testing"
"github.com/stretchr/testify/assert"
@@ -69,9 +71,12 @@ func TestUserList(t *testing.T) {
t.Run("NoURLFileErrorHasHelperText", func(t *testing.T) {
t.Parallel()
+ executable, err := os.Executable()
+ require.NoError(t, err)
+
inv, _ := clitest.New(t, "users", "list")
- err := inv.Run()
- require.Contains(t, err.Error(), "Try logging in using 'coder login '.")
+ err = inv.Run()
+ require.Contains(t, err.Error(), fmt.Sprintf("Try logging in using '%s login '.", executable))
})
t.Run("SessionAuthErrorHasHelperText", func(t *testing.T) {
t.Parallel()
From 364c8bfbed1e6959e92e201b469133ac748fa223 Mon Sep 17 00:00:00 2001
From: Callum Styan
Date: Thu, 8 May 2025 20:32:47 +0000
Subject: [PATCH 3/4] fix lint error; move os.Executable call outside of the
anonymous goroutine
Signed-off-by: Callum Styan
---
cli/logout_test.go | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/cli/logout_test.go b/cli/logout_test.go
index f8ce09460b6f6..35a59360ed171 100644
--- a/cli/logout_test.go
+++ b/cli/logout_test.go
@@ -90,11 +90,11 @@ func TestLogout(t *testing.T) {
logout.Stdin = pty.Input()
logout.Stdout = pty.Output()
- go func() {
- executable, err := os.Executable()
- require.NoError(t, err)
- require.NotEqual(t, "", executable)
+ executable, err := os.Executable()
+ require.NoError(t, err)
+ require.NotEqual(t, "", executable)
+ go func() {
defer close(logoutChan)
err = logout.Run()
require.Contains(t, err.Error(), fmt.Sprintf("Try logging in using '%s login '.", executable))
From b561db449d1b1d89a2b80d2e9e54f9737ad8bada Mon Sep 17 00:00:00 2001
From: Callum Styan
Date: Fri, 9 May 2025 21:30:27 +0000
Subject: [PATCH 4/4] change require back to assert, not sure why I changed
this before
Signed-off-by: Callum Styan
---
cli/logout_test.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cli/logout_test.go b/cli/logout_test.go
index 35a59360ed171..9e7e95c68f211 100644
--- a/cli/logout_test.go
+++ b/cli/logout_test.go
@@ -97,7 +97,7 @@ func TestLogout(t *testing.T) {
go func() {
defer close(logoutChan)
err = logout.Run()
- require.Contains(t, err.Error(), fmt.Sprintf("Try logging in using '%s login '.", executable))
+ assert.Contains(t, err.Error(), fmt.Sprintf("Try logging in using '%s login '.", executable))
}()
<-logoutChan
--- a PPN by Garber Painting Akron. With Image Size Reduction included!Fetched URL: http://github.com/coder/coder/pull/17715.patch
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy