mirror of https://github.com/coder/coder.git
chore: upgrade golangci-lint to v1.46.0 (#1373)
This commit is contained in:
parent
e0a7aec228
commit
97a95f1377
|
@ -42,7 +42,7 @@ jobs:
|
|||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v3.1.0
|
||||
with:
|
||||
version: v1.45.2
|
||||
version: v1.46.0
|
||||
|
||||
style-lint-typescript:
|
||||
name: "style/lint/typescript"
|
||||
|
|
|
@ -77,7 +77,7 @@ linters-settings:
|
|||
# - sloppyReassign
|
||||
- sloppyTypeAssert
|
||||
- sortSlice
|
||||
# - sprintfQuotedString
|
||||
- sprintfQuotedString
|
||||
- sqlQuery
|
||||
# - stringConcatSimplify
|
||||
# - stringXbytes
|
||||
|
@ -105,6 +105,13 @@ linters-settings:
|
|||
failOn: all
|
||||
rules: rules.go
|
||||
|
||||
staticcheck:
|
||||
# https://staticcheck.io/docs/options#checks
|
||||
# We disable SA1019 because it gets angry about our usage of xerrors. We
|
||||
# intentionally xerrors because stack frame support didn't make it into the
|
||||
# stdlib port.
|
||||
checks: ["all", "-SA1019"]
|
||||
|
||||
goimports:
|
||||
local-prefixes: coder.com,cdr.dev,go.coder.com,github.com/cdr,github.com/coder
|
||||
|
||||
|
@ -235,7 +242,7 @@ linters:
|
|||
# without testing any exported functions. This is enabled to promote
|
||||
# decomposing a package before testing it's internals. A function caller
|
||||
# should be able to test most of the functionality from exported functions.
|
||||
#
|
||||
#
|
||||
# There are edge-cases to this rule, but they should be carefully considered
|
||||
# to avoid structural inconsistency.
|
||||
- testpackage
|
||||
|
|
|
@ -60,7 +60,7 @@ func TestGitSSH(t *testing.T) {
|
|||
|
||||
// start workspace agent
|
||||
cmd, root := clitest.New(t, "agent", "--agent-token", agentToken, "--agent-url", client.URL.String())
|
||||
agentClient := &*client
|
||||
agentClient := client
|
||||
clitest.SetupConfig(t, agentClient, root)
|
||||
ctx, cancelFunc := context.WithCancel(context.Background())
|
||||
defer cancelFunc()
|
||||
|
|
31
cli/ssh.go
31
cli/ssh.go
|
@ -3,10 +3,8 @@ package cli
|
|||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/mattn/go-isatty"
|
||||
|
@ -181,32 +179,3 @@ func ssh() *cobra.Command {
|
|||
|
||||
return cmd
|
||||
}
|
||||
|
||||
type stdioConn struct {
|
||||
io.Reader
|
||||
io.Writer
|
||||
}
|
||||
|
||||
func (*stdioConn) Close() (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*stdioConn) LocalAddr() net.Addr {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*stdioConn) RemoteAddr() net.Addr {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*stdioConn) SetDeadline(_ time.Time) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*stdioConn) SetReadDeadline(_ time.Time) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*stdioConn) SetWriteDeadline(_ time.Time) error {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -31,20 +31,7 @@ func (b *postgresBackend) Decision() audit.FilterDecision {
|
|||
}
|
||||
|
||||
func (b *postgresBackend) Export(ctx context.Context, alog database.AuditLog) error {
|
||||
_, err := b.db.InsertAuditLog(ctx, database.InsertAuditLogParams{
|
||||
ID: alog.ID,
|
||||
Time: alog.Time,
|
||||
UserID: alog.UserID,
|
||||
OrganizationID: alog.OrganizationID,
|
||||
Ip: alog.Ip,
|
||||
UserAgent: alog.UserAgent,
|
||||
ResourceType: alog.ResourceType,
|
||||
ResourceID: alog.ResourceID,
|
||||
ResourceTarget: alog.ResourceTarget,
|
||||
Action: alog.Action,
|
||||
Diff: alog.Diff,
|
||||
StatusCode: alog.StatusCode,
|
||||
})
|
||||
_, err := b.db.InsertAuditLog(ctx, database.InsertAuditLogParams(alog))
|
||||
if err != nil {
|
||||
return xerrors.Errorf("insert audit log: %w", err)
|
||||
}
|
||||
|
|
|
@ -77,9 +77,9 @@ func New(t *testing.T, options *Options) *codersdk.Client {
|
|||
db := databasefake.New()
|
||||
pubsub := database.NewPubsubInMemory()
|
||||
if os.Getenv("DB") != "" {
|
||||
connectionURL, close, err := postgres.Open()
|
||||
connectionURL, closePg, err := postgres.Open()
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(close)
|
||||
t.Cleanup(closePg)
|
||||
sqlDB, err := sql.Open("postgres", connectionURL)
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() {
|
||||
|
|
|
@ -1733,20 +1733,7 @@ func (q *fakeQuerier) InsertAuditLog(_ context.Context, arg database.InsertAudit
|
|||
q.mutex.Lock()
|
||||
defer q.mutex.Unlock()
|
||||
|
||||
alog := database.AuditLog{
|
||||
ID: arg.ID,
|
||||
Time: arg.Time,
|
||||
UserID: arg.UserID,
|
||||
OrganizationID: arg.OrganizationID,
|
||||
Ip: arg.Ip,
|
||||
UserAgent: arg.UserAgent,
|
||||
ResourceType: arg.ResourceType,
|
||||
ResourceID: arg.ResourceID,
|
||||
ResourceTarget: arg.ResourceTarget,
|
||||
Action: arg.Action,
|
||||
Diff: arg.Diff,
|
||||
StatusCode: arg.StatusCode,
|
||||
}
|
||||
alog := database.AuditLog(arg)
|
||||
|
||||
q.auditLogs = append(q.auditLogs, alog)
|
||||
slices.SortFunc(q.auditLogs, func(a, b database.AuditLog) bool {
|
||||
|
|
|
@ -6,12 +6,11 @@ import (
|
|||
"database/sql"
|
||||
"testing"
|
||||
|
||||
_ "github.com/lib/pq"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.uber.org/goleak"
|
||||
|
||||
"github.com/coder/coder/coderd/database/postgres"
|
||||
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
|
@ -26,9 +25,9 @@ func TestPostgres(t *testing.T) {
|
|||
return
|
||||
}
|
||||
|
||||
connect, close, err := postgres.Open()
|
||||
connect, closePg, err := postgres.Open()
|
||||
require.NoError(t, err)
|
||||
defer close()
|
||||
defer closePg()
|
||||
db, err := sql.Open("postgres", connect)
|
||||
require.NoError(t, err)
|
||||
err = db.Ping()
|
||||
|
|
|
@ -27,9 +27,9 @@ func TestPubsub(t *testing.T) {
|
|||
ctx, cancelFunc := context.WithCancel(context.Background())
|
||||
defer cancelFunc()
|
||||
|
||||
connectionURL, close, err := postgres.Open()
|
||||
connectionURL, closePg, err := postgres.Open()
|
||||
require.NoError(t, err)
|
||||
defer close()
|
||||
defer closePg()
|
||||
db, err := sql.Open("postgres", connectionURL)
|
||||
require.NoError(t, err)
|
||||
defer db.Close()
|
||||
|
@ -56,9 +56,9 @@ func TestPubsub(t *testing.T) {
|
|||
t.Parallel()
|
||||
ctx, cancelFunc := context.WithCancel(context.Background())
|
||||
defer cancelFunc()
|
||||
connectionURL, close, err := postgres.Open()
|
||||
connectionURL, closePg, err := postgres.Open()
|
||||
require.NoError(t, err)
|
||||
defer close()
|
||||
defer closePg()
|
||||
db, err := sql.Open("postgres", connectionURL)
|
||||
require.NoError(t, err)
|
||||
defer db.Close()
|
||||
|
|
|
@ -48,7 +48,7 @@ func ExtractOAuth2(config OAuth2Config) func(http.Handler) http.Handler {
|
|||
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
|
||||
if config == nil {
|
||||
httpapi.Write(rw, http.StatusPreconditionRequired, httpapi.Response{
|
||||
Message: fmt.Sprintf("The oauth2 method requested is not configured!"),
|
||||
Message: "The oauth2 method requested is not configured!",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package coderd
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
@ -29,7 +28,7 @@ func (api *api) putMemberRoles(rw http.ResponseWriter, r *http.Request) {
|
|||
// the selected organization. Until then, allow anarchy
|
||||
if apiKey.UserID != user.ID {
|
||||
httpapi.Write(rw, http.StatusUnauthorized, httpapi.Response{
|
||||
Message: fmt.Sprintf("modifying other users is not supported at this time"),
|
||||
Message: "modifying other users is not supported at this time",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ func (a RegoAuthorizer) Authorize(ctx context.Context, subjectID string, roles [
|
|||
|
||||
results, err := a.query.Eval(ctx, rego.EvalInput(input))
|
||||
if err != nil {
|
||||
return ForbiddenWithInternal(xerrors.Errorf("eval rego: %w, err"), input, results)
|
||||
return ForbiddenWithInternal(xerrors.Errorf("eval rego: %w", err), input, results)
|
||||
}
|
||||
|
||||
if len(results) != 1 {
|
||||
|
|
|
@ -58,7 +58,7 @@ func (api *api) userOAuth2Github(rw http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
if selectedMembership == nil {
|
||||
httpapi.Write(rw, http.StatusUnauthorized, httpapi.Response{
|
||||
Message: fmt.Sprintf("You aren't a member of the authorized Github organizations!"),
|
||||
Message: "You aren't a member of the authorized Github organizations!",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
|
|
@ -266,7 +266,7 @@ func (api *api) putUserProfile(rw http.ResponseWriter, r *http.Request) {
|
|||
})
|
||||
}
|
||||
httpapi.Write(rw, http.StatusConflict, httpapi.Response{
|
||||
Message: fmt.Sprintf("user already exists"),
|
||||
Message: "user already exists",
|
||||
Errors: responseErrors,
|
||||
})
|
||||
return
|
||||
|
@ -391,7 +391,7 @@ func (api *api) putUserRoles(rw http.ResponseWriter, r *http.Request) {
|
|||
apiKey := httpmw.APIKey(r)
|
||||
if apiKey.UserID != user.ID {
|
||||
httpapi.Write(rw, http.StatusUnauthorized, httpapi.Response{
|
||||
Message: fmt.Sprintf("modifying other users is not supported at this time"),
|
||||
Message: "modifying other users is not supported at this time",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
|
|
@ -213,7 +213,7 @@ func (api *api) postWorkspaceBuilds(rw http.ResponseWriter, r *http.Request) {
|
|||
return xerrors.Errorf("insert provisioner job: %w", err)
|
||||
}
|
||||
state := createBuild.ProvisionerState
|
||||
if state == nil || len(state) == 0 {
|
||||
if len(state) == 0 {
|
||||
state = priorHistory.ProvisionerState
|
||||
}
|
||||
|
||||
|
|
|
@ -307,7 +307,7 @@ func (c *Client) userByIdentifier(ctx context.Context, ident string) (User, erro
|
|||
// Users returns all users according to the request parameters. If no parameters are set,
|
||||
// the default behavior is to return all users in a single page.
|
||||
func (c *Client) Users(ctx context.Context, req UsersRequest) ([]User, error) {
|
||||
res, err := c.request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/users"), nil,
|
||||
res, err := c.request(ctx, http.MethodGet, "/api/v2/users", nil,
|
||||
req.Pagination.asRequestOption(),
|
||||
func(r *http.Request) {
|
||||
q := r.URL.Query()
|
||||
|
|
|
@ -176,7 +176,7 @@ func (g *Generator) generateAll() (*TypescriptTypes, error) {
|
|||
st, _ := obj.Type().Underlying().(*types.Struct)
|
||||
codeBlock, err := g.buildStruct(obj, st)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("generate %q: %w", obj.Name())
|
||||
return nil, xerrors.Errorf("generate %q: %w", obj.Name(), err)
|
||||
}
|
||||
structs[obj.Name()] = codeBlock
|
||||
case *types.Basic:
|
||||
|
|
|
@ -75,7 +75,7 @@ func main() {
|
|||
"service": "coder",
|
||||
"_dd.cireport_version": "2",
|
||||
|
||||
"test.traits": fmt.Sprintf(`{"database":["%s"], "category":["%s"]}`,
|
||||
"test.traits": fmt.Sprintf(`{"database":[%q], "category":[%q]}`,
|
||||
os.Getenv("DD_DATABASE"), os.Getenv("DD_CATEGORY")),
|
||||
|
||||
// Additional tags found in DataDog docs. See:
|
||||
|
|
Loading…
Reference in New Issue