Skip to content
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

chore: update golint #3177

Merged
merged 2 commits into from
Apr 12, 2024
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
10 changes: 4 additions & 6 deletions test/cel-validation/backendtrafficpolicy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ import (
"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"

gwapiv1 "sigs.k8s.io/gateway-api/apis/v1"
gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2"

Expand Down Expand Up @@ -436,8 +434,8 @@ func TestBackendTrafficPolicyTarget(t *testing.T) {
{
desc: " valid config: min, max, nil",
mutate: func(btp *egv1a1.BackendTrafficPolicy) {
valMax := pointer.Int64(4294967295)
valMin := pointer.Int64(0)
valMax := ptr.To[int64](4294967295)
valMin := ptr.To[int64](0)
btp.Spec = egv1a1.BackendTrafficPolicySpec{
TargetRef: gwapiv1a2.PolicyTargetReferenceWithSectionName{
PolicyTargetReference: gwapiv1a2.PolicyTargetReference{
Expand All @@ -459,8 +457,8 @@ func TestBackendTrafficPolicyTarget(t *testing.T) {
{
desc: " invalid config: min and max values",
mutate: func(btp *egv1a1.BackendTrafficPolicy) {
valOverMax := pointer.Int64(4294967296)
valUnderMin := pointer.Int64(-1)
valOverMax := ptr.To[int64](4294967296)
valUnderMin := ptr.To[int64](-1)
btp.Spec = egv1a1.BackendTrafficPolicySpec{
TargetRef: gwapiv1a2.PolicyTargetReferenceWithSectionName{
PolicyTargetReference: gwapiv1a2.PolicyTargetReference{
Expand Down
7 changes: 5 additions & 2 deletions test/cel-validation/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ import (
var c client.Client

func TestMain(m *testing.M) {
Copy link
Contributor Author

@zirain zirain Apr 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks golint! This fix a memory leak when cel test failed.

os.Exit(runTest(m))
}

func runTest(m *testing.M) int {
// Setup the test environment.
testEnv, restCfg, err := startEnv()
if err != nil {
Expand All @@ -47,8 +51,7 @@ func TestMain(m *testing.M) {
panic(fmt.Sprintf("Error initializing client: %v", err))
}
_ = egv1a1.AddToScheme(c.Scheme())

os.Exit(m.Run())
return m.Run()
}

func startEnv() (*envtest.Environment, *rest.Config, error) {
Expand Down
2 changes: 1 addition & 1 deletion tools/make/lint.mk
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ lint: lint.golint
lint-deps: $(tools/golangci-lint)
lint.golint: $(tools/golangci-lint)
@$(LOG_TARGET)
$(tools/golangci-lint) run $(GOLANGCI_LINT_FLAGS) --build-tags=e2e --config=tools/linter/golangci-lint/.golangci.yml
$(tools/golangci-lint) run $(GOLANGCI_LINT_FLAGS) --build-tags=e2e,celvalidation --config=tools/linter/golangci-lint/.golangci.yml

.PHONY: lint.yamllint
lint: lint.yamllint
Expand Down