Skip to content

Commit e3dd4c0

Browse files
committed
make lint
1 parent a2b7935 commit e3dd4c0

File tree

8 files changed

+40
-14
lines changed

8 files changed

+40
-14
lines changed

coderd/database/dbauthz/dbauthz.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -911,8 +911,11 @@ func (q *querier) GetGitAuthLink(ctx context.Context, arg database.GetGitAuthLin
911911
return fetch(q.log, q.auth, q.db.GetGitAuthLink)(ctx, arg)
912912
}
913913

914-
func (q *querier) GetGitAuthLinksByUserID(_ context.Context, _ uuid.UUID) ([]database.GitAuthLink, error) {
915-
return nil, xerrors.Errorf("this is intentionally not implemented")
914+
func (q *querier) GetGitAuthLinksByUserID(ctx context.Context, userID uuid.UUID) ([]database.GitAuthLink, error) {
915+
if err := q.authorizeContext(ctx, rbac.ActionRead, rbac.ResourceSystem); err != nil {
916+
return nil, err
917+
}
918+
return q.db.GetGitAuthLinksByUserID(ctx, userID)
916919
}
917920

918921
func (q *querier) GetGitSSHKey(ctx context.Context, userID uuid.UUID) (database.GitSSHKey, error) {
@@ -1483,8 +1486,11 @@ func (q *querier) GetUserLinkByUserIDLoginType(ctx context.Context, arg database
14831486
return q.db.GetUserLinkByUserIDLoginType(ctx, arg)
14841487
}
14851488

1486-
func (q *querier) GetUserLinksByUserID(_ context.Context, _ uuid.UUID) ([]database.UserLink, error) {
1487-
return nil, xerrors.Errorf("this is intentionally not implemented")
1489+
func (q *querier) GetUserLinksByUserID(ctx context.Context, userID uuid.UUID) ([]database.UserLink, error) {
1490+
if err := q.authorizeContext(ctx, rbac.ActionRead, rbac.ResourceSystem); err != nil {
1491+
return nil, err
1492+
}
1493+
return q.db.GetUserLinksByUserID(ctx, userID)
14881494
}
14891495

14901496
func (q *querier) GetUsers(ctx context.Context, arg database.GetUsersParams) ([]database.GetUsersRow, error) {

coderd/database/dbfake/dbfake.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,8 +1403,16 @@ func (q *FakeQuerier) GetGitAuthLink(_ context.Context, arg database.GetGitAuthL
14031403
return database.GitAuthLink{}, sql.ErrNoRows
14041404
}
14051405

1406-
func (q *FakeQuerier) GetGitAuthLinksByUserID(_ context.Context, _ uuid.UUID) ([]database.GitAuthLink, error) {
1407-
panic("this is intentionally not implemented")
1406+
func (q *FakeQuerier) GetGitAuthLinksByUserID(_ context.Context, userID uuid.UUID) ([]database.GitAuthLink, error) {
1407+
q.mutex.RLock()
1408+
defer q.mutex.RUnlock()
1409+
gals := make([]database.GitAuthLink, 0)
1410+
for _, gal := range q.gitAuthLinks {
1411+
if gal.UserID == userID {
1412+
gals = append(gals, gal)
1413+
}
1414+
}
1415+
return gals, nil
14081416
}
14091417

14101418
func (q *FakeQuerier) GetGitSSHKey(_ context.Context, userID uuid.UUID) (database.GitSSHKey, error) {
@@ -2847,8 +2855,16 @@ func (q *FakeQuerier) GetUserLinkByUserIDLoginType(_ context.Context, params dat
28472855
return database.UserLink{}, sql.ErrNoRows
28482856
}
28492857

2850-
func (q *FakeQuerier) GetUserLinksByUserID(ctx context.Context, userID uuid.UUID) ([]database.UserLink, error) {
2851-
panic("this is intentionally not implemented")
2858+
func (q *FakeQuerier) GetUserLinksByUserID(_ context.Context, userID uuid.UUID) ([]database.UserLink, error) {
2859+
q.mutex.RLock()
2860+
defer q.mutex.RUnlock()
2861+
uls := make([]database.UserLink, 0)
2862+
for _, ul := range q.userLinks {
2863+
if ul.UserID == userID {
2864+
uls = append(uls, ul)
2865+
}
2866+
}
2867+
return uls, nil
28522868
}
28532869

28542870
func (q *FakeQuerier) GetUsers(_ context.Context, params database.GetUsersParams) ([]database.GetUsersRow, error) {

codersdk/deployment.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ type DeploymentValues struct {
154154
AgentFallbackTroubleshootingURL clibase.URL `json:"agent_fallback_troubleshooting_url,omitempty" typescript:",notnull"`
155155
BrowserOnly clibase.Bool `json:"browser_only,omitempty" typescript:",notnull"`
156156
SCIMAPIKey clibase.String `json:"scim_api_key,omitempty" typescript:",notnull"`
157-
ExternalTokenEncryptionKeys clibase.StringArray `json:"external_token_encryption_keys" typescript:",notnull"`
157+
ExternalTokenEncryptionKeys clibase.StringArray `json:"external_token_encryption_keys,omitempty" typescript:",notnull"`
158158
Provisioner ProvisionerConfig `json:"provisioner,omitempty" typescript:",notnull"`
159159
RateLimit RateLimitConfig `json:"rate_limit,omitempty" typescript:",notnull"`
160160
Experiments clibase.StringArray `json:"experiments,omitempty" typescript:",notnull"`

enterprise/cli/dbcrypt_rotate.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"golang.org/x/xerrors"
1919
)
2020

21-
func (r *RootCmd) dbcryptRotate() *clibase.Cmd {
21+
func (*RootCmd) dbcryptRotate() *clibase.Cmd {
2222
var (
2323
vals = new(codersdk.DeploymentValues)
2424
opts = vals.Options()
@@ -58,7 +58,7 @@ func (r *RootCmd) dbcryptRotate() *clibase.Cmd {
5858
if err != nil {
5959
return xerrors.Errorf("old key must be base64-encoded")
6060
}
61-
if bytes.Compare(newKey, oldKey) == 0 {
61+
if bytes.Equal(newKey, oldKey) {
6262
return xerrors.Errorf("old and new keys must be different")
6363
}
6464

@@ -126,7 +126,7 @@ func (r *RootCmd) dbcryptRotate() *clibase.Cmd {
126126
}
127127
logger.Info(ctx, "encrypted user tokens", slog.F("current", idx+1), slog.F("of", len(users)))
128128
}
129-
logger.Info(ctx, "operation completed successfully!")
129+
logger.Info(ctx, "operation completed successfully")
130130
return nil
131131
},
132132
}

enterprise/cli/dbcrypt_rotate_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import (
1818
"github.com/stretchr/testify/require"
1919
)
2020

21+
// nolint: paralleltest // use of t.Setenv
2122
func TestDBCryptRotate(t *testing.T) {
22-
//nolint: paralleltest // use of t.Setenv
2323
if !dbtestutil.WillUsePostgres() {
2424
t.Skip("this test requires a postgres instance")
2525
}

enterprise/dbcrypt/dbcrypt.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ func New(ctx context.Context, db database.Store, cs *Ciphers) (database.Store, e
8181
ciphers: cs,
8282
Store: db,
8383
}
84+
// nolint: gocritic // This is allowed.
8485
if err := ensureEncrypted(dbauthz.AsSystemRestricted(ctx), dbc); err != nil {
8586
return nil, xerrors.Errorf("ensure encrypted database fields: %w", err)
8687
}

enterprise/dbcrypt/dbcrypt_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ func TestNew(t *testing.T) {
150150
t.Parallel()
151151

152152
t.Run("OK", func(t *testing.T) {
153+
t.Parallel()
153154
// Given: a cipher is loaded
154155
cipher := dbcrypt.NewCiphers(initCipher(t))
155156
ctx, cancel := context.WithCancel(context.Background())
@@ -172,6 +173,7 @@ func TestNew(t *testing.T) {
172173
})
173174

174175
t.Run("NoCipher", func(t *testing.T) {
176+
t.Parallel()
175177
// Given: no cipher is loaded
176178
ctx, cancel := context.WithCancel(context.Background())
177179
t.Cleanup(cancel)
@@ -189,6 +191,7 @@ func TestNew(t *testing.T) {
189191
})
190192

191193
t.Run("CipherChanged", func(t *testing.T) {
194+
t.Parallel()
192195
// Given: no cipher is loaded
193196
ctx, cancel := context.WithCancel(context.Background())
194197
t.Cleanup(cancel)

site/src/api/typesGenerated.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)