Merge pull request #4401 from hashicorp/jefferai-linter-fixes
Fix linter warnings, parts 1 and 2
This commit is contained in:
91 files changed
+472
-411
No files matched your search
@@ -24,7 +24,6 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/util"
|
||||
"github.com/hashicorp/go-dbw"
|
||||
"github.com/hashicorp/nodeenrollment"
|
||||
nodee "github.com/hashicorp/nodeenrollment"
|
||||
"github.com/hashicorp/nodeenrollment/types"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"google.golang.org/protobuf/proto"
|
||||
@@ -32,7 +31,7 @@ import (
|
||||
|
||||
// Ensure we implement the Storage interfaces
|
||||
var (
|
||||
_ nodee.Storage = (*WorkerAuthRepositoryStorage)(nil)
|
||||
_ nodeenrollment.Storage = (*WorkerAuthRepositoryStorage)(nil)
|
||||
)
|
||||
|
||||
type rootCertificatesVersion struct {
|
||||
@@ -68,7 +67,7 @@ func NewRepositoryStorage(ctx context.Context, r db.Reader, w db.Writer, kms *km
|
||||
}
|
||||
|
||||
// Store implements the Storage interface
|
||||
func (r *WorkerAuthRepositoryStorage) Store(ctx context.Context, msg nodee.MessageWithId) error {
|
||||
func (r *WorkerAuthRepositoryStorage) Store(ctx context.Context, msg nodeenrollment.MessageWithId) error {
|
||||
const op = "server.(WorkerAuthRepositoryStorage).Store"
|
||||
if err := types.ValidateMessage(msg); err != nil {
|
||||
return errors.Wrap(ctx, err, op)
|
||||
@@ -426,7 +425,7 @@ func (r *WorkerAuthRepositoryStorage) storeRootCertificates(ctx context.Context,
|
||||
// Load implements the Storage interface.
|
||||
// Load loads values into the given message. The message must be populated
|
||||
// with the ID value. If not found, the returned error should be ErrNotFound.
|
||||
func (r *WorkerAuthRepositoryStorage) Load(ctx context.Context, msg nodee.MessageWithId) error {
|
||||
func (r *WorkerAuthRepositoryStorage) Load(ctx context.Context, msg nodeenrollment.MessageWithId) error {
|
||||
const op = "server.(WorkerAuthRepositoryStorage).Load"
|
||||
if err := types.ValidateMessage(msg); err != nil {
|
||||
return errors.Wrap(ctx, err, op)
|
||||
@@ -493,13 +492,13 @@ func (r *WorkerAuthRepositoryStorage) loadNodeInformation(ctx context.Context, n
|
||||
workerAuthorizedSet, err := r.validateWorkerAuths(ctx, workerAuths)
|
||||
if err != nil {
|
||||
if errors.IsNotFoundError(err) {
|
||||
return nodee.ErrNotFound
|
||||
return nodeenrollment.ErrNotFound
|
||||
}
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
|
||||
if workerAuthorizedSet == nil || workerAuthorizedSet.Current == nil {
|
||||
return nodee.ErrNotFound
|
||||
return nodeenrollment.ErrNotFound
|
||||
}
|
||||
|
||||
if workerAuthorizedSet.Previous != nil {
|
||||
@@ -566,7 +565,7 @@ func (r *WorkerAuthRepositoryStorage) loadServerLedActivationToken(ctx context.C
|
||||
err := r.reader.LookupWhere(ctx, activationTokenEntry, "token_id = ?", []any{token.Id})
|
||||
if err != nil {
|
||||
if errors.Is(err, dbw.ErrRecordNotFound) {
|
||||
return nodee.ErrNotFound
|
||||
return nodeenrollment.ErrNotFound
|
||||
}
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
@@ -663,7 +662,7 @@ func (r *WorkerAuthRepositoryStorage) loadRootCertificates(ctx context.Context,
|
||||
}
|
||||
err := r.reader.LookupById(ctx, certAuthority)
|
||||
if err != nil {
|
||||
return nodee.ErrNotFound
|
||||
return nodeenrollment.ErrNotFound
|
||||
}
|
||||
|
||||
// Add version to state field of cert
|
||||
@@ -687,7 +686,7 @@ func (r *WorkerAuthRepositoryStorage) loadRootCertificates(ctx context.Context,
|
||||
}
|
||||
|
||||
if rootCertificate.Certificate == nil {
|
||||
return nodee.ErrNotFound
|
||||
return nodeenrollment.ErrNotFound
|
||||
}
|
||||
|
||||
// decrypt private key
|
||||
@@ -719,7 +718,7 @@ func (r *WorkerAuthRepositoryStorage) loadRootCertificates(ctx context.Context,
|
||||
|
||||
// Remove implements the Storage interface.
|
||||
// Remove removes the given message. Only the ID field of the message is considered.
|
||||
func (r *WorkerAuthRepositoryStorage) Remove(ctx context.Context, msg nodee.MessageWithId) error {
|
||||
func (r *WorkerAuthRepositoryStorage) Remove(ctx context.Context, msg nodeenrollment.MessageWithId) error {
|
||||
const op = "server.(WorkerAuthRepositoryStorage).Remove"
|
||||
if err := types.ValidateMessage(msg); err != nil {
|
||||
return errors.New(ctx, errors.InvalidParameter, op, "given message cannot be removed as it has no ID")
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
wrapping "github.com/hashicorp/go-kms-wrapping/v2"
|
||||
"github.com/hashicorp/nodeenrollment"
|
||||
nodee "github.com/hashicorp/nodeenrollment"
|
||||
"github.com/hashicorp/nodeenrollment/registration"
|
||||
"github.com/hashicorp/nodeenrollment/rotation"
|
||||
"github.com/hashicorp/nodeenrollment/storage/file"
|
||||
@@ -201,7 +200,7 @@ func TestStoreWorkerAuth(t *testing.T) {
|
||||
Id: keyId,
|
||||
}
|
||||
err = storage.Load(ctx, nodeLookup)
|
||||
assert.Equal(err, nodee.ErrNotFound)
|
||||
assert.Equal(err, nodeenrollment.ErrNotFound)
|
||||
|
||||
// The AuthorizeNode request will result in a WorkerAuth record being stored
|
||||
_, err = registration.AuthorizeNode(ctx, storage, fetchReq, nodeenrollment.WithState(state))
|
||||
|
||||
@@ -89,7 +89,7 @@ func newRootCertificate(ctx context.Context, serialNumber uint64, certificate []
|
||||
) (*RootCertificate, error) {
|
||||
const op = "server.newRootCertificate"
|
||||
|
||||
if &serialNumber == nil {
|
||||
if serialNumber == 0 {
|
||||
return nil, errors.New(ctx, errors.InvalidParameter, op, "no serialNumber")
|
||||
}
|
||||
if certificate == nil || len(certificate) == 0 {
|
||||
@@ -146,7 +146,7 @@ func (r *RootCertificate) clone() *RootCertificate {
|
||||
// Validate the RootCertificate. On success, return nil
|
||||
func (r *RootCertificate) ValidateNewRootCertificate(ctx context.Context) error {
|
||||
const op = "server.(RootCertificate).ValidateNewRootCertificate"
|
||||
if &r.SerialNumber == nil {
|
||||
if r.SerialNumber == 0 {
|
||||
return errors.New(ctx, errors.InvalidParameter, op, "missing SerialNumber")
|
||||
}
|
||||
if r.Certificate == nil {
|
||||
|
||||
@@ -102,11 +102,12 @@ func newWorkerAuth(ctx context.Context, workerKeyIdentifier, workerId string, op
|
||||
},
|
||||
}
|
||||
|
||||
if &opts.withWorkerKeys != nil {
|
||||
if len(opts.withWorkerKeys.workerSigningPubKey) != 0 &&
|
||||
len(opts.withWorkerKeys.workerEncryptionPubKey) != 0 {
|
||||
l.WorkerSigningPubKey = opts.withWorkerKeys.workerSigningPubKey
|
||||
l.WorkerEncryptionPubKey = opts.withWorkerKeys.workerEncryptionPubKey
|
||||
}
|
||||
if &opts.withControllerEncryptionPrivateKey != nil {
|
||||
if len(opts.withControllerEncryptionPrivateKey) != 0 {
|
||||
l.ControllerEncryptionPrivKey = opts.withControllerEncryptionPrivateKey
|
||||
}
|
||||
if opts.withNonce != nil {
|
||||
|
||||
@@ -674,7 +674,7 @@ func TestRepository_WorkerTagsConsequent(t *testing.T) {
|
||||
assert.Contains(worker.apiTags, &Tag{Key: "key2", Value: "value2"})
|
||||
|
||||
// Add another valid tag to worker
|
||||
added, err = repo.AddWorkerTags(context.Background(), worker.PublicId, worker.Version, []*Tag{
|
||||
_, err = repo.AddWorkerTags(context.Background(), worker.PublicId, worker.Version, []*Tag{
|
||||
{Key: "key!", Value: "value!"},
|
||||
})
|
||||
assert.NoError(err)
|
||||
@@ -706,7 +706,7 @@ func TestRepository_WorkerTagsConsequent(t *testing.T) {
|
||||
assert.Equal(4, len(worker.configTags))
|
||||
|
||||
// Go full circle
|
||||
added, err = repo.AddWorkerTags(context.Background(), worker.PublicId, worker.Version, manyTags)
|
||||
_, err = repo.AddWorkerTags(context.Background(), worker.PublicId, worker.Version, manyTags)
|
||||
assert.NoError(err)
|
||||
worker, err = repo.LookupWorker(context.Background(), worker.PublicId)
|
||||
require.NoError(err)
|
||||
|
||||
Reference in new issue
Block a user