Skip to content

Commit

Permalink
update go to 1.18 (#46)
Browse files Browse the repository at this point in the history
* update go to 1.18

Signed-off-by: Jonathan Marcantonio <[email protected]>

* fix linters

Signed-off-by: Jonathan Marcantonio <[email protected]>

* fix golangci-lint version

Signed-off-by: Jonathan Marcantonio <[email protected]>

* enable linters gocognit, nolintlint, typecheck

Signed-off-by: Jonathan Marcantonio <[email protected]>
  • Loading branch information
lennysgarage authored Jul 7, 2022
1 parent f86f7d9 commit 1184777
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 140 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go-postsubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

env:
# Common versions
GO_VERSION: '1.17'
GO_VERSION: '1.18'
GO_REQUIRED_MIN_VERSION: ''
GOPATH: '/home/runner/work/multicloud-operators-channel/multicloud-operators-channel/go'
defaults:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/go-presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

env:
# Common versions
GO_VERSION: '1.17'
GO_VERSION: '1.18'
GO_REQUIRED_MIN_VERSION: ''
GOPATH: '/home/runner/work/multicloud-operators-channel/multicloud-operators-channel/go'
defaults:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/go-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- 'v*.*.*'
env:
# Common versions
GO_VERSION: '1.17'
GO_VERSION: '1.18'
GO_REQUIRED_MIN_VERSION: ''
GOPATH: '/home/runner/work/multicloud-operators-channel/multicloud-operators-channel/go'
GITHUB_REF: ${{ github.ref }}
Expand Down
2 changes: 1 addition & 1 deletion build/Dockerfile.prow
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM registry.ci.openshift.org/stolostron/builder:go1.17-linux AS builder
FROM registry.ci.openshift.org/stolostron/builder:go1.18-linux AS builder

WORKDIR /go/src/github.com/stolostron/multicluster-operators-channel
COPY . .
Expand Down
2 changes: 1 addition & 1 deletion build/run-code-lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ gem install mdl
gem install awesome_bot

# Install golangci-lint
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "$(go env GOPATH)"/bin v1.24.0
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "$(go env GOPATH)"/bin v1.46.2

# Start lint task
make -f Makefile.prow lint-all
6 changes: 3 additions & 3 deletions cmd/manager/exec/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ import (

// Change below variables to serve metrics on different host or port.
var (
metricsHost = "0.0.0.0"
metricsPort int = 8384
operatorMetricsPort int = 8687
metricsHost = "0.0.0.0"
metricsPort = 8384
operatorMetricsPort = 8687
)

const (
Expand Down
60 changes: 45 additions & 15 deletions common/config/.golangci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
service:
# When updating this, also update the version stored in docker/build-tools/Dockerfile in the multicloudlab/tools repo.
golangci-lint-version: 1.28.x # use the fixed version to not introduce new linters unexpectedly
golangci-lint-version: 1.46.x # use the fixed version to not introduce new linters unexpectedly
run:
# timeout for analysis, e.g. 30s, 5m, default is 1m
deadline: 20m
timeout: 20m
go: '1.17'

# which dirs to skip: they won't be analyzed;
# can use regexp here: generated.*, regexp is applied on full path;
Expand All @@ -28,31 +29,56 @@ run:
linters:
enable-all: true
disable:
- bodyclose
- containedctx
- contextcheck
- cyclop
- depguard
- dupl
- forbidigo
- funlen
- errchkjson
- exhaustive
- exhaustruct
- exhaustivestruct
- forcetypeassert
- gci
- gochecknoglobals
- gochecknoinits
- goconst
- gocritic
- gocyclo
- godot
- goerr113
- gofumpt
- golint
- gomnd
- gomoddirectives
- gosec
- ifshort
- ineffassign
- interfacer
- ireturn
- maintidx
- maligned
- nakedret
- nestif
- nilnil
- nlreturn
- noctx
- nonamedreturns
- paralleltest
- prealloc
- predeclared
- staticcheck
- scopelint
- funlen
- bodyclose

- tagliatelle
- tenv
- testpackage
- stylecheck
- noctx
- gomnd
- goerr113
- godot
- gofumpt
- nestif
- ineffassign

- godox
- unused
- thelper
- varnamelen
- wastedassign
- wrapcheck
fast: false

linters-settings:
Expand All @@ -64,6 +90,10 @@ linters-settings:
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
# default is false: such cases aren't reported by default.
check-blank: false
nolintlint:
# Disable to ensure that all nolint directives actually have an effect.
# Default: false
allow-unused: true
govet:
# report about shadowed variables
check-shadowing: false
Expand Down
2 changes: 1 addition & 1 deletion common/scripts/lint_go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.28.3
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.46.2

export GOLANGCI_LINT_CACHE=/tmp/golangci-cache
rm -rf $GOLANGCI_LINT_CACHE
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 open-cluster-management.io/multicloud-operators-channel

go 1.17
go 1.18

require (
github.com/aws/aws-sdk-go-v2 v1.13.0
Expand Down
108 changes: 0 additions & 108 deletions go.sum

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions pkg/webhook/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func GenerateSelfSignedCACert(cn string) (Certificate, error) {

priv, err := rsa.GenerateKey(rand.Reader, rsaKeySize)
if err != nil {
return ca, fmt.Errorf("error generating rsa key: %s", err)
return ca, fmt.Errorf("error generating rsa key: %w", err)
}

ca.Cert, ca.Key, err = getCertAndKey(template, priv, template, priv)
Expand All @@ -221,7 +221,7 @@ func GenerateSignedCert(cn string, alternateDNS []string, ca Certificate) (Certi
signerCert, err := x509.ParseCertificate(decodedSignerCert.Bytes)
if err != nil {
return cert, fmt.Errorf(
"error parsing certificate: decodedSignerCert.Bytes: %s",
"error parsing certificate: decodedSignerCert.Bytes: %w",
err,
)
}
Expand All @@ -234,7 +234,7 @@ func GenerateSignedCert(cn string, alternateDNS []string, ca Certificate) (Certi
signerKey, err := x509.ParsePKCS1PrivateKey(decodedSignerKey.Bytes)
if err != nil {
return cert, fmt.Errorf(
"error parsing prive key: decodedSignerKey.Bytes: %s",
"error parsing prive key: decodedSignerKey.Bytes: %w",
err,
)
}
Expand All @@ -246,7 +246,7 @@ func GenerateSignedCert(cn string, alternateDNS []string, ca Certificate) (Certi

priv, err := rsa.GenerateKey(rand.Reader, rsaKeySize)
if err != nil {
return cert, fmt.Errorf("error generating rsa key: %s", err)
return cert, fmt.Errorf("error generating rsa key: %w", err)
}

cert.Cert, cert.Key, err = getCertAndKey(template, priv, signerCert, signerKey)
Expand Down Expand Up @@ -295,15 +295,15 @@ func getCertAndKey(
)

if err != nil {
return "", "", fmt.Errorf("error creating certificate: %s", err)
return "", "", fmt.Errorf("error creating certificate: %w", err)
}

certBuffer := bytes.Buffer{}
if err := pem.Encode(
&certBuffer,
&pem.Block{Type: "CERTIFICATE", Bytes: derBytes},
); err != nil {
return "", "", fmt.Errorf("error pem-encoding certificate: %s", err)
return "", "", fmt.Errorf("error pem-encoding certificate: %w", err)
}

keyBuffer := bytes.Buffer{}
Expand All @@ -314,7 +314,7 @@ func getCertAndKey(
Bytes: x509.MarshalPKCS1PrivateKey(signeeKey),
},
); err != nil {
return "", "", fmt.Errorf("error pem-encoding key: %s", err)
return "", "", fmt.Errorf("error pem-encoding key: %w", err)
}

return certBuffer.String(), keyBuffer.String(), nil
Expand Down

0 comments on commit 1184777

Please sign in to comment.