all: fix linting issues

Change-Id: Idfc93948e59a181321d79b365e638d63e256a16f
This commit is contained in:
Egon Elbre 2022-03-21 16:48:03 +02:00
parent 2a10b2fd14
commit 0d2d59f884
22 changed files with 52 additions and 20 deletions

View File

@ -1,6 +1,7 @@
// Copyright (C) 2019 Storj Labs, Inc. // Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information. // See LICENSE for copying information.
//go:build ignore
// +build ignore // +build ignore
package main package main

View File

@ -1,6 +1,7 @@
// Copyright (C) 2020 Storj Labs, Inc. // Copyright (C) 2020 Storj Labs, Inc.
// See LICENSE for copying information. // See LICENSE for copying information.
//go:build windows && !unittest
// +build windows,!unittest // +build windows,!unittest
package main package main

View File

@ -7,6 +7,7 @@
// //
// sc.exe create storagenode-updater binpath= "C:\Users\MyUser\storagenode-updater.exe run ..." // sc.exe create storagenode-updater binpath= "C:\Users\MyUser\storagenode-updater.exe run ..."
//go:build windows
// +build windows // +build windows
package main package main

View File

@ -1,6 +1,7 @@
// Copyright (C) 2020 Storj Labs, Inc. // Copyright (C) 2020 Storj Labs, Inc.
// See LICENSE for copying information. // See LICENSE for copying information.
//go:build linux && service
// +build linux,service // +build linux,service
package main package main

View File

@ -1,6 +1,7 @@
// Copyright (C) 2020 Storj Labs, Inc. // Copyright (C) 2020 Storj Labs, Inc.
// See LICENSE for copying information. // See LICENSE for copying information.
//go:build windows && service
// +build windows,service // +build windows,service
package main package main

View File

@ -61,7 +61,7 @@ func (m *service) Execute(args []string, r <-chan svc.ChangeRequest, changes cha
process.Exec(rootCmd) process.Exec(rootCmd)
return nil return nil
}) })
defer group.Wait() defer func() { _ = group.Wait() }()
changes <- svc.Status{State: svc.Running, Accepts: cmdsAccepted} changes <- svc.Status{State: svc.Running, Accepts: cmdsAccepted}

View File

@ -1,6 +1,7 @@
// Copyright (C) 2019 Storj Labs, Inc. // Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information. // See LICENSE for copying information.
//go:build ignore
// +build ignore // +build ignore
package main package main

View File

@ -1,6 +1,7 @@
// Copyright (C) 2019 Storj Labs, Inc. // Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information. // See LICENSE for copying information.
//go:build ignore
// +build ignore // +build ignore
package main package main

View File

@ -1,6 +1,7 @@
// Copyright (C) 2019 Storj Labs, Inc. // Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information. // See LICENSE for copying information.
//go:build ignore
// +build ignore // +build ignore
package main package main

View File

