mirror of
https://github.com/coder/coder.git
synced 2025-07-13 21:36:50 +00:00
chore: upgrade golangci-lint to v1.46.0 (#1373)
This commit is contained in:
@ -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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user