Skip to content

Commit

Permalink
chore: Upgrade Golang to 1.19 (#10176) (#10186)
Browse files Browse the repository at this point in the history
* Upgrade Golang to 1.19

Signed-off-by: OmarKalloush <omar.kalloush@optimumpartners.co>

* go mod tidy with go 1.19

Signed-off-by: OmarKalloush <omar.kalloush@optimumpartners.co>

* Replace deprecated ioutil

Signed-off-by: OmarKalloush <omar.kalloush@optimumpartners.co>

* make codegen changes

Signed-off-by: OmarKalloush <omar.kalloush@optimumpartners.co>

* Codegen Changes

Signed-off-by: OmarKalloush <omar.kalloush@optimumpartners.co>
  • Loading branch information
omarkalloush committed Aug 5, 2022
1 parent 2b11915 commit ce394dd
Show file tree
Hide file tree
Showing 32 changed files with 117 additions and 131 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:

env:
# Golang version to use across CI steps
GOLANG_VERSION: '1.18'
GOLANG_VERSION: '1.19'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
types: [ labeled, unlabeled, opened, synchronize, reopened ]

env:
GOLANG_VERSION: '1.18'
GOLANG_VERSION: '1.19'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
- "!release-v0*"

env:
GOLANG_VERSION: '1.18'
GOLANG_VERSION: '1.19'

jobs:
prepare-release:
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ARG BASE_IMAGE=docker.io/library/ubuntu:22.04
# Initial stage which pulls prepares build dependencies and CLI tooling we need for our final image
# Also used as the image in CI jobs so needs all dependencies
####################################################################################################
FROM docker.io/library/golang:1.18 AS builder
FROM docker.io/library/golang:1.19 AS builder

RUN echo 'deb http://deb.debian.org/debian buster-backports main' >> /etc/apt/sources.list

Expand Down Expand Up @@ -98,7 +98,7 @@ RUN HOST_ARCH=$TARGETARCH NODE_ENV='production' NODE_ONLINE_ENV='online' NODE_OP
####################################################################################################
# Argo CD Build stage which performs the actual build of Argo CD binaries
####################################################################################################
FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.18 AS argocd-build
FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.19 AS argocd-build

WORKDIR /go/src/github.com/argoproj/argo-cd

Expand Down
7 changes: 4 additions & 3 deletions applicationset/utils/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package utils
import (
"bytes"
"context"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"os"
"path/filepath"
"testing"

Expand Down Expand Up @@ -133,9 +134,9 @@ func TestWebhookHandler(t *testing.T) {

req := httptest.NewRequest("POST", "/api/webhook", nil)
req.Header.Set(test.headerKey, test.headerValue)
eventJSON, err := ioutil.ReadFile(filepath.Join("testdata", test.payloadFile))
eventJSON, err := os.ReadFile(filepath.Join("testdata", test.payloadFile))
assert.NoError(t, err)
req.Body = ioutil.NopCloser(bytes.NewReader(eventJSON))
req.Body = io.NopCloser(bytes.NewReader(eventJSON))
w := httptest.NewRecorder()

h.Handler(w, req)
Expand Down
3 changes: 1 addition & 2 deletions cmd/argocd/commands/admin/settings_rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package admin
import (
"context"
"fmt"
"io/ioutil"
"os"

"github.com/ghodss/yaml"
Expand Down Expand Up @@ -263,7 +262,7 @@ func getPolicyFromFile(policyFile string) (string, string, string, error) {
matchMode string
)

upol, err := ioutil.ReadFile(policyFile)
upol, err := os.ReadFile(policyFile)
if err != nil {
log.Fatalf("error opening policy file: %v", err)
return "", "", "", err
Expand Down
8 changes: 4 additions & 4 deletions cmd/util/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package util
import (
"bufio"
"fmt"
"io/ioutil"
"io"
"net/url"
"os"
"strings"
Expand Down Expand Up @@ -159,7 +159,7 @@ func SetAppSpecOptions(flags *pflag.FlagSet, spec *argoappv1.ApplicationSpec, ap
// read uri
parsedURL, err := url.ParseRequestURI(appOpts.values)
if err != nil || !(parsedURL.Scheme == "http" || parsedURL.Scheme == "https") {
data, err = ioutil.ReadFile(appOpts.values)
data, err = os.ReadFile(appOpts.values)
} else {
data, err = config.ReadRemoteFile(appOpts.values)
}
Expand Down Expand Up @@ -520,7 +520,7 @@ func readApps(yml []byte, apps *[]*argoappv1.Application) error {

func readAppsFromStdin(apps *[]*argoappv1.Application) error {
reader := bufio.NewReader(os.Stdin)
data, err := ioutil.ReadAll(reader)
data, err := io.ReadAll(reader)
if err != nil {
return err
}
Expand All @@ -536,7 +536,7 @@ func readAppsFromURI(fileURL string, apps *[]*argoappv1.Application) error {
readFilePayload := func() ([]byte, error) {
parsedURL, err := url.ParseRequestURI(fileURL)
if err != nil || !(parsedURL.Scheme == "http" || parsedURL.Scheme == "https") {
return ioutil.ReadFile(fileURL)
return os.ReadFile(fileURL)
}
return config.ReadRemoteFile(fileURL)
}
Expand Down
5 changes: 2 additions & 3 deletions cmd/util/app_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package util

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

Expand Down Expand Up @@ -254,7 +253,7 @@ spec:
- values.yaml`

func TestReadAppsFromURI(t *testing.T) {
file, err := ioutil.TempFile(os.TempDir(), "")
file, err := os.CreateTemp(os.TempDir(), "")
if err != nil {
panic(err)
}
Expand All @@ -276,7 +275,7 @@ func TestReadAppsFromURI(t *testing.T) {
}

func TestConstructAppFromStdin(t *testing.T) {
file, err := ioutil.TempFile(os.TempDir(), "")
file, err := os.CreateTemp(os.TempDir(), "")
if err != nil {
panic(err)
}
Expand Down
7 changes: 3 additions & 4 deletions cmd/util/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package util

import (
"fmt"
"io/ioutil"
"os"
"sort"
"strings"
Expand Down Expand Up @@ -64,17 +63,17 @@ func NewCluster(name string, namespaces []string, clusterResources bool, conf *r
KeyData: conf.TLSClientConfig.KeyData,
}
if len(conf.TLSClientConfig.CAData) == 0 && conf.TLSClientConfig.CAFile != "" {
data, err := ioutil.ReadFile(conf.TLSClientConfig.CAFile)
data, err := os.ReadFile(conf.TLSClientConfig.CAFile)
errors.CheckError(err)
tlsClientConfig.CAData = data
}
if len(conf.TLSClientConfig.CertData) == 0 && conf.TLSClientConfig.CertFile != "" {
data, err := ioutil.ReadFile(conf.TLSClientConfig.CertFile)
data, err := os.ReadFile(conf.TLSClientConfig.CertFile)
errors.CheckError(err)
tlsClientConfig.CertData = data
}
if len(conf.TLSClientConfig.KeyData) == 0 && conf.TLSClientConfig.KeyFile != "" {
data, err := ioutil.ReadFile(conf.TLSClientConfig.KeyFile)
data, err := os.ReadFile(conf.TLSClientConfig.KeyFile)
errors.CheckError(err)
tlsClientConfig.KeyData = data
}
Expand Down
1 change: 1 addition & 0 deletions cmpserver/apiclient/plugin.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions controller/health_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package controller

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

"github.com/argoproj/gitops-engine/pkg/health"
Expand Down Expand Up @@ -29,7 +29,7 @@ func initStatuses(resources []managedResource) []appv1.ResourceStatus {
}

func resourceFromFile(filePath string) unstructured.Unstructured {
yamlBytes, err := ioutil.ReadFile(filePath)
yamlBytes, err := os.ReadFile(filePath)
if err != nil {
panic(err)
}
Expand Down
3 changes: 1 addition & 2 deletions controller/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package controller

import (
"encoding/json"
"io/ioutil"
"os"
"testing"
"time"
Expand Down Expand Up @@ -481,7 +480,7 @@ func Test_appStateManager_persistRevisionHistory(t *testing.T) {
// helper function to read contents of a file to string
// panics on error
func mustReadFile(path string) string {
b, err := ioutil.ReadFile(path)
b, err := os.ReadFile(path)
if err != nil {
panic(err.Error())
}
Expand Down
58 changes: 29 additions & 29 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/argoproj/argo-cd/v2

go 1.18
go 1.19

require (
code.gitea.io/sdk/gitea v0.15.1
Expand Down Expand Up @@ -100,6 +100,22 @@ require (
sigs.k8s.io/yaml v1.3.0
)

require (
github.com/gfleury/go-bitbucket-v1 v0.0.0-20220301131131-8e7ed04b843e
github.com/stretchr/objx v0.3.0 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
k8s.io/apiserver v0.24.2
)

require (
github.com/gosimple/slug v1.12.0
github.com/microsoft/azure-devops-go-api/azuredevops v1.0.0-b5
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.31.0
go.opentelemetry.io/otel v1.6.3
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.6.3
go.opentelemetry.io/otel/sdk v1.6.3
)

require (
cloud.google.com/go v0.99.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
Expand All @@ -114,6 +130,7 @@ require (
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Masterminds/sprig v2.22.0+incompatible // indirect
github.com/Microsoft/go-winio v0.4.17 // indirect
github.com/PagerDuty/go-pagerduty v1.5.0 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
Expand All @@ -123,6 +140,7 @@ require (
github.com/antonmedv/expr v1.8.9 // indirect
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.1.2 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
Expand All @@ -135,10 +153,10 @@ require (
github.com/felixge/httpsnoop v1.0.1 // indirect
github.com/form3tech-oss/jwt-go v3.2.3+incompatible // indirect
github.com/fvbommel/sortorder v1.0.1 // indirect
github.com/gfleury/go-bitbucket-v1 v0.0.0-20220301131131-8e7ed04b843e
github.com/go-errors/errors v1.0.1 // indirect
github.com/go-git/gcfg v1.5.0 // indirect
github.com/go-git/go-billy/v5 v5.3.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/analysis v0.19.5 // indirect
github.com/go-openapi/errors v0.19.2 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
Expand All @@ -150,16 +168,20 @@ require (
github.com/golang/glog v1.0.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-github/v41 v41.0.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/gosimple/unidecode v1.0.1 // indirect
github.com/gregdel/pushover v1.1.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-version v1.2.1 // indirect
github.com/huandu/xstrings v1.3.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/itchyny/timefmt-go v0.1.2 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jonboulle/clockwork v0.2.2 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
Expand All @@ -179,6 +201,7 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opsgenie/opsgenie-go-sdk-v2 v1.0.5 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
Expand All @@ -190,14 +213,17 @@ require (
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/slack-go/slack v0.10.1 // indirect
github.com/stretchr/objx v0.3.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/vmihailenco/go-tinylfu v0.2.1 // indirect
github.com/vmihailenco/msgpack/v5 v5.3.4 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/xanzy/ssh-agent v0.3.0 // indirect
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca // indirect
go.mongodb.org/mongo-driver v1.1.2 // indirect
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.6.3 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.6.3 // indirect
go.opentelemetry.io/otel/trace v1.6.3 // indirect
go.opentelemetry.io/proto/otlp v0.15.0 // indirect
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
golang.org/x/exp v0.0.0-20210901193431-a062eea981d2 // indirect
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
Expand All @@ -213,10 +239,8 @@ require (
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/apiserver v0.24.2
k8s.io/cli-runtime v0.24.2 // indirect
k8s.io/component-base v0.24.2 // indirect
k8s.io/component-helpers v0.24.2 // indirect
Expand All @@ -228,30 +252,6 @@ require (
sigs.k8s.io/kustomize/kyaml v0.13.6 // indirect
)

require (
github.com/gosimple/slug v1.12.0
github.com/microsoft/azure-devops-go-api/azuredevops v1.0.0-b5
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.31.0
go.opentelemetry.io/otel v1.6.3
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.6.3
go.opentelemetry.io/otel/sdk v1.6.3
)

require (
github.com/PagerDuty/go-pagerduty v1.5.0 // indirect
github.com/cenkalti/backoff/v4 v4.1.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/gosimple/unidecode v1.0.1 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.6.3 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.6.3 // indirect
go.opentelemetry.io/otel/trace v1.6.3 // indirect
go.opentelemetry.io/proto/otlp v0.15.0 // indirect
)

replace (
// https://github.com/golang/go/issues/33546#issuecomment-519656923
github.com/go-check/check => github.com/go-check/check v0.0.0-20180628173108-788fd7840127
Expand Down
3 changes: 1 addition & 2 deletions pkg/apiclient/apiclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"math"
"net"
"net/http"
Expand Down Expand Up @@ -230,7 +229,7 @@ func NewClient(opts *ClientOptions) (Client, error) {
}
// Override certificate data if specified from CLI flag
if opts.CertFile != "" {
b, err := ioutil.ReadFile(opts.CertFile)
b, err := os.ReadFile(opts.CertFile)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit ce394dd

Please sign in to comment.