mirror of
https://github.com/coder/coder.git
synced 2026-10-29 17:44:33 +08:00
chore: Fix golangci-lint configuration and patch errors (#34)
* chore: Fix golangci-lint configuration and patch errors Due to misconfiguration of a linting rules directory, our linter has not been working properly. This change fixes the configuration issue, and all remaining linting errors. * Fix race in peer logging * Fix race and return * Lock on bufferred amount low * Fix mutex lock
This commit is contained in:
+5
-5
@@ -18,9 +18,9 @@ import (
|
||||
)
|
||||
|
||||
// New creates a Coder client for the provided URL.
|
||||
func New(url *url.URL) *Client {
|
||||
func New(serverURL *url.URL) *Client {
|
||||
return &Client{
|
||||
url: url,
|
||||
url: serverURL,
|
||||
httpClient: &http.Client{},
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ func (c *Client) SetSessionToken(token string) error {
|
||||
// request performs an HTTP request with the body provided.
|
||||
// The caller is responsible for closing the response body.
|
||||
func (c *Client) request(ctx context.Context, method, path string, body interface{}) (*http.Response, error) {
|
||||
url, err := c.url.Parse(path)
|
||||
serverURL, err := c.url.Parse(path)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("parse url: %w", err)
|
||||
}
|
||||
@@ -65,7 +65,7 @@ func (c *Client) request(ctx context.Context, method, path string, body interfac
|
||||
}
|
||||
}
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, method, url.String(), &buf)
|
||||
req, err := http.NewRequestWithContext(ctx, method, serverURL.String(), &buf)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("create request: %w", err)
|
||||
}
|
||||
@@ -81,7 +81,7 @@ func (c *Client) request(ctx context.Context, method, path string, body interfac
|
||||
}
|
||||
|
||||
// readBodyAsError reads the response as an httpapi.Message, and
|
||||
// wraps it in a codersdk.Error type for easy marshalling.
|
||||
// wraps it in a codersdk.Error type for easy marshaling.
|
||||
func readBodyAsError(res *http.Response) error {
|
||||
var m httpapi.Response
|
||||
err := json.NewDecoder(res.Body).Decode(&m)
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ func (c *Client) CreateInitialUser(ctx context.Context, req coderd.CreateUserReq
|
||||
|
||||
// User returns a user for the ID provided.
|
||||
// If the ID string is empty, the current user will be returned.
|
||||
func (c *Client) User(ctx context.Context, id string) (coderd.User, error) {
|
||||
func (c *Client) User(ctx context.Context, _ string) (coderd.User, error) {
|
||||
res, err := c.request(ctx, http.MethodGet, "/api/v2/user", nil)
|
||||
if err != nil {
|
||||
return coderd.User{}, err
|
||||
|
||||
@@ -5,10 +5,11 @@ import (
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/coder/coder/coderd"
|
||||
"github.com/coder/coder/coderd/coderdtest"
|
||||
"github.com/coder/coder/codersdk"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestUsers(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user