From 5b2e679e32dce2ae222c5697073dc1850c402d84 Mon Sep 17 00:00:00 2001 From: Natasha Sarkar Date: Fri, 31 Mar 2023 23:15:14 -0500 Subject: [PATCH] update go functions to go 1.19 (#1036) --- .github/workflows/ci.yaml | 8 ++++---- .github/workflows/verify-docs.yaml | 4 ++-- build/docker/go/defaults.env | 2 +- functions/go/apply-replacements/go.mod | 2 +- .../applysetters/apply_setters_test.go | 9 ++++----- functions/go/apply-setters/go.mod | 2 +- .../createsetters/create_setters_test.go | 9 ++++----- functions/go/create-setters/go.mod | 2 +- .../gcpservices/project_service_set_test.go | 5 ++--- functions/go/enable-gcp-services/go.mod | 2 +- functions/go/ensure-name-substring/go.mod | 2 +- functions/go/export-terraform/go.mod | 2 +- .../terraformgenerator/terraform_generator_test.go | 5 ++--- functions/go/fix/fixpkg/fix_test.go | 5 ++--- functions/go/fix/go.mod | 2 +- functions/go/format/go.mod | 2 +- functions/go/gatekeeper/go.mod | 2 +- functions/go/gatekeeper/main.go | 5 ++--- functions/go/generate-kpt-pkg-docs/go.mod | 2 +- functions/go/generate-kpt-pkg-docs/main.go | 7 +++---- functions/go/go.mod | 2 +- functions/go/go.sum | 7 +++---- functions/go/list-setters/go.mod | 2 +- .../list-setters/listsetters/list_setters_test.go | 5 ++--- functions/go/remove-local-config-resources/go.mod | 2 +- functions/go/render-helm-chart/go.mod | 2 +- .../api/builtins/HelmChartInflationGenerator.go | 13 +++++++------ functions/go/search-replace/go.mod | 2 +- .../searchreplace/search_replace_test.go | 9 ++++----- functions/go/set-annotations/go.mod | 2 +- functions/go/set-enforcement-action/go.mod | 2 +- functions/go/set-image/go.mod | 5 ++--- functions/go/set-image/go.sum | 1 - functions/go/set-labels/go.mod | 2 +- functions/go/set-labels/go.sum | 4 ---- functions/go/set-namespace/go.mod | 2 +- functions/go/set-project-id/go.mod | 2 +- functions/go/source-gcloud-config/go.mod | 2 +- functions/go/starlark/go.mod | 2 +- functions/go/starlark/go.sum | 2 -- .../kustomize/kyaml/fn/runtime/starlark/starlark.go | 6 +++--- functions/go/upsert-resource/go.mod | 2 +- .../upsertresource/upsert_resource_test.go | 5 ++--- hack/Dockerfile | 2 +- 44 files changed, 73 insertions(+), 91 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7de3d1648..23b085bca 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -59,10 +59,10 @@ jobs: GOPATH: /home/runner/work/kpt-functions-catalog/functions/go GO111MODULE: on steps: - - name: Set up Go 1.18 + - name: Set up Go 1.19 uses: actions/setup-go@v2 with: - go-version: 1.18 + go-version: 1.19 id: go - name: Check out code into GOPATH uses: actions/checkout@v1 @@ -92,10 +92,10 @@ jobs: uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} - - name: Set up Go 1.18 + - name: Set up Go 1.19 uses: actions/setup-go@v2 with: - go-version: 1.18 + go-version: 1.19 - name: Install kpt run: | go install github.com/GoogleContainerTools/kpt@main diff --git a/.github/workflows/verify-docs.yaml b/.github/workflows/verify-docs.yaml index 342001eb6..0cc82176a 100644 --- a/.github/workflows/verify-docs.yaml +++ b/.github/workflows/verify-docs.yaml @@ -19,10 +19,10 @@ jobs: - name: Install libs run: | pip install pyyaml - - name: Set up Go 1.18 + - name: Set up Go 1.19 uses: actions/setup-go@v2 with: - go-version: 1.18 + go-version: 1.19 - name: Install mdrip run: | go install github.com/monopole/mdrip@v1.0.2 diff --git a/build/docker/go/defaults.env b/build/docker/go/defaults.env index 39c7b5ea0..e9b0939d6 100644 --- a/build/docker/go/defaults.env +++ b/build/docker/go/defaults.env @@ -1,2 +1,2 @@ -BUILDER_IMAGE=golang:1.18-alpine3.15 +BUILDER_IMAGE=golang:1.19-alpine3.15 BASE_IMAGE=alpine:3.15 diff --git a/functions/go/apply-replacements/go.mod b/functions/go/apply-replacements/go.mod index c2165d818..f082de10a 100644 --- a/functions/go/apply-replacements/go.mod +++ b/functions/go/apply-replacements/go.mod @@ -1,6 +1,6 @@ module github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/apply-replacements -go 1.18 +go 1.19 require ( github.com/GoogleContainerTools/kpt-functions-sdk/go/fn v0.0.0-20220506190241-f85503febd54 diff --git a/functions/go/apply-setters/applysetters/apply_setters_test.go b/functions/go/apply-setters/applysetters/apply_setters_test.go index 89a72ad2a..861adf3b6 100644 --- a/functions/go/apply-setters/applysetters/apply_setters_test.go +++ b/functions/go/apply-setters/applysetters/apply_setters_test.go @@ -1,7 +1,6 @@ package applysetters import ( - "io/ioutil" "os" "testing" @@ -438,18 +437,18 @@ roles: # kpt-set: ${roles} for i := range tests { test := tests[i] t.Run(test.name, func(t *testing.T) { - baseDir, err := ioutil.TempDir("", "") + baseDir, err := os.MkdirTemp("", "") if !assert.NoError(t, err) { t.FailNow() } defer os.RemoveAll(baseDir) - r, err := ioutil.TempFile(baseDir, "k8s-cli-*.yaml") + r, err := os.CreateTemp(baseDir, "k8s-cli-*.yaml") if !assert.NoError(t, err) { t.FailNow() } defer os.Remove(r.Name()) - err = ioutil.WriteFile(r.Name(), []byte(test.input), 0600) + err = os.WriteFile(r.Name(), []byte(test.input), 0600) if !assert.NoError(t, err) { t.FailNow() } @@ -486,7 +485,7 @@ roles: # kpt-set: ${roles} t.FailNow() } - actualResources, err := ioutil.ReadFile(r.Name()) + actualResources, err := os.ReadFile(r.Name()) if !assert.NoError(t, err) { t.FailNow() } diff --git a/functions/go/apply-setters/go.mod b/functions/go/apply-setters/go.mod index 6f72556d4..ddb1b899e 100644 --- a/functions/go/apply-setters/go.mod +++ b/functions/go/apply-setters/go.mod @@ -1,6 +1,6 @@ module github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/apply-setters -go 1.18 +go 1.19 require ( github.com/stretchr/testify v1.6.1 diff --git a/functions/go/create-setters/createsetters/create_setters_test.go b/functions/go/create-setters/createsetters/create_setters_test.go index 1f7b81781..04b975af1 100644 --- a/functions/go/create-setters/createsetters/create_setters_test.go +++ b/functions/go/create-setters/createsetters/create_setters_test.go @@ -2,7 +2,6 @@ package createsetters import ( "fmt" - "io/ioutil" "os" "sort" "strings" @@ -525,18 +524,18 @@ spec: for i := range tests { test := tests[i] t.Run(test.name, func(t *testing.T) { - baseDir, err := ioutil.TempDir("", "") + baseDir, err := os.MkdirTemp("", "") if !assert.NoError(t, err) { t.FailNow() } defer os.RemoveAll(baseDir) - r, err := ioutil.TempFile(baseDir, "k8s-cli-*.yaml") + r, err := os.CreateTemp(baseDir, "k8s-cli-*.yaml") if !assert.NoError(t, err) { t.FailNow() } defer os.Remove(r.Name()) - err = ioutil.WriteFile(r.Name(), []byte(test.input), 0600) + err = os.WriteFile(r.Name(), []byte(test.input), 0600) if !assert.NoError(t, err) { t.FailNow() } @@ -584,7 +583,7 @@ spec: t.FailNow() } - actualResources, err := ioutil.ReadFile(r.Name()) + actualResources, err := os.ReadFile(r.Name()) if !assert.NoError(t, err) { t.FailNow() } diff --git a/functions/go/create-setters/go.mod b/functions/go/create-setters/go.mod index 56a7352ce..c0f593776 100644 --- a/functions/go/create-setters/go.mod +++ b/functions/go/create-setters/go.mod @@ -1,6 +1,6 @@ module github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/create-setters -go 1.18 +go 1.19 require ( github.com/stretchr/testify v1.6.1 diff --git a/functions/go/enable-gcp-services/gcpservices/project_service_set_test.go b/functions/go/enable-gcp-services/gcpservices/project_service_set_test.go index afefb9f9c..7b5ca885f 100644 --- a/functions/go/enable-gcp-services/gcpservices/project_service_set_test.go +++ b/functions/go/enable-gcp-services/gcpservices/project_service_set_test.go @@ -2,7 +2,6 @@ package gcpservices import ( "bytes" - "io/ioutil" "os" "path" "testing" @@ -709,14 +708,14 @@ metadata: func setupInputs(t *testing.T, resourceMap map[string]string) string { t.Helper() require := require.New(t) - baseDir, err := ioutil.TempDir("", "") + baseDir, err := os.MkdirTemp("", "") require.NoError(err) for rpath, data := range resourceMap { filePath := path.Join(baseDir, rpath) err = os.MkdirAll(path.Dir(filePath), os.ModePerm) require.NoError(err) - err = ioutil.WriteFile(path.Join(baseDir, rpath), []byte(data), 0644) + err = os.WriteFile(path.Join(baseDir, rpath), []byte(data), 0644) require.NoError(err) } return baseDir diff --git a/functions/go/enable-gcp-services/go.mod b/functions/go/enable-gcp-services/go.mod index eb8b00649..9f8c24dec 100644 --- a/functions/go/enable-gcp-services/go.mod +++ b/functions/go/enable-gcp-services/go.mod @@ -1,6 +1,6 @@ module github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/project-services -go 1.18 +go 1.19 require ( github.com/stretchr/testify v1.7.0 diff --git a/functions/go/ensure-name-substring/go.mod b/functions/go/ensure-name-substring/go.mod index 2b7139ca5..22e549b78 100644 --- a/functions/go/ensure-name-substring/go.mod +++ b/functions/go/ensure-name-substring/go.mod @@ -1,6 +1,6 @@ module github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/ensure-name-substring -go 1.18 +go 1.19 require ( github.com/stretchr/testify v1.7.0 diff --git a/functions/go/export-terraform/go.mod b/functions/go/export-terraform/go.mod index 5074d52dd..5dd052fee 100644 --- a/functions/go/export-terraform/go.mod +++ b/functions/go/export-terraform/go.mod @@ -1,6 +1,6 @@ module github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/export-terraform -go 1.18 +go 1.19 require ( github.com/GoogleContainerTools/kpt-functions-catalog/thirdparty/kyaml/fnsdk v0.0.0-20220111011035-c598c94c9a02 diff --git a/functions/go/export-terraform/terraformgenerator/terraform_generator_test.go b/functions/go/export-terraform/terraformgenerator/terraform_generator_test.go index 61e9d574d..0dd8289dd 100644 --- a/functions/go/export-terraform/terraformgenerator/terraform_generator_test.go +++ b/functions/go/export-terraform/terraformgenerator/terraform_generator_test.go @@ -16,7 +16,6 @@ package terraformgenerator import ( "fmt" - "io/ioutil" "os" "path" "path/filepath" @@ -95,7 +94,7 @@ func TestTerraformGeneration(t *testing.T) { require.NoError(err) // round-trip to disk to make sure all annotations are consistent - tmpDir, err := ioutil.TempDir("", "export-terraform-test-*") + tmpDir, err := os.MkdirTemp("", "export-terraform-test-*") defer os.RemoveAll(tmpDir) require.NoError(err) err = testutil.ResourceListToDirectory(tempRL, tmpDir) @@ -142,7 +141,7 @@ func TestTerraformGeneration(t *testing.T) { // diff command) to do it. This will be addressed in the next iteration. // The workaround is that we read the resource files as a ResourceList and // then compare this ResourceList with the expected ResourceList. - tmpDir, err := ioutil.TempDir("", "export-terraform-test-*") + tmpDir, err := os.MkdirTemp("", "export-terraform-test-*") defer os.RemoveAll(tmpDir) require.NoError(err) err = testutil.ResourceListToDirectory(actualRL, tmpDir) diff --git a/functions/go/fix/fixpkg/fix_test.go b/functions/go/fix/fixpkg/fix_test.go index c146f2fc5..73847f0f2 100644 --- a/functions/go/fix/fixpkg/fix_test.go +++ b/functions/go/fix/fixpkg/fix_test.go @@ -1,7 +1,6 @@ package fixpkg import ( - "io/ioutil" "os" "testing" @@ -12,7 +11,7 @@ import ( ) func TestFixV1alpha1ToV1(t *testing.T) { - dir, err := ioutil.TempDir("", "") + dir, err := os.MkdirTemp("", "") assert.NoError(t, err) defer os.RemoveAll(dir) err = copyutil.CopyDir("../../../../testdata/fix/nginx-v1alpha1", dir) @@ -57,7 +56,7 @@ func TestFixV1alpha1ToV1(t *testing.T) { } func TestFixV1alpha2ToV1(t *testing.T) { - dir, err := ioutil.TempDir("", "") + dir, err := os.MkdirTemp("", "") assert.NoError(t, err) defer os.RemoveAll(dir) err = copyutil.CopyDir("../../../../testdata/fix/nginx-v1alpha2", dir) diff --git a/functions/go/fix/go.mod b/functions/go/fix/go.mod index 7ee5e14ca..4a0ae5bdd 100644 --- a/functions/go/fix/go.mod +++ b/functions/go/fix/go.mod @@ -1,6 +1,6 @@ module github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/fix -go 1.18 +go 1.19 require ( github.com/stretchr/testify v1.7.0 diff --git a/functions/go/format/go.mod b/functions/go/format/go.mod index 8a64367f7..84ed507c4 100644 --- a/functions/go/format/go.mod +++ b/functions/go/format/go.mod @@ -1,6 +1,6 @@ module github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/format -go 1.18 +go 1.19 require sigs.k8s.io/kustomize/kyaml v0.10.21 diff --git a/functions/go/gatekeeper/go.mod b/functions/go/gatekeeper/go.mod index 89b54e10a..84556fff1 100644 --- a/functions/go/gatekeeper/go.mod +++ b/functions/go/gatekeeper/go.mod @@ -1,6 +1,6 @@ module github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/gatekeeper -go 1.18 +go 1.19 require ( github.com/open-policy-agent/frameworks/constraint v0.0.0-20220121182312-5d06dedcafb4 diff --git a/functions/go/gatekeeper/main.go b/functions/go/gatekeeper/main.go index 20037e523..d978a7f89 100644 --- a/functions/go/gatekeeper/main.go +++ b/functions/go/gatekeeper/main.go @@ -17,7 +17,6 @@ package main import ( "bytes" "fmt" - "io/ioutil" "os" "github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/gatekeeper/generated" @@ -82,7 +81,7 @@ func (gkp *GatekeeperProcessor) Process(resourceList *framework.ResourceList) er } func (gkp *GatekeeperProcessor) ProcessInput() error { - content, err := ioutil.ReadFile(gkp.input) + content, err := os.ReadFile(gkp.input) if err != nil { return fmt.Errorf("unable to process input: %w", err) } @@ -116,7 +115,7 @@ func (gkp *GatekeeperProcessor) ProcessOutput() error { } } - err = ioutil.WriteFile(gkp.output, content, 0644) + err = os.WriteFile(gkp.output, content, 0644) if err != nil { return fmt.Errorf("unable to process output: %w", err) } diff --git a/functions/go/generate-kpt-pkg-docs/go.mod b/functions/go/generate-kpt-pkg-docs/go.mod index a5fdc12bc..740a77530 100644 --- a/functions/go/generate-kpt-pkg-docs/go.mod +++ b/functions/go/generate-kpt-pkg-docs/go.mod @@ -1,6 +1,6 @@ module github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/generate-kpt-pkg-docs -go 1.18 +go 1.19 require ( github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/list-setters v0.1.0 diff --git a/functions/go/generate-kpt-pkg-docs/main.go b/functions/go/generate-kpt-pkg-docs/main.go index 5a30b8cd8..d56943c3f 100644 --- a/functions/go/generate-kpt-pkg-docs/main.go +++ b/functions/go/generate-kpt-pkg-docs/main.go @@ -3,7 +3,6 @@ package main import ( "errors" "fmt" - "io/ioutil" "os" "github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/generate-kpt-pkg-docs/docs" @@ -16,7 +15,7 @@ import ( const defaultReadmePath = "/tmp/README.md" const defaultRepoPath = "https://github.com/GoogleCloudPlatform/blueprints.git/catalog/" -//nolint +// nolint func main() { rp := ReadmeProcessor{} cmd := command.Build(&rp, command.StandaloneEnabled, false) @@ -34,7 +33,7 @@ type ReadmeProcessor struct{} func (rp *ReadmeProcessor) Process(resourceList *framework.ResourceList) error { readmePath, repoPath, pkgName := parseFnCfg(resourceList.FunctionConfig) - currentDoc, err := ioutil.ReadFile(readmePath) + currentDoc, err := os.ReadFile(readmePath) if err != nil { if errors.Is(err, os.ErrNotExist) { resourceList.Results = getResults(fmt.Sprintf("Skipping readme generation: %s", err), framework.Warning) @@ -60,7 +59,7 @@ func generateReadme(repoPath, readmePath, pkgName, currentDoc string, resourceLi if err != nil { return err } - err = ioutil.WriteFile(readmePath, []byte(readme), os.ModePerm) + err = os.WriteFile(readmePath, []byte(readme), os.ModePerm) if err != nil { return err } diff --git a/functions/go/go.mod b/functions/go/go.mod index 35f616eda..6402d8dba 100644 --- a/functions/go/go.mod +++ b/functions/go/go.mod @@ -1,6 +1,6 @@ module github.com/GoogleContainerTools/kpt-functions-catalog/functions/go -go 1.18 +go 1.19 require ( github.com/GoogleContainerTools/kpt-functions-sdk/go/fn v0.0.0-20221007213718-5fa523b306fe diff --git a/functions/go/go.sum b/functions/go/go.sum index 38fcd8b38..582051dd5 100644 --- a/functions/go/go.sum +++ b/functions/go/go.sum @@ -3,8 +3,6 @@ cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/GoogleContainerTools/kpt-functions-sdk/go/api v0.0.0-20221007213718-5fa523b306fe h1:8PNHR5cev3FqOduItCH59KZdabDwz9I5xNcB8Woc6es= github.com/GoogleContainerTools/kpt-functions-sdk/go/api v0.0.0-20221007213718-5fa523b306fe/go.mod h1:prNhhUAODrB2VqHVead9tB8nLU9ffY4e4jjBwLMNO1M= -github.com/GoogleContainerTools/kpt-functions-sdk/go/fn v0.0.0-20220929172014-8888fc9691d1 h1:DFLHb51Av8m6ETGvd+J4Ok0pvfo735OW0sP+wbJLQyg= -github.com/GoogleContainerTools/kpt-functions-sdk/go/fn v0.0.0-20220929172014-8888fc9691d1/go.mod h1:TZd94D9b8alIDuF3mW9g+ofbl0RfwT0JewXmXm7phDI= github.com/GoogleContainerTools/kpt-functions-sdk/go/fn v0.0.0-20221007213718-5fa523b306fe h1:BjbTCT1mkPf0s4X3osOleEcaa89psOlcEJGUcLc+YPo= github.com/GoogleContainerTools/kpt-functions-sdk/go/fn v0.0.0-20221007213718-5fa523b306fe/go.mod h1:mqc5jH6i0Ll6T4wCmTXsVNVxhwBGlVtrtmoF/g3E9lE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= @@ -67,7 +65,7 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= @@ -76,8 +74,8 @@ github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFF github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -92,6 +90,7 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= +github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/functions/go/list-setters/go.mod b/functions/go/list-setters/go.mod index 8cadf6f63..9718f97cd 100644 --- a/functions/go/list-setters/go.mod +++ b/functions/go/list-setters/go.mod @@ -1,6 +1,6 @@ module github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/list-setters -go 1.18 +go 1.19 require ( github.com/GoogleContainerTools/kpt-functions-sdk/go v0.0.0-20210810181223-632b30549de6 diff --git a/functions/go/list-setters/listsetters/list_setters_test.go b/functions/go/list-setters/listsetters/list_setters_test.go index 3cf547df0..41793651f 100644 --- a/functions/go/list-setters/listsetters/list_setters_test.go +++ b/functions/go/list-setters/listsetters/list_setters_test.go @@ -1,7 +1,6 @@ package listsetters import ( - "io/ioutil" "os" "path" "testing" @@ -515,14 +514,14 @@ spec: func setupInputs(t *testing.T, resourceMap map[string]string) string { t.Helper() require := require.New(t) - baseDir, err := ioutil.TempDir("", "") + baseDir, err := os.MkdirTemp("", "") require.NoError(err) for rpath, data := range resourceMap { filePath := path.Join(baseDir, rpath) err = os.MkdirAll(path.Dir(filePath), os.ModePerm) require.NoError(err) - err = ioutil.WriteFile(path.Join(baseDir, rpath), []byte(data), 0644) + err = os.WriteFile(path.Join(baseDir, rpath), []byte(data), 0644) require.NoError(err) } return baseDir diff --git a/functions/go/remove-local-config-resources/go.mod b/functions/go/remove-local-config-resources/go.mod index 61eb490ca..0547265cd 100644 --- a/functions/go/remove-local-config-resources/go.mod +++ b/functions/go/remove-local-config-resources/go.mod @@ -1,6 +1,6 @@ module github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/remove-local-config-resources -go 1.18 +go 1.19 require ( github.com/stretchr/testify v1.7.0 diff --git a/functions/go/render-helm-chart/go.mod b/functions/go/render-helm-chart/go.mod index d2e3c2d92..fbfcb071c 100644 --- a/functions/go/render-helm-chart/go.mod +++ b/functions/go/render-helm-chart/go.mod @@ -1,6 +1,6 @@ module github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/render-helm-chart -go 1.18 +go 1.19 require ( github.com/GoogleContainerTools/kpt-functions-sdk/go/fn v0.0.0-20220506190241-f85503febd54 diff --git a/functions/go/render-helm-chart/third_party/sigs.k8s.io/kustomize/api/builtins/HelmChartInflationGenerator.go b/functions/go/render-helm-chart/third_party/sigs.k8s.io/kustomize/api/builtins/HelmChartInflationGenerator.go index 440cd75b6..138918d01 100644 --- a/functions/go/render-helm-chart/third_party/sigs.k8s.io/kustomize/api/builtins/HelmChartInflationGenerator.go +++ b/functions/go/render-helm-chart/third_party/sigs.k8s.io/kustomize/api/builtins/HelmChartInflationGenerator.go @@ -9,7 +9,7 @@ import ( "crypto/md5" "encoding/hex" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "os" @@ -51,7 +51,7 @@ var legalMergeOptions = []string{ valuesMergeOptionReplace, } -//noinspection GoUnusedGlobalVariable +// noinspection GoUnusedGlobalVariable var KustomizeHelmChartInflationGeneratorPlugin HelmChartInflationGeneratorPlugin func (p *HelmChartInflationGeneratorPlugin) establishTmpDir() (err error) { @@ -59,7 +59,8 @@ func (p *HelmChartInflationGeneratorPlugin) establishTmpDir() (err error) { // already done. return nil } - p.tmpDir, err = ioutil.TempDir("", "kustomize-helm-") + + p.tmpDir, err = os.MkdirTemp("", "kustomize-helm-") return err } @@ -171,7 +172,7 @@ func (p *HelmChartInflationGeneratorPlugin) runHelmCommand( // createNewMergedValuesFiles replaces/merges original values file with ValuesInline. func (p *HelmChartInflationGeneratorPlugin) createNewMergedValuesFiles(path string) ( string, error) { - pValues, err := ioutil.ReadFile(path) + pValues, err := os.ReadFile(path) if err != nil { if u, urlErr := url.Parse(path); urlErr == nil { if u.Scheme == "http" || u.Scheme == "https" { @@ -180,7 +181,7 @@ func (p *HelmChartInflationGeneratorPlugin) createNewMergedValuesFiles(path stri return "", err } defer resp.Body.Close() - pValues, err = ioutil.ReadAll(resp.Body) + pValues, err = io.ReadAll(resp.Body) if err != nil { return "", err } @@ -242,7 +243,7 @@ func (p *HelmChartInflationGeneratorPlugin) writeValuesBytes( // use a hash of the provided path to generate a unique, valid filename hash := md5.Sum([]byte(path)) newPath := filepath.Join(p.tmpDir, p.Name+"-kustomize-values-"+hex.EncodeToString(hash[:])+".yaml") - return newPath, ioutil.WriteFile(newPath, b, 0644) + return newPath, os.WriteFile(newPath, b, 0644) } func (p *HelmChartInflationGeneratorPlugin) cleanup() { diff --git a/functions/go/search-replace/go.mod b/functions/go/search-replace/go.mod index f85ec0616..c555dc907 100644 --- a/functions/go/search-replace/go.mod +++ b/functions/go/search-replace/go.mod @@ -1,6 +1,6 @@ module github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/search-replace -go 1.18 +go 1.19 require ( github.com/bmatcuk/doublestar/v4 v4.0.2 diff --git a/functions/go/search-replace/searchreplace/search_replace_test.go b/functions/go/search-replace/searchreplace/search_replace_test.go index 71fc4018a..d83882e73 100644 --- a/functions/go/search-replace/searchreplace/search_replace_test.go +++ b/functions/go/search-replace/searchreplace/search_replace_test.go @@ -1,7 +1,6 @@ package searchreplace import ( - "io/ioutil" "os" "path/filepath" "strings" @@ -26,18 +25,18 @@ func TestSearchCommand(t *testing.T) { for i := range tests { test := tests[i] t.Run(test.name, func(t *testing.T) { - baseDir, err := ioutil.TempDir("", "") + baseDir, err := os.MkdirTemp("", "") if !assert.NoError(t, err) { t.FailNow() } defer os.RemoveAll(baseDir) - r, err := ioutil.TempFile(baseDir, "k8s-cli-*.yaml") + r, err := os.CreateTemp(baseDir, "k8s-cli-*.yaml") if !assert.NoError(t, err) { t.FailNow() } defer os.Remove(r.Name()) - err = ioutil.WriteFile(r.Name(), []byte(test.input), 0600) + err = os.WriteFile(r.Name(), []byte(test.input), 0600) if !assert.NoError(t, err) { t.FailNow() } @@ -75,7 +74,7 @@ func TestSearchCommand(t *testing.T) { t.FailNow() } - actualResources, err := ioutil.ReadFile(r.Name()) + actualResources, err := os.ReadFile(r.Name()) if !assert.NoError(t, err) { t.FailNow() } diff --git a/functions/go/set-annotations/go.mod b/functions/go/set-annotations/go.mod index 1f575939e..06b0d9af3 100644 --- a/functions/go/set-annotations/go.mod +++ b/functions/go/set-annotations/go.mod @@ -1,6 +1,6 @@ module github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/set-annotations -go 1.18 +go 1.19 require ( sigs.k8s.io/kustomize/api v0.10.2-0.20211202184144-fe551be87b8d diff --git a/functions/go/set-enforcement-action/go.mod b/functions/go/set-enforcement-action/go.mod index ffa0f7e9e..4c202351f 100644 --- a/functions/go/set-enforcement-action/go.mod +++ b/functions/go/set-enforcement-action/go.mod @@ -1,6 +1,6 @@ module github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/set-enforcement-action -go 1.18 +go 1.19 require ( github.com/stretchr/testify v1.7.0 diff --git a/functions/go/set-image/go.mod b/functions/go/set-image/go.mod index f55b99c7a..91513438b 100644 --- a/functions/go/set-image/go.mod +++ b/functions/go/set-image/go.mod @@ -1,10 +1,9 @@ module github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/set-image -go 1.18 +go 1.19 require ( github.com/GoogleContainerTools/kpt-functions-sdk/go/fn v0.0.0-20220812180116-970f3e4cbc5a - github.com/stretchr/testify v1.8.0 sigs.k8s.io/kustomize/api v0.11.0 sigs.k8s.io/kustomize/kyaml v0.13.9 ) @@ -24,7 +23,7 @@ require ( github.com/mailru/easyjson v0.7.7 // indirect github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/stretchr/objx v0.4.0 // indirect github.com/xlab/treeprint v1.1.0 // indirect golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect google.golang.org/protobuf v1.28.1 // indirect diff --git a/functions/go/set-image/go.sum b/functions/go/set-image/go.sum index 769682f35..f85625782 100644 --- a/functions/go/set-image/go.sum +++ b/functions/go/set-image/go.sum @@ -285,7 +285,6 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= diff --git a/functions/go/set-labels/go.mod b/functions/go/set-labels/go.mod index 7b38f6994..db62ce4d8 100644 --- a/functions/go/set-labels/go.mod +++ b/functions/go/set-labels/go.mod @@ -1,6 +1,6 @@ module github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/set-labels -go 1.18 +go 1.19 require github.com/GoogleContainerTools/kpt-functions-sdk/go/fn v0.0.0-20221014182208-8e78fe927b37 diff --git a/functions/go/set-labels/go.sum b/functions/go/set-labels/go.sum index 8025ef2e9..442b0aded 100644 --- a/functions/go/set-labels/go.sum +++ b/functions/go/set-labels/go.sum @@ -1,12 +1,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/GoogleContainerTools/kpt-functions-sdk/go/api v0.0.0-20221013190212-691c71e8ceee h1:4lvMQqHIcZFCLO0JS0YkHligjZca5Wi0CZ7QLCvMjZY= -github.com/GoogleContainerTools/kpt-functions-sdk/go/api v0.0.0-20221013190212-691c71e8ceee/go.mod h1:prNhhUAODrB2VqHVead9tB8nLU9ffY4e4jjBwLMNO1M= github.com/GoogleContainerTools/kpt-functions-sdk/go/api v0.0.0-20221014182208-8e78fe927b37 h1:XBW54uFJhiVz3fvypNtWhfkthKI4PpFnLNTBXfi7DHE= github.com/GoogleContainerTools/kpt-functions-sdk/go/api v0.0.0-20221014182208-8e78fe927b37/go.mod h1:prNhhUAODrB2VqHVead9tB8nLU9ffY4e4jjBwLMNO1M= -github.com/GoogleContainerTools/kpt-functions-sdk/go/fn v0.0.0-20221013190212-691c71e8ceee h1:AdsG3SitnwYJrCWPVa6X/whonvmbKa5+uOI3tUm3sJU= -github.com/GoogleContainerTools/kpt-functions-sdk/go/fn v0.0.0-20221013190212-691c71e8ceee/go.mod h1:mqc5jH6i0Ll6T4wCmTXsVNVxhwBGlVtrtmoF/g3E9lE= github.com/GoogleContainerTools/kpt-functions-sdk/go/fn v0.0.0-20221014182208-8e78fe927b37 h1:3IBAC+PIdiUyLSuUBCdfWgNUdki0aUcEyvjljfygMpo= github.com/GoogleContainerTools/kpt-functions-sdk/go/fn v0.0.0-20221014182208-8e78fe927b37/go.mod h1:mqc5jH6i0Ll6T4wCmTXsVNVxhwBGlVtrtmoF/g3E9lE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= diff --git a/functions/go/set-namespace/go.mod b/functions/go/set-namespace/go.mod index 64b9bb74f..6eb3152cc 100644 --- a/functions/go/set-namespace/go.mod +++ b/functions/go/set-namespace/go.mod @@ -1,6 +1,6 @@ module github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/set-namespace -go 1.18 +go 1.19 require ( github.com/GoogleContainerTools/kpt-functions-sdk/go/fn v0.0.0-20220706221933-7181f451a663 diff --git a/functions/go/set-project-id/go.mod b/functions/go/set-project-id/go.mod index f38e15a68..54c938678 100644 --- a/functions/go/set-project-id/go.mod +++ b/functions/go/set-project-id/go.mod @@ -1,6 +1,6 @@ module github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/set-project-id -go 1.18 +go 1.19 require ( github.com/GoogleContainerTools/kpt-functions-sdk/go v0.0.0-20210810181223-632b30549de6 diff --git a/functions/go/source-gcloud-config/go.mod b/functions/go/source-gcloud-config/go.mod index 3c31a15dd..94ae2cc21 100644 --- a/functions/go/source-gcloud-config/go.mod +++ b/functions/go/source-gcloud-config/go.mod @@ -1,6 +1,6 @@ module github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/source-gcloud-generator -go 1.18 +go 1.19 require ( gopkg.in/ini.v1 v1.66.4 diff --git a/functions/go/starlark/go.mod b/functions/go/starlark/go.mod index a2a9ac04c..4af5a59f8 100644 --- a/functions/go/starlark/go.mod +++ b/functions/go/starlark/go.mod @@ -1,6 +1,6 @@ module github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/starlark -go 1.18 +go 1.19 require ( github.com/GoogleContainerTools/kpt-functions-sdk/go/fn v0.0.0-20220506190241-f85503febd54 diff --git a/functions/go/starlark/go.sum b/functions/go/starlark/go.sum index 042485280..d6a2aadfd 100644 --- a/functions/go/starlark/go.sum +++ b/functions/go/starlark/go.sum @@ -350,8 +350,6 @@ go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5/go.mod h1:nmDLcffg48OtT/PSW0Hg7FvpRQsQh5OSqIylirxKC7o= go.starlark.net v0.0.0-20210406145628-7a1108eaa012/go.mod h1:t3mmBBPzAVvK0L0n1drDmrQsJ8FoIx4INCqVMTr/Zo0= -go.starlark.net v0.0.0-20210901212718-87f333178d59 h1:F8ArBy9n1l7HE1JjzOIYqweEqoUlywy5+L3bR0tIa9g= -go.starlark.net v0.0.0-20210901212718-87f333178d59/go.mod h1:t3mmBBPzAVvK0L0n1drDmrQsJ8FoIx4INCqVMTr/Zo0= go.starlark.net v0.0.0-20230302034142-4b1e35fe2254 h1:Ss6D3hLXTM0KobyBYEAygXzFfGcjnmfEJOBgSbemCtg= go.starlark.net v0.0.0-20230302034142-4b1e35fe2254/go.mod h1:jxU+3+j+71eXOW14274+SmmuW82qJzl6iZSeqEtTGds= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= diff --git a/functions/go/starlark/third_party/sigs.k8s.io/kustomize/kyaml/fn/runtime/starlark/starlark.go b/functions/go/starlark/third_party/sigs.k8s.io/kustomize/kyaml/fn/runtime/starlark/starlark.go index ef81407cd..b16f0b072 100644 --- a/functions/go/starlark/third_party/sigs.k8s.io/kustomize/kyaml/fn/runtime/starlark/starlark.go +++ b/functions/go/starlark/third_party/sigs.k8s.io/kustomize/kyaml/fn/runtime/starlark/starlark.go @@ -7,8 +7,8 @@ import ( "bytes" "fmt" "io" - "io/ioutil" "net/http" + "os" "github.com/qri-io/starlib/util" "go.starlark.net/resolve" @@ -60,7 +60,7 @@ func (sf *Filter) setup() error { // read the program from a file if sf.Path != "" { - b, err := ioutil.ReadFile(sf.Path) + b, err := os.ReadFile(sf.Path) if err != nil { return err } @@ -75,7 +75,7 @@ func (sf *Filter) setup() error { return err } defer resp.Body.Close() - b, err := ioutil.ReadAll(resp.Body) + b, err := io.ReadAll(resp.Body) if err != nil { return err } diff --git a/functions/go/upsert-resource/go.mod b/functions/go/upsert-resource/go.mod index ed0af4892..b6a614b39 100644 --- a/functions/go/upsert-resource/go.mod +++ b/functions/go/upsert-resource/go.mod @@ -1,6 +1,6 @@ module github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/upsert-resource -go 1.18 +go 1.19 require ( github.com/stretchr/testify v1.6.1 diff --git a/functions/go/upsert-resource/upsertresource/upsert_resource_test.go b/functions/go/upsert-resource/upsertresource/upsert_resource_test.go index 5e6b3429b..e9f1af64f 100644 --- a/functions/go/upsert-resource/upsertresource/upsert_resource_test.go +++ b/functions/go/upsert-resource/upsertresource/upsert_resource_test.go @@ -2,7 +2,6 @@ package upsertresource import ( "bytes" - "io/ioutil" "os" "path/filepath" "testing" @@ -537,13 +536,13 @@ spec: for i := range tests { test := tests[i] t.Run(test.name, func(t *testing.T) { - baseDir, err := ioutil.TempDir("", "") + baseDir, err := os.MkdirTemp("", "") if !assert.NoError(t, err) { t.FailNow() } defer os.RemoveAll(baseDir) - err = ioutil.WriteFile(filepath.Join(baseDir, "f1.yaml"), []byte(test.input), 0700) + err = os.WriteFile(filepath.Join(baseDir, "f1.yaml"), []byte(test.input), 0700) if !assert.NoError(t, err) { t.FailNow() } diff --git a/hack/Dockerfile b/hack/Dockerfile index 305082388..31457d1ca 100644 --- a/hack/Dockerfile +++ b/hack/Dockerfile @@ -25,7 +25,7 @@ RUN apk add --no-cache build-base bash make curl COPY --from=docker/buildx-bin:latest /buildx /usr/libexec/docker/cli-plugins/docker-buildx # Install golang -COPY --from=golang:1.18-alpine /usr/local/go/ /usr/local/go/ +COPY --from=golang:1.19-alpine /usr/local/go/ /usr/local/go/ ENV PATH="/usr/local/go/bin:${PATH}" # Install node and npm