Skip to content

Commit

Permalink
Merge pull request #2418 from carolynvs/go1.19
Browse files Browse the repository at this point in the history
Use Go 1.19
  • Loading branch information
carolynvs authored Oct 11, 2022
2 parents 1b801fe + 8ad1834 commit 91676a6
Show file tree
Hide file tree
Showing 52 changed files with 133 additions and 150 deletions.
11 changes: 2 additions & 9 deletions .github/workflows/security-scan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,8 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
check-latest: true
- name: Set up Cache
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
go-version-file: go.mod
cache: true
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion build/azure-pipelines.integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pool:
vmImage: "ubuntu-latest"

variables: # these are really constants
GOVERSION: "1.18"
GOVERSION: "1.19.2"
# Cache go modules and the results of go build/test
# Increment the version number prefix of the key and restoreKey to clear the cache
GOCACHE: $(Pipeline.Workspace)/.cache/go-build/
Expand Down
2 changes: 1 addition & 1 deletion build/azure-pipelines.pr-automatic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pool:
vmImage: "ubuntu-latest"

variables:
GOVERSION: "1.18"
GOVERSION: "1.19.2"
# Cache go modules and the results of go build/test
# Increment the version number prefix of the key and restoreKey to clear the cache
GOCACHE: $(Pipeline.Workspace)/.cache/go-build/
Expand Down
4 changes: 2 additions & 2 deletions build/azure-pipelines.release-template.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
variables: # these are really constants
vmImage: "ubuntu-latest"
GOVERSION: "1.18"
GOVERSION: "1.19.2"
# Cache go modules and the results of go build/test
# Increment the version number prefix of the key and restoreKey to clear the cache
GOCACHE: $(Pipeline.Workspace)/.cache/go-build/
Expand All @@ -22,7 +22,7 @@ variables: # these are really constants
parameters:
- name: goVersion
type: string
default: "1.18"
default: "1.19.2"
- name: registry
type: string
default: ghcr.io/getporter/test
Expand Down
2 changes: 1 addition & 1 deletion docs/content/contribute/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ need a few things.
If you are new to Git or GitHub, we recommend reading the [GitHub Guides].
They will walk you through installing Git, forking a repository and
submitting a pull request.
* [Go](https://golang.org/doc/install) version 1.18 or higher
* [Go](https://golang.org/doc/install) version 1.19 or higher
* [Docker]
* [Mage](#install-mage)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module get.porter.sh/porter

go 1.18
go 1.19

replace (
// a dependency of buildx (github.com/tonistiigi/fsutil) relies on an untagged version of Docker on the master branch
Expand Down
11 changes: 5 additions & 6 deletions mage/docs/docs_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package docs

import (
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand All @@ -13,7 +12,7 @@ import (

func TestEnsureOperatorRepository(t *testing.T) {
t.Run("has local repo", func(t *testing.T) {
tmp, err := ioutil.TempDir("", "porter-docs-test")
tmp, err := os.MkdirTemp("", "porter-docs-test")
require.NoError(t, err)
defer os.RemoveAll(tmp)

Expand All @@ -23,7 +22,7 @@ func TestEnsureOperatorRepository(t *testing.T) {
})

t.Run("missing local repo", func(t *testing.T) {
tmp, err := ioutil.TempDir("", "porter-docs-test")
tmp, err := os.MkdirTemp("", "porter-docs-test")
require.NoError(t, err)
defer os.RemoveAll(tmp)

Expand All @@ -33,7 +32,7 @@ func TestEnsureOperatorRepository(t *testing.T) {
})

t.Run("local repo unset", func(t *testing.T) {
tmp, err := ioutil.TempDir("", "porter-docs-test")
tmp, err := os.MkdirTemp("", "porter-docs-test")
require.NoError(t, err)
defer os.RemoveAll(tmp)

Expand All @@ -43,7 +42,7 @@ func TestEnsureOperatorRepository(t *testing.T) {
})

t.Run("empty default path clones repo", func(t *testing.T) {
tmp, err := ioutil.TempDir("", "porter-docs-test")
tmp, err := os.MkdirTemp("", "porter-docs-test")
require.NoError(t, err)
defer os.RemoveAll(tmp)

Expand All @@ -56,7 +55,7 @@ func TestEnsureOperatorRepository(t *testing.T) {
})

t.Run("changes in default path are reset", func(t *testing.T) {
tmp, err := ioutil.TempDir("", "porter-docs-test")
tmp, err := os.MkdirTemp("", "porter-docs-test")
require.NoError(t, err)
defer os.RemoveAll(tmp)

Expand Down
3 changes: 1 addition & 2 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package main
import (
"fmt"
"go/build"
"io/ioutil"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -495,7 +494,7 @@ func Install() {

// Copy mixin binaries
mixinsDir := filepath.Join("bin", "mixins")
mixinsDirItems, err := ioutil.ReadDir(mixinsDir)
mixinsDirItems, err := os.ReadDir(mixinsDir)
if err != nil {
mgx.Must(fmt.Errorf("could not list mixins in bin: %w", err))
}
Expand Down
2 changes: 1 addition & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

[build.environment]
HUGO_VERSION = "0.78.1"
GO_VERSION = "1.18.5"
GO_VERSION = "1.19.2"

[context.branch-deploy]
command = "go run mage.go -v DocsBranchPreview"
Expand Down
3 changes: 1 addition & 2 deletions pkg/agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package agent

import (
"bytes"
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -55,7 +54,7 @@ func TestExecute(t *testing.T) {
}

func makeTestPorterHome(t *testing.T) string {
home, err := ioutil.TempDir("", "porter-home")
home, err := os.MkdirTemp("", "porter-home")
require.NoError(t, err)
require.NoError(t, shx.Copy("../../bin/porter", home))
return home
Expand Down
5 changes: 2 additions & 3 deletions pkg/cnab/config-adapter/adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"os"
"testing"

Expand Down Expand Up @@ -873,15 +872,15 @@ func TestManifestConverter_generateCustomMetadata(t *testing.T) {
require.NoError(t, err, "ToBundle failed")
assert.Len(t, bun.Custom, 4)

f, err := ioutil.TempFile("", "")
f, err := os.CreateTemp("", "")
require.NoError(t, err, "Failed to create bundle file")
defer os.Remove(f.Name())

_, err = bun.WriteTo(f)
require.NoError(t, err, "Failed to write bundle file")

expectedCustomMetaData := "{\"foo\":{\"test1\":true,\"test2\":1,\"test3\":\"value\",\"test4\":[\"one\",\"two\",\"three\"],\"test5\":{\"1\":\"one\",\"two\":\"two\"}}"
bundleData, err := ioutil.ReadFile(f.Name())
bundleData, err := os.ReadFile(f.Name())
require.NoError(t, err, "Failed to read bundle file")

assert.Contains(t, string(bundleData), expectedCustomMetaData, "Created bundle should be equal to expected bundle ")
Expand Down
4 changes: 2 additions & 2 deletions pkg/cnab/dependencies_v1_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cnab

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

"github.com/cnabio/cnab-go/bundle"
Expand All @@ -12,7 +12,7 @@ import (
func TestReadDependencyV1Properties(t *testing.T) {
t.Parallel()

data, err := ioutil.ReadFile("testdata/bundle.json")
data, err := os.ReadFile("testdata/bundle.json")
require.NoError(t, err, "cannot read bundle file")

b, err := bundle.Unmarshal(data)
Expand Down
4 changes: 2 additions & 2 deletions pkg/cnab/helpers.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package cnab

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

"github.com/cnabio/cnab-go/bundle"
"github.com/stretchr/testify/require"
)

func ReadTestBundle(t *testing.T, path string) ExtendedBundle {
bunD, err := ioutil.ReadFile(path)
bunD, err := os.ReadFile(path)
require.NoError(t, err, "ReadFile failed for %s", path)

bun, err := bundle.Unmarshal(bunD)
Expand Down
4 changes: 2 additions & 2 deletions pkg/cnab/parameter_sources_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cnab

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

"github.com/cnabio/cnab-go/bundle"
Expand Down Expand Up @@ -55,7 +55,7 @@ func TestProcessedExtensions_GetParameterSourcesExtension(t *testing.T) {
func TestReadParameterSourcesProperties(t *testing.T) {
t.Parallel()

data, err := ioutil.ReadFile("testdata/bundle.json")
data, err := os.ReadFile("testdata/bundle.json")
require.NoError(t, err, "cannot read bundle file")

b, err := bundle.Unmarshal(data)
Expand Down
4 changes: 2 additions & 2 deletions pkg/cnab/provider/action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cnabprovider

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

"github.com/cnabio/cnab-go/bundle"
Expand All @@ -14,7 +14,7 @@ import (
func TestAddRelocation(t *testing.T) {
t.Parallel()

data, err := ioutil.ReadFile("testdata/relocation-mapping.json")
data, err := os.ReadFile("testdata/relocation-mapping.json")
require.NoError(t, err)

d := NewTestRuntime(t)
Expand Down
34 changes: 18 additions & 16 deletions pkg/exec/builder/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bufio"
"context"
"fmt"
"io/ioutil"
"io"

"get.porter.sh/porter/pkg/runtime"
"get.porter.sh/porter/pkg/tracing"
Expand All @@ -13,16 +13,17 @@ import (

// UnmarshalAction handles unmarshaling any action, given a pointer to a slice of Steps.
// Iterate over the results and cast back to the Steps to use the results.
// var steps []Step
// results, err := UnmarshalAction(unmarshal, &steps)
// if err != nil {
// return err
// }
//
// for _, result := range results {
// step := result.(*[]Step)
// a.Steps = append(a.Steps, *step...)
// }
// var steps []Step
// results, err := UnmarshalAction(unmarshal, &steps)
// if err != nil {
// return err
// }
//
// for _, result := range results {
// step := result.(*[]Step)
// a.Steps = append(a.Steps, *step...)
// }
func UnmarshalAction(unmarshal func(interface{}) error, builder BuildableAction) (map[string][]interface{}, error) {
actionMap := map[string][]interface{}{}
err := unmarshal(&actionMap)
Expand Down Expand Up @@ -70,11 +71,12 @@ func unmarshalActionMap(actionMap map[string][]interface{}, builder BuildableAct
// Action instance.
//
// Example:
// var action Action
// err := builder.LoadAction(m.Context, opts.File, func(contents []byte) (interface{}, error) {
// err := yaml.Unmarshal(contents, &action)
// return &action, err
// })
//
// var action Action
// err := builder.LoadAction(m.Context, opts.File, func(contents []byte) (interface{}, error) {
// err := yaml.Unmarshal(contents, &action)
// return &action, err
// })
func LoadAction(ctx context.Context, cfg runtime.RuntimeConfig, commandFile string, unmarshal func([]byte) (interface{}, error)) error {
//lint:ignore SA4006 ignore unused ctx for now
ctx, span := tracing.StartSpan(ctx)
Expand All @@ -98,7 +100,7 @@ func readInputFromStdinOrFile(cfg runtime.RuntimeConfig, commandFile string) ([]
var err error
if commandFile == "" {
reader := bufio.NewReader(cfg.In)
b, err = ioutil.ReadAll(reader)
b, err = io.ReadAll(reader)
} else {
b, err = cfg.FileSystem.ReadFile(commandFile)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/exec/builder/flags_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package builder

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

Expand All @@ -13,7 +13,7 @@ import (
var testStep = TestStep{}

func TestFlags_UnmarshalYAML(t *testing.T) {
b, err := ioutil.ReadFile("testdata/flags-input.yaml")
b, err := os.ReadFile("testdata/flags-input.yaml")
require.NoError(t, err, "could not read the input file")

var flags Flags
Expand Down
4 changes: 2 additions & 2 deletions pkg/exec/builder/output_jsonpath_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package builder

import (
"context"
"io/ioutil"
"os"
"path/filepath"
"testing"

Expand Down Expand Up @@ -73,7 +73,7 @@ func TestJsonPathOutputs(t *testing.T) {
{"string", "$[0].cpuPlatform", `Intel Haswell`},
}

stdout, err := ioutil.ReadFile("testdata/install-output.json")
stdout, err := os.ReadFile("testdata/install-output.json")
require.NoError(t, err, "could not read testdata")

for _, tc := range testcases {
Expand Down
6 changes: 3 additions & 3 deletions pkg/exec/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"context"
"fmt"
"io/ioutil"
"os"
"sort"
"testing"

Expand All @@ -16,7 +16,7 @@ import (
)

func TestAction_UnmarshalYAML(t *testing.T) {
b, err := ioutil.ReadFile("testdata/install-input.yaml")
b, err := os.ReadFile("testdata/install-input.yaml")
require.NoError(t, err)

action := Action{}
Expand Down Expand Up @@ -171,7 +171,7 @@ func TestMixin_Uninstall(t *testing.T) {

func TestMixin_SuffixArgs(t *testing.T) {
ctx := context.Background()
b, err := ioutil.ReadFile("testdata/suffix-args-input.yaml")
b, err := os.ReadFile("testdata/suffix-args-input.yaml")
require.NoError(t, err, "ReadFile failed")

var action Action
Expand Down
Loading

0 comments on commit 91676a6

Please sign in to comment.