@ -75,7 +75,9 @@ func TestAdminOAuthAPI(t *testing.T) {
body := "" body := ""
if testCase.request != nil { if testCase.request != nil {
if data, _ := json.Marshal(testCase.request); len(data) > 0 { data, err := json.Marshal(testCase.request)
require.NoError(t, err)
if len(data) > 0 {
body = string(data) body = string(data)
} }
} }

View File

@ -1,4 +1,6 @@
//go:build js && wasm
// +build js,wasm // +build js,wasm
// Copyright (C) 2020 Storj Labs, Inc. // Copyright (C) 2020 Storj Labs, Inc.
// See LICENSE for copying information. // See LICENSE for copying information.

View File

@ -1,6 +1,7 @@
// Copyright (C) 2019 Storj Labs, Inc. // Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information. // See LICENSE for copying information.
//go:build ignore
// +build ignore // +build ignore
package main package main

View File

@ -12,12 +12,15 @@ import (
"storj.io/common/uuid" "storj.io/common/uuid"
) )
// clientStore provides a simple adapter for the oauth implementation. // ClientStore provides a simple adapter for the oauth implementation.
type clientStore struct { type ClientStore struct {
clients OAuthClients clients OAuthClients
} }
func (c *clientStore) GetByID(ctx context.Context, id string) (oauth2.ClientInfo, error) { var _ oauth2.ClientStore = (*ClientStore)(nil)
// GetByID returns client information by id.
func (c *ClientStore) GetByID(ctx context.Context, id string) (oauth2.ClientInfo, error) {
uid, err := uuid.FromString(id) uid, err := uuid.FromString(id)
if err != nil { if err != nil {
return nil, err return nil, err
@ -26,13 +29,16 @@ func (c *clientStore) GetByID(ctx context.Context, id string) (oauth2.ClientInfo
return c.clients.Get(ctx, uid) return c.clients.Get(ctx, uid)
} }
// tokenStore provides a simple adapter for the oauth implementation. // TokenStore provides a simple adapter for the oauth implementation.
type tokenStore struct { type TokenStore struct {
codes OAuthCodes codes OAuthCodes
tokens OAuthTokens tokens OAuthTokens
} }
func (t *tokenStore) Create(ctx context.Context, info oauth2.TokenInfo) (err error) { var _ oauth2.TokenStore = (*TokenStore)(nil)
// Create creates a new token with the given info.
func (t *TokenStore) Create(ctx context.Context, info oauth2.TokenInfo) (err error) {
var code OAuthCode var code OAuthCode
var access, refresh OAuthToken var access, refresh OAuthToken
@ -108,19 +114,23 @@ func (t *tokenStore) Create(ctx context.Context, info oauth2.TokenInfo) (err err
return nil return nil
} }
func (t *tokenStore) RemoveByCode(ctx context.Context, code string) error { // RemoveByCode deletes token by authorization code.
func (t *TokenStore) RemoveByCode(ctx context.Context, code string) error {
return t.codes.Claim(ctx, code) return t.codes.Claim(ctx, code)
} }
func (t *tokenStore) RemoveByAccess(ctx context.Context, access string) error { // RemoveByAccess deletes token by access token.
func (t *TokenStore) RemoveByAccess(ctx context.Context, access string) error {
return nil // unsupported by current configuration return nil // unsupported by current configuration
} }
func (t *tokenStore) RemoveByRefresh(ctx context.Context, refresh string) error { // RemoveByRefresh deletes token by refresh token.
func (t *TokenStore) RemoveByRefresh(ctx context.Context, refresh string) error {
return nil // unsupported by current configuration return nil // unsupported by current configuration
} }
func (t *tokenStore) GetByCode(ctx context.Context, code string) (oauth2.TokenInfo, error) { // GetByCode uses authorization code to find token information.
func (t *TokenStore) GetByCode(ctx context.Context, code string) (oauth2.TokenInfo, error) {
oauthCode, err := t.codes.Get(ctx, code) oauthCode, err := t.codes.Get(ctx, code)
if err != nil { if err != nil {
return nil, err return nil, err
@ -129,7 +139,8 @@ func (t *tokenStore) GetByCode(ctx context.Context, code string) (oauth2.TokenIn
return &record{code: oauthCode}, nil return &record{code: oauthCode}, nil
} }
func (t *tokenStore) GetByAccess(ctx context.Context, access string) (oauth2.TokenInfo, error) { // GetByAccess uses access token to find token information.
func (t *TokenStore) GetByAccess(ctx context.Context, access string) (oauth2.TokenInfo, error) {
oauthToken, err := t.tokens.Get(ctx, KindAccessToken, access) oauthToken, err := t.tokens.Get(ctx, KindAccessToken, access)
if err != nil { if err != nil {
return nil, err return nil, err
@ -138,7 +149,8 @@ func (t *tokenStore) GetByAccess(ctx context.Context, access string) (oauth2.Tok
return &record{access: oauthToken}, nil return &record{access: oauthToken}, nil
} }
func (t *tokenStore) GetByRefresh(ctx context.Context, refresh string) (oauth2.TokenInfo, error) { // GetByRefresh uses refresh token to find token information.
func (t *TokenStore) GetByRefresh(ctx context.Context, refresh string) (oauth2.TokenInfo, error) {
oauthToken, err := t.tokens.Get(ctx, KindRefreshToken, refresh) oauthToken, err := t.tokens.Get(ctx, KindRefreshToken, refresh)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -18,15 +18,15 @@ type Service struct {
} }
// ClientStore returns a store used to lookup oauth clients from the consent flow. // ClientStore returns a store used to lookup oauth clients from the consent flow.
func (s *Service) ClientStore() *clientStore { func (s *Service) ClientStore() *ClientStore {
return &clientStore{ return &ClientStore{
clients: s.store.OAuthClients(), clients: s.store.OAuthClients(),
} }
} }
// TokenStore returns a store used to manage access tokens during the consent flow. // TokenStore returns a store used to manage access tokens during the consent flow.
func (s *Service) TokenStore() *tokenStore { func (s *Service) TokenStore() *TokenStore {
return &tokenStore{ return &TokenStore{
codes: s.store.OAuthCodes(), codes: s.store.OAuthCodes(),
tokens: s.store.OAuthTokens(), tokens: s.store.OAuthTokens(),
} }

View File

@ -1,7 +1,8 @@
// Copyright (C) 2021 Storj Labs, Inc. // Copyright (C) 2021 Storj Labs, Inc.
// See LICENSE for copying information. // See LICENSE for copying information.
//+build ignore //go:build ignore
// +build ignore
package main package main

View File

@ -84,7 +84,7 @@ func loadSnapshots(ctx context.Context, connstr, dbxscript string) (*dbschema.Sn
if err != nil { if err != nil {
var pgErr *pgconn.PgError var pgErr *pgconn.PgError
if errors.As(err, &pgErr) { if errors.As(err, &pgErr) {
return fmt.Errorf("Version %d error: %v\nDetail: %s\nHint: %s", version, pgErr, pgErr.Detail, pgErr.Hint) return fmt.Errorf("Version %d error: %w\nDetail: %s\nHint: %s", version, pgErr, pgErr.Detail, pgErr.Hint)
} }
return fmt.Errorf("Version %d error: %w", version, err) return fmt.Errorf("Version %d error: %w", version, err)
} }

View File

@ -1,6 +1,7 @@
// Copyright (C) 2019 Storj Labs, Inc. // Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information. // See LICENSE for copying information.
//go:build ignore
// +build ignore // +build ignore
package main package main

View File

@ -1,6 +1,7 @@
// Copyright (C) 2019 Storj Labs, Inc. // Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information. // See LICENSE for copying information.
//go:build ignore
// +build ignore // +build ignore
// Tests whether the uplink tool correctly times out when one of the storage nodes it's talking to // Tests whether the uplink tool correctly times out when one of the storage nodes it's talking to

View File

@ -1,6 +1,7 @@
// Copyright (C) 2020 Storj Labs, Inc. // Copyright (C) 2020 Storj Labs, Inc.
// See LICENSE for copying information. // See LICENSE for copying information.
//go:build ignore
// +build ignore // +build ignore
package main package main

View File

@ -1,6 +1,7 @@
// Copyright (C) 2019 Storj Labs, Inc. // Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information. // See LICENSE for copying information.
//go:build windows
// +build windows // +build windows
package filestore package filestore

View File

@ -1,6 +1,7 @@
// Copyright (C) 2019 Storj Labs, Inc. // Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information. // See LICENSE for copying information.
//go:build ignore
// +build ignore // +build ignore
package main package main

View File

@ -1,6 +1,7 @@
// Copyright (C) 2020 Storj Labs, Inc. // Copyright (C) 2020 Storj Labs, Inc.
// See LICENSE for copying information. // See LICENSE for copying information.
//go:build ignore
// +build ignore // +build ignore
package main package main