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

Skip to content

Commit 8ea2920

Browse files
committed
Fix lint issues
1 parent 7774e29 commit 8ea2920

9 files changed

+23
-20
lines changed

cli/login.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222

2323
const (
2424
goosWindows = "windows"
25-
goosLinux = "linux"
2625
goosDarwin = "darwin"
2726
)
2827

@@ -173,7 +172,7 @@ func saveSessionToken(cmd *cobra.Command, client *codersdk.Client, sessionToken
173172
client.SessionToken = sessionToken
174173
resp, err := client.User(cmd.Context(), "me")
175174
if err != nil {
176-
return xerrors.Errorf("get user: ", err)
175+
return xerrors.Errorf("get user: %w", err)
177176
}
178177

179178
config := createConfig(cmd)
@@ -203,7 +202,7 @@ func isWSL() (bool, error) {
203202
}
204203

205204
// openURL opens the provided URL via user's default browser
206-
func openURL(url string) error {
205+
func openURL(urlToOpen string) error {
207206
var cmd string
208207
var args []string
209208

@@ -215,10 +214,10 @@ func openURL(url string) error {
215214
if wsl {
216215
cmd = "cmd.exe"
217216
args = []string{"/c", "start"}
218-
url = strings.ReplaceAll(url, "&", "^&")
219-
args = append(args, url)
217+
urlToOpen = strings.ReplaceAll(urlToOpen, "&", "^&")
218+
args = append(args, urlToOpen)
220219
return exec.Command(cmd, args...).Start()
221220
}
222221

223-
return browser.OpenURL(url)
222+
return browser.OpenURL(urlToOpen)
224223
}

cli/login_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import (
44
"context"
55
"testing"
66

7+
"github.com/stretchr/testify/require"
8+
79
"github.com/coder/coder/cli/clitest"
810
"github.com/coder/coder/coderd"
911
"github.com/coder/coder/coderd/coderdtest"
1012
"github.com/coder/coder/console"
11-
"github.com/stretchr/testify/require"
1213
)
1314

1415
func TestLogin(t *testing.T) {

cli/workspacecreate_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ package cli_test
33
import (
44
"testing"
55

6+
"github.com/stretchr/testify/require"
7+
68
"github.com/coder/coder/cli/clitest"
79
"github.com/coder/coder/coderd/coderdtest"
810
"github.com/coder/coder/console"
911
"github.com/coder/coder/provisioner/echo"
1012
"github.com/coder/coder/provisionersdk/proto"
11-
"github.com/stretchr/testify/require"
1213
)
1314

1415
func TestWorkspaceCreate(t *testing.T) {

coderd/coderd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func New(options *Options) http.Handler {
4040
r.Use(
4141
httpmw.ExtractAPIKey(options.Database, nil),
4242
)
43-
r.Post("/", api.postApiKey)
43+
r.Post("/", api.postAPIKey)
4444
})
4545

4646
// Used for setup.

coderd/projectimport_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import (
55
"net/http"
66
"testing"
77

8+
"github.com/stretchr/testify/require"
9+
810
"github.com/coder/coder/coderd"
911
"github.com/coder/coder/coderd/coderdtest"
1012
"github.com/coder/coder/codersdk"
1113
"github.com/coder/coder/database"
1214
"github.com/coder/coder/provisioner/echo"
1315
"github.com/coder/coder/provisionersdk/proto"
14-
"github.com/stretchr/testify/require"
1516
)
1617

1718
func TestPostProjectImportByOrganization(t *testing.T) {

coderd/users.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ func (api *api) postLogin(rw http.ResponseWriter, r *http.Request) {
318318
}
319319

320320
// Creates a new API key, used for logging in via the CLI
321-
func (api *api) postApiKey(rw http.ResponseWriter, r *http.Request) {
321+
func (api *api) postAPIKey(rw http.ResponseWriter, r *http.Request) {
322322
apiKey := httpmw.APIKey(r)
323323
userID := apiKey.UserID
324324

@@ -348,10 +348,10 @@ func (api *api) postApiKey(rw http.ResponseWriter, r *http.Request) {
348348
}
349349

350350
// This format is consumed by the APIKey middleware.
351-
generatedApiKey := fmt.Sprintf("%s-%s", keyID, keySecret)
351+
generatedAPIKey := fmt.Sprintf("%s-%s", keyID, keySecret)
352352

353353
render.Status(r, http.StatusCreated)
354-
render.JSON(rw, r, GenerateAPIKeyResponse{Key: generatedApiKey})
354+
render.JSON(rw, r, GenerateAPIKeyResponse{Key: generatedAPIKey})
355355
}
356356

357357
// Clear the user's session cookie

coderd/users_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func TestPostAPIKey(t *testing.T) {
129129
// Clear session token
130130
client.SessionToken = ""
131131
// ...and request an API key
132-
_, err := client.CreateApiKey(context.Background())
132+
_, err := client.CreateAPIKey(context.Background())
133133
var apiErr *codersdk.Error
134134
require.ErrorAs(t, err, &apiErr)
135135
require.Equal(t, http.StatusUnauthorized, apiErr.StatusCode())
@@ -139,7 +139,7 @@ func TestPostAPIKey(t *testing.T) {
139139
t.Parallel()
140140
client := coderdtest.New(t)
141141
_ = coderdtest.CreateInitialUser(t, client)
142-
apiKey, err := client.CreateApiKey(context.Background())
142+
apiKey, err := client.CreateAPIKey(context.Background())
143143
require.NotNil(t, apiKey)
144144
require.GreaterOrEqual(t, len(apiKey.Key), 2)
145145
require.NoError(t, err)

codersdk/projectimport_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ import (
55
"testing"
66
"time"
77

8+
"github.com/google/uuid"
9+
"github.com/stretchr/testify/require"
10+
811
"github.com/coder/coder/coderd"
912
"github.com/coder/coder/coderd/coderdtest"
1013
"github.com/coder/coder/provisioner/echo"
1114
"github.com/coder/coder/provisionersdk/proto"
12-
"github.com/google/uuid"
13-
"github.com/stretchr/testify/require"
1415
)
1516

1617
func TestCreateProjectImportJob(t *testing.T) {

codersdk/users.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ func (c *Client) CreateUser(ctx context.Context, req coderd.CreateUserRequest) (
5656
return user, json.NewDecoder(res.Body).Decode(&user)
5757
}
5858

59-
// CreateApiKey calls the /api-key API
60-
func (c *Client) CreateApiKey(ctx context.Context) (*coderd.GenerateAPIKeyResponse, error) {
61-
res, err := c.request(ctx, http.MethodPost, fmt.Sprintf("/api/v2/api-keys"), nil)
59+
// CreateAPIKey calls the /api-key API
60+
func (c *Client) CreateAPIKey(ctx context.Context) (*coderd.GenerateAPIKeyResponse, error) {
61+
res, err := c.request(ctx, http.MethodPost, "/api/v2/api-keys", nil)
6262
if err != nil {
6363
return nil, err
6464
}

0 commit comments

Comments
 (0)