From 5c359bda2826f805eba4be35f1156659afb722cb Mon Sep 17 00:00:00 2001 From: Katrina Verey Date: Mon, 28 Mar 2022 17:35:38 -0400 Subject: [PATCH] Go 1.18 compatibility updates --- Makefile | 6 +++--- api/krusty/disablenamesuffix_test.go | 12 ++++-------- hack/testExamplesAgainstKustomize.sh | 2 +- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index b92acbba0..f66648544 100644 --- a/Makefile +++ b/Makefile @@ -55,17 +55,17 @@ verify-kustomize-e2e: test-examples-e2e-kustomize # This installs what kustomize wants to use. $(MYGOBIN)/golangci-lint-kustomize: rm -f $(CURDIR)/hack/golangci-lint - GOBIN=$(CURDIR)/hack go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.23.8 + GOBIN=$(CURDIR)/hack go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.45.2 mv $(CURDIR)/hack/golangci-lint $(MYGOBIN)/golangci-lint-kustomize $(MYGOBIN)/mdrip: go install github.com/monopole/mdrip@v1.0.2 $(MYGOBIN)/stringer: - go get golang.org/x/tools/cmd/stringer + go install golang.org/x/tools/cmd/stringer@latest $(MYGOBIN)/goimports: - go get golang.org/x/tools/cmd/goimports + go install golang.org/x/tools/cmd/goimports@latest # Build from local source. $(MYGOBIN)/gorepomod: diff --git a/api/krusty/disablenamesuffix_test.go b/api/krusty/disablenamesuffix_test.go index 9580a8914..5c4ca2dc9 100644 --- a/api/krusty/disablenamesuffix_test.go +++ b/api/krusty/disablenamesuffix_test.go @@ -82,8 +82,7 @@ metadata: secret := findSecret(m, "") if secret == nil { t.Errorf("Expected to find a Secret") - } - if secret.GetName() != "foo-secret-bar-82c2g5f8f6" { + } else if secret.GetName() != "foo-secret-bar-82c2g5f8f6" { t.Errorf("unexpected secret resource name: %s", secret.GetName()) } @@ -95,8 +94,7 @@ metadata: secret = findSecret(m, "") if secret == nil { t.Errorf("Expected to find a Secret") - } - if secret.GetName() != "foo-secret-bar" { // No hash at end. + } else if secret.GetName() != "foo-secret-bar" { // No hash at end. t.Errorf("unexpected secret resource name: %s", secret.GetName()) } } @@ -131,16 +129,14 @@ secretGenerator: secret := findSecret(m, "nohash") if secret == nil { t.Errorf("Expected to find a Secret") - } - if secret.GetName() != "nohash" { + } else if secret.GetName() != "nohash" { t.Errorf("unexpected secret resource name: %s", secret.GetName()) } secret = findSecret(m, "yeshash") if secret == nil { t.Errorf("Expected to find a Secret") - } - if secret.GetName() != "yeshash-82c2g5f8f6" { + } else if secret.GetName() != "yeshash-82c2g5f8f6" { t.Errorf("unexpected secret resource name: %s", secret.GetName()) } } diff --git a/hack/testExamplesAgainstKustomize.sh b/hack/testExamplesAgainstKustomize.sh index 1a447ee41..f1a85ad90 100755 --- a/hack/testExamplesAgainstKustomize.sh +++ b/hack/testExamplesAgainstKustomize.sh @@ -22,7 +22,7 @@ rm -f $MYGOBIN/kustomize if [ "$version" == "HEAD" ]; then (cd kustomize; go install .) else - GO111MODULE=on go get sigs.k8s.io/kustomize/kustomize/${version} + GO111MODULE=on go install sigs.k8s.io/kustomize/kustomize/${version} fi # TODO: change the label?