Skip to content

Commit

Permalink
chore: enable gofumpt lint (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
ltucker authored Dec 16, 2024
1 parent a8b8ef7 commit 6ea3df5
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .github/golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ linters:
- gosimple
- bodyclose
- gci
- gofumpt

issues:
exclude-use-default: false
Expand All @@ -35,3 +36,5 @@ linters-settings:
- default
- prefix(github.com/netboxlabs/diode)
custom-order: true
go-fumpt:
extra-rules: true
4 changes: 4 additions & 0 deletions diode-server/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ deps:
lint:
@golangci-lint run ./... --config ../.github/golangci.yaml

.PHONY: fix-lint
fix-lint:
@golangci-lint run ./... --config ../.github/golangci.yaml --fix

.PHONY: test
test:
@go test -race ./...
Expand Down
2 changes: 1 addition & 1 deletion diode-server/cmd/ingester/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func main() {
os.Exit(1)
}

//TODO: instantiate prometheus server
// TODO: instantiate prometheus server

if err := s.Run(); err != nil {
s.Logger().Error("server failure", "serverName", s.Name(), "error", err)
Expand Down
2 changes: 1 addition & 1 deletion diode-server/cmd/reconciler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func main() {
os.Exit(1)
}

//TODO: instantiate prometheus server
// TODO: instantiate prometheus server

if err := s.Run(); err != nil {
s.Logger().Error("server failure", "serverName", s.Name(), "error", err)
Expand Down
4 changes: 2 additions & 2 deletions diode-server/netboxdiodeplugin/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,8 @@ func statusMapToStringHookFunc() mapstructure.DecodeHookFunc {
return func(
f reflect.Kind,
t reflect.Kind,
data interface{}) (interface{}, error) {

data interface{},
) (interface{}, error) {
if f != reflect.Map {
return data, nil
}
Expand Down
3 changes: 2 additions & 1 deletion diode-server/netboxdiodeplugin/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,8 @@ func TestRetrieveObjectState(t *testing.T) {
params: netboxdiodeplugin.RetrieveObjectStateQueryParams{
ObjectType: netbox.DcimDeviceObjectType,
ObjectID: 1,
Params: map[string]string{"q": "dev1", "attr_name": "site.id", "attr_value": "2"}},
Params: map[string]string{"q": "dev1", "attr_name": "site.id", "attr_value": "2"},
},
mockServerResponse: `{"object_type":"dcim.device","object_change_id":1,"object":{"id":1,"name":"dev1", "site": {"id": 2}}}`,
apiKey: "foobar",
response: &netboxdiodeplugin.ObjectState{
Expand Down
1 change: 0 additions & 1 deletion diode-server/reconciler/differ/differ_virt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,6 @@ func TestVirtualizationPrepare(t *testing.T) {
wantChangeSet: changeset.ChangeSet{
ChangeSetID: "5663a77e-9bad-4981-afe9-77d8a9f2b8b5",
ChangeSet: []changeset.Change{

{
ChangeID: "5663a77e-9bad-4981-afe9-77d8a9f2b8b5",
ChangeType: changeset.ChangeTypeCreate,
Expand Down
2 changes: 1 addition & 1 deletion diode-server/reconciler/ingestion_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ func (p *IngestionProcessor) writeIngestionLog(ctx context.Context, key string,
}

func normalizeIngestionLog(l []byte) []byte {
//replace ingestionTs string value as integer, see: https://github.com/golang/protobuf/issues/1414
// replace ingestionTs string value as integer, see: https://github.com/golang/protobuf/issues/1414
re := regexp.MustCompile(`"ingestionTs":"(\d+)"`)
return re.ReplaceAll(l, []byte(`"ingestionTs":$1`))
}
Expand Down
6 changes: 4 additions & 2 deletions diode-server/reconciler/ingestion_processor_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,14 @@ func TestHandleStreamMessage(t *testing.T) {
if tt.reconcilerError {
mockNbClient.On("RetrieveObjectState", ctx, mock.Anything).Return(&netboxdiodeplugin.ObjectState{}, errors.New("prepare error"))
} else {
mockNbClient.On("RetrieveObjectState", ctx, mock.Anything).Return(&netboxdiodeplugin.ObjectState{ObjectType: "dcim.site",
mockNbClient.On("RetrieveObjectState", ctx, mock.Anything).Return(&netboxdiodeplugin.ObjectState{
ObjectType: "dcim.site",
ObjectID: 0,
ObjectChangeID: 0,
Object: &netbox.DcimSiteDataWrapper{
Site: nil,
}}, nil)
},
}, nil)
}
mockNbClient.On("ApplyChangeSet", ctx, mock.Anything).Return(tt.changeSetResponse, tt.changeSetError)
if tt.entities[0].Entity != nil {
Expand Down
4 changes: 2 additions & 2 deletions diode-server/reconciler/logs_retriever.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ func buildQueryFilter(req *reconcilerpb.RetrieveIngestionLogsRequest) string {
}

func escapeSpecialChars(s string) string {
//replace ,.<>{}[]"':;!@#$%^&*()-+=~ with double backslash
//ref: https://redis.io/docs/latest/develop/interact/search-and-query/advanced-concepts/escaping/
// replace ,.<>{}[]"':;!@#$%^&*()-+=~ with double backslash
// ref: https://redis.io/docs/latest/develop/interact/search-and-query/advanced-concepts/escaping/
oldNew := []string{
",", "\\,", ".", "\\.", "<", "\\<", ">", "\\>", "{", "\\{", "}", "\\}", "[", "\\[", "]", "\\]", "\"", "\\\"",
"'", "\\'", ":", "\\:", ";", "\\;", "!", "\\!", "@", "\\@", "#", "\\#", "$", "\\$", "%", "\\%", "^", "\\^",
Expand Down

0 comments on commit 6ea3df5

Please sign in to comment.