mirror of
https://dev.azure.com/schwarzit/schwarzit.stackit-public/_git/audit-go
synced 2026-02-08 00:57:24 +00:00
Fix linter issues
This commit is contained in:
parent
a509aae2a6
commit
85f07ec14a
5 changed files with 12 additions and 19 deletions
|
|
@ -144,7 +144,7 @@ buf generate --include-imports
|
|||
|
||||
##### Build library
|
||||
```bash
|
||||
go mod download && go mod tidy && go get ./... && go fmt ./... && go vet ./... && go build ./... && go test ./...
|
||||
go mod download && go mod tidy && go get ./... && go fmt ./... && go vet ./... && golangci-lint run && go build ./... && go test ./...
|
||||
```
|
||||
|
||||
#### Register buf validation schema in IntelliJ / Goland
|
||||
|
|
|
|||
|
|
@ -229,11 +229,9 @@ func (a *LegacyAuditApi) convertAndSerializeIntoLegacyFormat(
|
|||
} else {
|
||||
return nil, ErrUnsupportedObjectIdentifierType
|
||||
}
|
||||
break
|
||||
case *auditV1.RoutableAuditEvent_ObjectName:
|
||||
eventType = "SYSTEM_EVENT"
|
||||
messageContext = nil
|
||||
break
|
||||
default:
|
||||
return nil, ErrUnsupportedResourceReferenceType
|
||||
}
|
||||
|
|
|
|||
|
|
@ -410,15 +410,12 @@ func validateProtobufMessagePayload(
|
|||
if objectIdentifier.Type == auditV1.ObjectType_OBJECT_TYPE_ORGANIZATION {
|
||||
assert.Equal(t, routingIdentifier.Identifier.String(), reference.ObjectIdentifier.Identifier)
|
||||
}
|
||||
break
|
||||
case RoutingIdentifierTypeProject:
|
||||
assert.Equal(t, routingIdentifier.Identifier.String(), reference.ObjectIdentifier.Identifier)
|
||||
assert.Equal(t, auditV1.ObjectType_OBJECT_TYPE_PROJECT, reference.ObjectIdentifier.Type)
|
||||
break
|
||||
default:
|
||||
assert.Fail(t, "Routing identifier type not expected")
|
||||
}
|
||||
break
|
||||
case *auditV1.RoutableAuditEvent_ObjectName:
|
||||
assert.Nil(t, objectIdentifier)
|
||||
assert.Nil(t, routingIdentifier)
|
||||
|
|
@ -431,7 +428,6 @@ func validateProtobufMessagePayload(
|
|||
switch data := routableAuditEvent.Data.(type) {
|
||||
case *auditV1.RoutableAuditEvent_UnencryptedData:
|
||||
assert.NoError(t, proto.Unmarshal(data.UnencryptedData.Data, &auditEvent))
|
||||
break
|
||||
default:
|
||||
assert.Fail(t, "Encrypted data not expected")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ func (a *AmqpMessagingApi) Send(ctx context.Context, topic string, data []byte,
|
|||
}
|
||||
|
||||
// Drop the current sender, as it cannot connect to the broker anymore
|
||||
slog.Error("message sender error, recreating", err)
|
||||
slog.Error("message sender error, recreating", slog.Any("error", err))
|
||||
|
||||
err = a.resetConnection(ctx)
|
||||
if err != nil {
|
||||
|
|
@ -182,7 +182,7 @@ func (a *AmqpMessagingApi) resetConnection(ctx context.Context) error {
|
|||
_ = (*a.session).Close(ctx)
|
||||
err := a.connection.Close()
|
||||
if err != nil {
|
||||
slog.Error("failed to close message connection", err)
|
||||
slog.Error("failed to close message connection", slog.Any("error", err))
|
||||
}
|
||||
|
||||
return a.connect()
|
||||
|
|
|
|||
|
|
@ -125,7 +125,8 @@ func (c SolaceContainer) QueueCreate(ctx context.Context, queueName string) erro
|
|||
_, err := c.sempClient.RequestWithBody(
|
||||
ctx,
|
||||
"POST",
|
||||
fmt.Sprintf("/config/msgVpns/default/queues"), queueConfig)
|
||||
"/config/msgVpns/default/queues",
|
||||
queueConfig)
|
||||
|
||||
return err
|
||||
}
|
||||
|
|
@ -220,7 +221,7 @@ func (c SolaceContainer) ValidateTopicName(topicSubscriptionTopicPattern string,
|
|||
}
|
||||
|
||||
// Check topic name
|
||||
allowedTopicCharacters, err := regexp.Compile("[0-9A-Za-z-.]+(?:/[0-9A-Za-z-.]+)+|[0-9A-Za-z-.]+")
|
||||
allowedTopicCharacters, err := regexp.Compile(`[0-9A-Za-z-.]+(?:/[0-9A-Za-z-.]+)+|[0-9A-Za-z-.]+`)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -230,7 +231,7 @@ func (c SolaceContainer) ValidateTopicName(topicSubscriptionTopicPattern string,
|
|||
|
||||
// Check topic subscription topic pattern
|
||||
allowedTopicSubscriptionCharacters, err := regexp.Compile(
|
||||
"(?:(?:[0-9A-Za-z-.]+|[0-9A-Za-z-.]*\\*)(?:/(?:[0-9A-Za-z-.]+|[0-9A-Za-z-.]*\\*))+|(?:[0-9A-Za-z-.]+|[0-9A-Za-z-.]*\\*)|/>)|>")
|
||||
`(?:(?:[0-9A-Za-z-.]+|[0-9A-Za-z-.]*\*)(?:/(?:[0-9A-Za-z-.]+|[0-9A-Za-z-.]*\*))+|(?:[0-9A-Za-z-.]+|[0-9A-Za-z-.]*\*)|/>)|>`)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -257,27 +258,25 @@ func (c SolaceContainer) ValidateTopicName(topicSubscriptionTopicPattern string,
|
|||
case '*':
|
||||
if name[i] == '/' {
|
||||
expectedNextCharacter = '/'
|
||||
nextError = errors.New(fmt.Sprintf("Invalid character '/' at index %d", i))
|
||||
nextError = fmt.Errorf("invalid character '/' at index %d", i)
|
||||
subscriptionIndex++
|
||||
}
|
||||
break
|
||||
case '/':
|
||||
if name[i] != '/' {
|
||||
return errors.New(fmt.Sprintf("Expected character '/', got %c at index %d", name[i], i))
|
||||
return fmt.Errorf("expected character '/', got %c at index %d", name[i], i)
|
||||
}
|
||||
subscriptionIndex++
|
||||
break
|
||||
case '>':
|
||||
// everything is allowed
|
||||
break
|
||||
default:
|
||||
if name[i] != topicSubscriptionTopicPattern[subscriptionIndex] {
|
||||
return errors.New(fmt.Sprintf(
|
||||
"Expected character %c, got %c at index %d",
|
||||
return fmt.Errorf(
|
||||
"expected character %c, got %c at index %d",
|
||||
topicSubscriptionTopicPattern[subscriptionIndex],
|
||||
name[i],
|
||||
i,
|
||||
))
|
||||
)
|
||||
} else {
|
||||
subscriptionIndex++
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue