Skip to content

chore/ci: add go.lint.fmt target #5846

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/gatewayapi/backendtrafficpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ func applyTrafficFeatureToRoute(route RouteContext,
}
}

func mergeBackendTrafficPolicy(routePolicy *egv1a1.BackendTrafficPolicy, gwPolicy *egv1a1.BackendTrafficPolicy) (*egv1a1.BackendTrafficPolicy, error) {
func mergeBackendTrafficPolicy(routePolicy, gwPolicy *egv1a1.BackendTrafficPolicy) (*egv1a1.BackendTrafficPolicy, error) {
if routePolicy.Spec.MergeType == nil || gwPolicy == nil {
return routePolicy.DeepCopy(), nil
}
Expand Down
2 changes: 1 addition & 1 deletion internal/gatewayapi/resource/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"io/fs"
"time"

"github.com/envoyproxy/gateway" // nolint:goimports
envoygateway "github.com/envoyproxy/gateway"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion internal/gatewayapi/resource/fs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/stretchr/testify/require"

"github.com/envoyproxy/gateway" // nolint:goimports
envoygateway "github.com/envoyproxy/gateway"
)

func TestOpenAndReadGatewayCRDsFS(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/utils/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1"
)

func Merge[T client.Object](original T, patch T, mergeType egv1a1.MergeType) (T, error) {
func Merge[T client.Object](original, patch T, mergeType egv1a1.MergeType) (T, error) {
var (
patchedJSON []byte
originalJSON []byte
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/tests/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ var MetricWorkqueueAndRestclientTest = suite.ConformanceTest{
)
require.NoError(t, err)

verifyMetrics := func(t *testing.T, metricQuery string, metricName string) {
verifyMetrics := func(t *testing.T, metricQuery, metricName string) {
httputils.AwaitConvergence(
t,
suite.TimeoutConfig.RequiredConsecutiveSuccesses,
Expand Down
2 changes: 2 additions & 0 deletions tools/linter/golangci-lint/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ formatters:
- prefix(github.com/envoyproxy/gateway)
gofmt:
simplify: true
gofumpt:
extra-rules: true
goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
Expand Down
5 changes: 5 additions & 0 deletions tools/make/golang.mk
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ go.mod.lint: go.mod.tidy go.mod.tidy.examples ## Check if go.mod is clean
$(call log, "Go module looks clean!"); \
fi

.PHONY: go.lint.fmt
go.lint.fmt:
@$(LOG_TARGET)
@go tool golangci-lint fmt --build-tags=$(LINT_BUILD_TAGS) --config=tools/linter/golangci-lint/.golangci.yml

.PHONY: go.generate
go.generate: ## Generate code from templates
@$(LOG_TARGET)
Expand Down
2 changes: 1 addition & 1 deletion tools/make/lint.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ lint: lint.yamllint
lint-deps: $(tools/yamllint)
lint.yamllint: $(tools/yamllint)
@$(LOG_TARGET)
$(tools/yamllint) --config-file=tools/linter/yamllint/.yamllint $$(git ls-files :*.yml :*.yaml | xargs -L1 dirname | sort -u)
$(tools/yamllint) --config-file=tools/linter/yamllint/.yamllint $$(git ls-files :*.yml :*.yaml | xargs -L1 dirname | sort -u)

CODESPELL_FLAGS ?= $(if $(GITHUB_ACTION),--disable-colors)
.PHONY: lint.codespell
Expand Down