Skip to content

Commit

Permalink
Use Go 1.19 (#678)
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <tamal@appscode.com>

Signed-off-by: Tamal Saha <tamal@appscode.com>
  • Loading branch information
tamalsaha committed Sep 18, 2022
1 parent 31c24f8 commit 17c6e94
Show file tree
Hide file tree
Showing 23 changed files with 66 additions and 59 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.18
- name: Set up Go 1.19
uses: actions/setup-go@v1
with:
go-version: 1.18
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.18
- name: Set up Go 1.19
uses: actions/setup-go@v1
with:
go-version: 1.18
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ BIN_PLATFORMS := $(DOCKER_PLATFORMS) windows/amd64 darwin/amd64 darwin/arm64
OS := $(if $(GOOS),$(GOOS),$(shell go env GOOS))
ARCH := $(if $(GOARCH),$(GOARCH),$(shell go env GOARCH))

GO_VERSION ?= 1.18
GO_VERSION ?= 1.19
BUILD_IMAGE ?= appscode/golang-dev:$(GO_VERSION)

OUTBIN = bin/$(BIN)-$(OS)-$(ARCH)
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ require (
k8s.io/component-base v0.25.1
k8s.io/klog/v2 v2.80.1
k8s.io/kubectl v0.25.1
kmodules.xyz/client-go v0.25.0
kmodules.xyz/client-go v0.25.2
kmodules.xyz/custom-resources v0.25.0
kmodules.xyz/monitoring-agent-api v0.25.0
kubedb.dev/apimachinery v0.28.4-0.20220917062222-b7b935978ac3
stash.appscode.dev/apimachinery v0.22.1-0.20220917042332-522f4e18711d
kubedb.dev/apimachinery v0.28.4-0.20220918140426-7263b50309d2
stash.appscode.dev/apimachinery v0.22.1-0.20220918134206-55dff33147a0
)

require (
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -983,8 +983,8 @@ k8s.io/kubectl v0.25.1 h1:M488FUhCMLugm5+kACkDMlldaOz0yLzYpQzUvUP+nDE=
k8s.io/kubectl v0.25.1/go.mod h1:ki8ymtGZau2M1lloUV2fqMxP9UCX/i0WIhnWTfqsGSY=
k8s.io/utils v0.0.0-20220823124924-e9cbc92d1a73 h1:H9TCJUUx+2VA0ZiD9lvtaX8fthFsMoD+Izn93E/hm8U=
k8s.io/utils v0.0.0-20220823124924-e9cbc92d1a73/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
kmodules.xyz/client-go v0.25.0 h1:ItlaPAwQEzmle33ieIvT+zSIlZ0sZpwxgtCBD8OJnuE=
kmodules.xyz/client-go v0.25.0/go.mod h1:PQAVWlXoHmk/OXqIuUz3xEW5H04uidiLwVyGX0yYnBQ=
kmodules.xyz/client-go v0.25.2 h1:Uav3RB85b3Pz2dhWI3VQR4XYjSSklpw8EFb88HHpMjI=
kmodules.xyz/client-go v0.25.2/go.mod h1:PQAVWlXoHmk/OXqIuUz3xEW5H04uidiLwVyGX0yYnBQ=
kmodules.xyz/custom-resources v0.25.0 h1:5JQTEuiv6lC/+VVFNKqzfX4YtJCmN5E7mcNtGnHGVQM=
kmodules.xyz/custom-resources v0.25.0/go.mod h1:ULwzvLmOqZJcPSXKI7iLclYL5eYRlKx8Nbex28Ht19E=
kmodules.xyz/monitoring-agent-api v0.25.0 h1:RU9RBeCqQdoS381xXy8cM1aqT+7qmtuPI3KxNQoX16Y=
Expand All @@ -995,8 +995,8 @@ kmodules.xyz/offshoot-api v0.25.0 h1:Svq9da/+sg5afOjpgo9vx2J/Lu90Mo0aFxkdQmgKnGI
kmodules.xyz/offshoot-api v0.25.0/go.mod h1:ysEBn7LJuT3+s8ynAQA/OG0BSsJugXa6KGtDLMRjlKo=
kmodules.xyz/prober v0.25.0 h1:R5uRLHJEvEtEoogj+vaTAob0Btph6+PX5IlS6hPh8PA=
kmodules.xyz/prober v0.25.0/go.mod h1:z4RTnjaajNQa/vPltsiOnO3xI716I/ziD2ac2Exm+1M=
kubedb.dev/apimachinery v0.28.4-0.20220917062222-b7b935978ac3 h1:EHU+0nOAscBY1es+ENe6G4FFRJht+Aqvl48G0H66qqY=
kubedb.dev/apimachinery v0.28.4-0.20220917062222-b7b935978ac3/go.mod h1:rN537raWj+HfZ3SwS7YN4fK3pDA2bMIpTqx8Ab75LYE=
kubedb.dev/apimachinery v0.28.4-0.20220918140426-7263b50309d2 h1:ic4TMCl+Yk3H3t5J9blQWyjEiLFTsKwC7pLtLgQ3+Ak=
kubedb.dev/apimachinery v0.28.4-0.20220918140426-7263b50309d2/go.mod h1:rRH1iTGsGM/1lFii5MqE/7SOd/iQSbeS3YaXhF+s2m8=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
Expand All @@ -1010,5 +1010,5 @@ sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kF
sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E=
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
stash.appscode.dev/apimachinery v0.22.1-0.20220917042332-522f4e18711d h1:nGXRD7UTu0B1ifqKeSpcRsA8RPJa6/rGdtiVYUvoIHE=
stash.appscode.dev/apimachinery v0.22.1-0.20220917042332-522f4e18711d/go.mod h1:f1yvcracYbBFRbabEdX3VFhzgXjOLER2QFvyyBNdeik=
stash.appscode.dev/apimachinery v0.22.1-0.20220918134206-55dff33147a0 h1:GHSuGopU1TXoFnaPLWrXLmwTthd7XWkz0Yj19pLK1qo=
stash.appscode.dev/apimachinery v0.22.1-0.20220918134206-55dff33147a0/go.mod h1:f1yvcracYbBFRbabEdX3VFhzgXjOLER2QFvyyBNdeik=
7 changes: 3 additions & 4 deletions pkg/connect/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package connect
import (
"context"
"fmt"
"io/ioutil"
"log"
"os"

Expand Down Expand Up @@ -175,7 +174,7 @@ func (opts *elasticsearchOpts) getDockerShellCommand(localPort int, dockerFlags,
if !ok {
return nil, fmt.Errorf("missing %s in secret %s/%s", corev1.ServiceAccountRootCAKey, certSecret.Namespace, certSecret.Name)
}
err = ioutil.WriteFile(caFile, caCrt, 0o644)
err = os.WriteFile(caFile, caCrt, 0o644)
if err != nil {
return nil, err
}
Expand All @@ -184,7 +183,7 @@ func (opts *elasticsearchOpts) getDockerShellCommand(localPort int, dockerFlags,
if !ok {
return nil, fmt.Errorf("missing %s in secret %s/%s", corev1.TLSCertKey, certSecret.Namespace, certSecret.Name)
}
err = ioutil.WriteFile(certFile, crt, 0o644)
err = os.WriteFile(certFile, crt, 0o644)
if err != nil {
return nil, err
}
Expand All @@ -193,7 +192,7 @@ func (opts *elasticsearchOpts) getDockerShellCommand(localPort int, dockerFlags,
if !ok {
return nil, fmt.Errorf("missing %s in secret %s/%s", corev1.TLSPrivateKeyKey, certSecret.Namespace, certSecret.Name)
}
err = ioutil.WriteFile(keyFile, key, 0o644)
err = os.WriteFile(keyFile, key, 0o644)
if err != nil {
return nil, err
}
Expand Down
7 changes: 3 additions & 4 deletions pkg/connect/mariadb.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package connect
import (
"context"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -238,7 +237,7 @@ func (opts *mariadbOpts) getDockerShellCommand(localPort int, dockerFlags, mysql
if !ok {
return nil, fmt.Errorf("missing %s in secret %s/%s", corev1.ServiceAccountRootCAKey, certSecret.Namespace, certSecret.Name)
}
err = ioutil.WriteFile(caFile, caCrt, 0o644)
err = os.WriteFile(caFile, caCrt, 0o644)
if err != nil {
return nil, err
}
Expand All @@ -247,7 +246,7 @@ func (opts *mariadbOpts) getDockerShellCommand(localPort int, dockerFlags, mysql
if !ok {
return nil, fmt.Errorf("missing %s in secret %s/%s", corev1.TLSCertKey, certSecret.Namespace, certSecret.Name)
}
err = ioutil.WriteFile(certFile, crt, 0o644)
err = os.WriteFile(certFile, crt, 0o644)
if err != nil {
return nil, err
}
Expand All @@ -256,7 +255,7 @@ func (opts *mariadbOpts) getDockerShellCommand(localPort int, dockerFlags, mysql
if !ok {
return nil, fmt.Errorf("missing %s in secret %s/%s", corev1.TLSPrivateKeyKey, certSecret.Namespace, certSecret.Name)
}
err = ioutil.WriteFile(keyFile, key, 0o644)
err = os.WriteFile(keyFile, key, 0o644)
if err != nil {
return nil, err
}
Expand Down
5 changes: 2 additions & 3 deletions pkg/connect/mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package connect
import (
"context"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -243,7 +242,7 @@ func (opts *mongodbOpts) getDockerShellCommand(localPort int, dockerFlags, mongo
if !ok {
return nil, fmt.Errorf("missing %s in secret %s/%s", corev1.ServiceAccountRootCAKey, certSecret.Namespace, certSecret.Name)
}
err = ioutil.WriteFile(caFile, caCrt, 0o644)
err = os.WriteFile(caFile, caCrt, 0o644)
if err != nil {
return nil, err
}
Expand All @@ -260,7 +259,7 @@ func (opts *mongodbOpts) getDockerShellCommand(localPort int, dockerFlags, mongo

pem := append(crt[:], []byte("\n")...)
pem = append(pem, key...)
err = ioutil.WriteFile(pemFile, pem, 0o644)
err = os.WriteFile(pemFile, pem, 0o644)
if err != nil {
return nil, err
}
Expand Down
7 changes: 3 additions & 4 deletions pkg/connect/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package connect
import (
"context"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -240,7 +239,7 @@ func (opts *mysqlOpts) getDockerShellCommand(localPort int, dockerFlags, mysqlEx
if !ok {
return nil, fmt.Errorf("missing %s in secret %s/%s", corev1.ServiceAccountRootCAKey, certSecret.Namespace, certSecret.Name)
}
err = ioutil.WriteFile(caFile, caCrt, 0o644)
err = os.WriteFile(caFile, caCrt, 0o644)
if err != nil {
return nil, err
}
Expand All @@ -249,7 +248,7 @@ func (opts *mysqlOpts) getDockerShellCommand(localPort int, dockerFlags, mysqlEx
if !ok {
return nil, fmt.Errorf("missing %s in secret %s/%s", corev1.TLSCertKey, certSecret.Namespace, certSecret.Name)
}
err = ioutil.WriteFile(certFile, crt, 0o644)
err = os.WriteFile(certFile, crt, 0o644)
if err != nil {
return nil, err
}
Expand All @@ -258,7 +257,7 @@ func (opts *mysqlOpts) getDockerShellCommand(localPort int, dockerFlags, mysqlEx
if !ok {
return nil, fmt.Errorf("missing %s in secret %s/%s", corev1.TLSPrivateKeyKey, certSecret.Namespace, certSecret.Name)
}
err = ioutil.WriteFile(keyFile, key, 0o644)
err = os.WriteFile(keyFile, key, 0o644)
if err != nil {
return nil, err
}
Expand Down
7 changes: 3 additions & 4 deletions pkg/connect/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"bytes"
"context"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -255,7 +254,7 @@ func (opts *postgresOpts) getDockerShellCommand(localPort int, dockerFlags, post
if !ok {
return nil, fmt.Errorf("missing %s in secret %s/%s", corev1.ServiceAccountRootCAKey, certSecret.Namespace, certSecret.Name)
}
err = ioutil.WriteFile(pgCaFile, caCrt, 0o644)
err = os.WriteFile(pgCaFile, caCrt, 0o644)
if err != nil {
return nil, err
}
Expand All @@ -264,7 +263,7 @@ func (opts *postgresOpts) getDockerShellCommand(localPort int, dockerFlags, post
if !ok {
return nil, fmt.Errorf("missing %s in secret %s/%s", corev1.TLSCertKey, certSecret.Namespace, certSecret.Name)
}
err = ioutil.WriteFile(pgCertFile, crt, 0o644)
err = os.WriteFile(pgCertFile, crt, 0o644)
if err != nil {
return nil, err
}
Expand All @@ -273,7 +272,7 @@ func (opts *postgresOpts) getDockerShellCommand(localPort int, dockerFlags, post
if !ok {
return nil, fmt.Errorf("missing %s in secret %s/%s", corev1.TLSPrivateKeyKey, certSecret.Namespace, certSecret.Name)
}
err = ioutil.WriteFile(pgKeyFile, key, 0o600)
err = os.WriteFile(pgKeyFile, key, 0o600)
if err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/connect/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"bytes"
"context"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -289,7 +288,7 @@ func (opts *redisOpts) executeFile(fileName string) error {
if err != nil {
return err
}
fileData, err := ioutil.ReadFile(fileName)
fileData, err := os.ReadFile(fileName)
if err != nil {
return err
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/describer/describer.go
Original file line number Diff line number Diff line change
Expand Up @@ -641,12 +641,14 @@ func tabbedString(f func(io.Writer) error) (string, error) {
}

// printAnnotationsMultilineWithFilter prints filtered multiple annotations with a proper alignment.
//
//nolint:unparam
func printAnnotationsMultilineWithFilter(level int, w describe.PrefixWriter, title string, annotations map[string]string, skip sets.String) {
printAnnotationsMultilineWithIndent(level, w, "", title, "\t", annotations, skip)
}

// printAnnotationsMultiline prints multiple annotations with a proper alignment.
//
//nolint:unparam
func printAnnotationsMultiline(level int, w describe.PrefixWriter, title string, annotations map[string]string) {
printAnnotationsMultilineWithIndent(level, w, "", title, "\t", annotations, sets.NewString())
Expand Down
2 changes: 1 addition & 1 deletion vendor/kmodules.xyz/client-go/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ ARCH := $(if $(GOARCH),$(GOARCH),$(shell go env GOARCH))
BASEIMAGE_PROD ?= gcr.io/distroless/static-debian11
BASEIMAGE_DBG ?= debian:bullseye

GO_VERSION ?= 1.18
GO_VERSION ?= 1.19
BUILD_IMAGE ?= appscode/golang-dev:$(GO_VERSION)

OUTBIN = bin/$(OS)_$(ARCH)/$(BIN)
Expand Down
20 changes: 16 additions & 4 deletions vendor/kmodules.xyz/client-go/discovery/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,23 @@ func CheckAPIVersion(client discovery.DiscoveryInterface, constraint string) (bo
}

func IsPreferredAPIResource(client discovery.DiscoveryInterface, groupVersion, kind string) bool {
return ExistsGroupVersionKind(client, groupVersion, kind)
if resourceList, err := client.ServerPreferredResources(); discovery.IsGroupDiscoveryFailedError(err) || err == nil {
for _, resources := range resourceList {
if resources.GroupVersion != groupVersion {
continue
}
for _, resource := range resources.APIResources {
if resource.Kind == kind {
return true
}
}
}
}
return false
}

func ExistsGroupVersionKind(client discovery.DiscoveryInterface, groupVersion, kind string) bool {
if resourceList, err := client.ServerPreferredResources(); discovery.IsGroupDiscoveryFailedError(err) || err == nil {
if _, resourceList, err := client.ServerGroupsAndResources(); discovery.IsGroupDiscoveryFailedError(err) || err == nil {
for _, resources := range resourceList {
if resources.GroupVersion != groupVersion {
continue
Expand All @@ -116,7 +128,7 @@ func ExistsGroupVersionKind(client discovery.DiscoveryInterface, groupVersion, k
}

func ExistsGroupKind(client discovery.DiscoveryInterface, group, kind string) bool {
if resourceList, err := client.ServerPreferredResources(); discovery.IsGroupDiscoveryFailedError(err) || err == nil {
if _, resourceList, err := client.ServerGroupsAndResources(); discovery.IsGroupDiscoveryFailedError(err) || err == nil {
for _, resources := range resourceList {
gv, err := schema.ParseGroupVersion(resources.GroupVersion)
if err != nil {
Expand All @@ -142,7 +154,7 @@ func ExistsGroupKinds(client discovery.DiscoveryInterface, gk schema.GroupKind,
desired[other] = false
}

if resourceList, err := client.ServerPreferredResources(); discovery.IsGroupDiscoveryFailedError(err) || err == nil {
if _, resourceList, err := client.ServerGroupsAndResources(); discovery.IsGroupDiscoveryFailedError(err) || err == nil {
for _, resources := range resourceList {
gv, err := schema.ParseGroupVersion(resources.GroupVersion)
if err != nil {
Expand Down
13 changes: 7 additions & 6 deletions vendor/kmodules.xyz/client-go/meta/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ package meta
import (
"crypto/x509"
"errors"
"io/ioutil"
"io"
"net/http"
"os"
"strings"
"time"

Expand All @@ -30,7 +31,7 @@ import (
// ref: https://cloud.google.com/compute/docs/storing-retrieving-metadata
func TestGKE() (string, error) {
// ref: https://github.com/kubernetes/kubernetes/blob/a0f94123616c275f94e7a5b680d60d6f34e92f37/pkg/credentialprovider/gcp/metadata.go#L115
data, err := ioutil.ReadFile("/sys/class/dmi/id/product_name")
data, err := os.ReadFile("/sys/class/dmi/id/product_name")
if err != nil {
return "", err
}
Expand All @@ -50,7 +51,7 @@ func TestGKE() (string, error) {
return "", err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -79,13 +80,13 @@ func TestAKS(cert *x509.Certificate) (string, error) {

// ref: https://cloud.google.com/compute/docs/storing-retrieving-metadata
func isAKS() error {
data, err := ioutil.ReadFile("/sys/class/dmi/id/sys_vendor")
data, err := os.ReadFile("/sys/class/dmi/id/sys_vendor")
if err != nil {
return err
}
sysVendor := strings.TrimSpace(string(data))

data, err = ioutil.ReadFile("/sys/class/dmi/id/product_name")
data, err = os.ReadFile("/sys/class/dmi/id/product_name")
if err != nil {
return err
}
Expand All @@ -110,7 +111,7 @@ func TestEKS(cert *x509.Certificate) (string, error) {

// ref: https://cloud.google.com/compute/docs/storing-retrieving-metadata
func isEKS() error {
data, err := ioutil.ReadFile("/sys/class/dmi/id/sys_vendor")
data, err := os.ReadFile("/sys/class/dmi/id/sys_vendor")
if err != nil {
return err
}
Expand Down
1 change: 0 additions & 1 deletion vendor/kmodules.xyz/client-go/meta/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ func UnmarshalFromJSON(data []byte, gv schema.GroupVersion) (runtime.Object, err
//
// WARNING: `json` tags are not respected when struct converted to map[string]interface{}
// WARNING: Embedded structs are not decoded properly: https://github.com/mitchellh/mapstructure/pull/80
//
func Decode(input interface{}, output interface{}) error {
config := &mapstructure.DecoderConfig{
DecodeHook: StringToQuantityHookFunc(),
Expand Down
Loading

0 comments on commit 17c6e94

Please sign in to comment.