Skip to content

Commit

Permalink
update go functions to go 1.19 (#1036)
Browse files Browse the repository at this point in the history
  • Loading branch information
natasha41575 authored Apr 1, 2023
1 parent 300aad7 commit 5b2e679
Show file tree
Hide file tree
Showing 44 changed files with 73 additions and 91 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/verify-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion build/docker/go/defaults.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
BUILDER_IMAGE=golang:1.18-alpine3.15
BUILDER_IMAGE=golang:1.19-alpine3.15
BASE_IMAGE=alpine:3.15
2 changes: 1 addition & 1 deletion functions/go/apply-replacements/go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 4 additions & 5 deletions functions/go/apply-setters/applysetters/apply_setters_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package applysetters

import (
"io/ioutil"
"os"
"testing"

Expand Down Expand Up @@ -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()
}
Expand Down Expand Up @@ -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()
}
Expand Down
2 changes: 1 addition & 1 deletion functions/go/apply-setters/go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package createsetters

import (
"fmt"
"io/ioutil"
"os"
"sort"
"strings"
Expand Down Expand Up @@ -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()
}
Expand Down Expand Up @@ -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()
}
Expand Down
2 changes: 1 addition & 1 deletion functions/go/create-setters/go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package gcpservices

import (
"bytes"
"io/ioutil"
"os"
"path"
"testing"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion functions/go/enable-gcp-services/go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion functions/go/ensure-name-substring/go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion functions/go/export-terraform/go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package terraformgenerator

import (
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions functions/go/fix/fixpkg/fix_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package fixpkg

import (
"io/ioutil"
"os"
"testing"

Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion functions/go/fix/go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion functions/go/format/go.mod
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion functions/go/gatekeeper/go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 2 additions & 3 deletions functions/go/gatekeeper/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package main
import (
"bytes"
"fmt"
"io/ioutil"
"os"

"github.com/GoogleContainerTools/kpt-functions-catalog/functions/go/gatekeeper/generated"
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion functions/go/generate-kpt-pkg-docs/go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 3 additions & 4 deletions functions/go/generate-kpt-pkg-docs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion functions/go/go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 3 additions & 4 deletions functions/go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand All @@ -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=
Expand All @@ -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=
Expand Down
2 changes: 1 addition & 1 deletion functions/go/list-setters/go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading

0 comments on commit 5b2e679

Please sign in to comment.