Skip to content

Commit

Permalink
golangci-lint: add nilerr & address issues
Browse files Browse the repository at this point in the history
Signed-off-by: Carlo Teubner <[email protected]>
  • Loading branch information
c4rlo committed Dec 20, 2024
1 parent 6928ff1 commit 032831f
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ linters:
- gosec
- misspell
- nakedret
- nilerr
- unconvert
- unparam
- whitespace
Expand Down
2 changes: 1 addition & 1 deletion pkg/common/container/process/winapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (a *api) QuerySystemExtendedHandleInformation() ([]SystemHandleInformationE
handlesList := (*SystemExtendedHandleInformation)(unsafe.Pointer(&buffer[0]))
handles := unsafe.Slice(&handlesList.Handles[0], int(handlesList.NumberOfHandles))

return handles, nil
return handles, nil //nolint:nilerr
}

return nil, status
Expand Down
2 changes: 1 addition & 1 deletion pkg/common/plugin/facade.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (f *Facade) InitLog(log logrus.FieldLogger) {
// that come out of plugin implementations.
func (f *Facade) WrapErr(err error) error {
if err == nil {
return err
return nil
}

// Embellish the gRPC status with the prefix, if necessary.
Expand Down
2 changes: 1 addition & 1 deletion pkg/common/telemetry/statsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func newStatsdRunner(c *MetricsConfig) (sinkRunner, error) {
for _, sc := range c.FileConfig.Statsd {
sink, err := metrics.NewStatsdSink(sc.Address)
if err != nil {
return runner, nil
return nil, err
}

runner.loadedSinks = append(runner.loadedSinks, sink)
Expand Down
2 changes: 1 addition & 1 deletion pkg/server/plugin/keymanager/awskms/awskms.go
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ func (p *Plugin) createDefaultPolicy(ctx context.Context) (*string, error) {
roleName, err := roleNameFromARN(*result.Arn)
if err != nil {
// the server has not assumed any role, use default KMS policy and log a warn message
p.log.Warn("In a future version of SPIRE, it will be mandatory for the SPIRE servers to assume an AWS IAM Role when using the default AWS KMS key policy. Please assign an IAM role to this SPIRE Server instance.")
p.log.Warn("In a future version of SPIRE, it will be mandatory for the SPIRE servers to assume an AWS IAM Role when using the default AWS KMS key policy. Please assign an IAM role to this SPIRE Server instance.", reasonTag, err)
return nil, nil
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/server/plugin/keymanager/awskms/awskms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,7 @@ func TestGenerateKey(t *testing.T) {
{
Level: logrus.WarnLevel,
Message: "In a future version of SPIRE, it will be mandatory for the SPIRE servers to assume an AWS IAM Role when using the default AWS KMS key policy. Please assign an IAM role to this SPIRE Server instance.",
Data: logrus.Fields{reasonTag: `incomplete resource, expected 'resource-type/resource-id' but got "example-account-id"`},
},
},
},
Expand All @@ -734,6 +735,7 @@ func TestGenerateKey(t *testing.T) {
{
Level: logrus.WarnLevel,
Message: "In a future version of SPIRE, it will be mandatory for the SPIRE servers to assume an AWS IAM Role when using the default AWS KMS key policy. Please assign an IAM role to this SPIRE Server instance.",
Data: logrus.Fields{reasonTag: `arn does not contain an assumed role: "arn:aws:sts::example-account-id:user/development"`},
},
},
},
Expand Down

0 comments on commit 032831f

Please sign in to comment.