Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump go lib to 1.21 #98

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .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.20'
GO_VERSION: '1.21'
GO_REQUIRED_MIN_VERSION: ''
GOPATH: '/home/runner/work/multicloud-integrations/multicloud-integrations/go'
defaults:
Expand All @@ -32,9 +32,9 @@ jobs:
- name: test
run: make test
- name: report-coverage
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_UPLOAD_TOKEN }}
token: ${{ secrets.CODECOV_TOKEN }}
files: /home/runner/work/multicloud-integrations/multicloud-integrations/go/src/github.com/open-cluster-management/multicloud-integrations/coverage.out,/home/runner/work/multicloud-integrations/multicloud-integrations/go/src/github.com/open-cluster-management/multicloud-integrations/prop_coverage.out
flags: unit
name: unit
Expand Down
6 changes: 3 additions & 3 deletions .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.20'
GO_VERSION: '1.21'
GO_REQUIRED_MIN_VERSION: ''
GOPATH: '/home/runner/work/multicloud-integrations/multicloud-integrations/go'
defaults:
Expand Down Expand Up @@ -82,9 +82,9 @@ jobs:
- name: test
run: make test
- name: report-coverage
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_UPLOAD_TOKEN }}
token: ${{ secrets.CODECOV_TOKEN }}
files: /home/runner/work/multicloud-integrations/multicloud-integrations/go/src/github.com/open-cluster-management/multicloud-integrations/coverage.out,/home/runner/work/multicloud-integrations/multicloud-integrations/go/src/github.com/open-cluster-management/multicloud-integrations/prop_coverage.out
flags: unit
name: unit
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.20'
GO_VERSION: '1.21'
GO_REQUIRED_MIN_VERSION: ''
GOPATH: '/home/runner/work/multicloud-integrations/multicloud-integrations/go'
GITHUB_REF: ${{ github.ref }}
Expand Down
2 changes: 1 addition & 1 deletion build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM registry.ci.openshift.org/stolostron/builder:go1.20-linux AS builder
FROM registry.ci.openshift.org/stolostron/builder:go1.21-linux AS builder

WORKDIR /go/src/github.com/open-cluster-management-io/multicloud-integrations
COPY . .
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.20-linux AS builder
FROM registry.ci.openshift.org/stolostron/builder:go1.21-linux AS builder

WORKDIR /go/src/github.com/stolostron/multicloud-integrations
COPY . .
Expand Down
2 changes: 1 addition & 1 deletion build/Dockerfile.rhtap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:rhel_8_1.20 AS builder
FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:rhel_8_1.21 AS builder

WORKDIR /go/src/github.com/open-cluster-management-io/multicloud-integrations
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 @@ -22,7 +22,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.51.2
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "$(go env GOPATH)"/bin v1.57.2

# Start lint task
make -f Makefile.prow lint-all
11 changes: 6 additions & 5 deletions cmd/gitopscluster/exec/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ import (
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
)

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

// RunManager starts the actual manager
Expand All @@ -62,8 +62,9 @@ func RunManager() {

// Create a new Cmd to provide shared dependencies and start components
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
MetricsBindAddress: fmt.Sprintf("%s:%d", metricsHost, metricsPort),
Port: operatorMetricsPort,
Metrics: metricsserver.Options{
BindAddress: fmt.Sprintf("%s:%d", metricsHost, metricsPort),
},
LeaderElection: enableLeaderElection,
LeaderElectionID: "multicloud-operators-gitopscluster-leader.open-cluster-management.io",
LeaderElectionNamespace: "kube-system",
Expand Down
11 changes: 6 additions & 5 deletions cmd/gitopssyncresc/exec/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ import (
"k8s.io/klog"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
)

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

// RunManager starts the actual manager
Expand All @@ -57,8 +57,9 @@ func RunManager() {

// Create a new Cmd to provide shared dependencies and start components
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
MetricsBindAddress: fmt.Sprintf("%s:%d", metricsHost, metricsPort),
Port: operatorMetricsPort,
Metrics: metricsserver.Options{
BindAddress: fmt.Sprintf("%s:%d", metricsHost, metricsPort),
},
LeaderElection: enableLeaderElection,
LeaderElectionID: "multicloud-operators-gitopssyncresc-leader.open-cluster-management.io",
LeaderElectionNamespace: "kube-system",
Expand Down
11 changes: 6 additions & 5 deletions cmd/multiclusterstatusaggregation/exec/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
)

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

// RunManager starts the actual manager
Expand Down Expand Up @@ -74,8 +74,9 @@ func RunManager() {
"retryPeriod", options.LeaderElectionRetryPeriod)

mgr, err := ctrl.NewManager(cfg, ctrl.Options{
MetricsBindAddress: fmt.Sprintf("%s:%d", metricsHost, metricsPort),
Port: operatorMetricsPort,
Metrics: metricsserver.Options{
BindAddress: fmt.Sprintf("%s:%d", metricsHost, metricsPort),
},
LeaderElection: enableLeaderElection,
LeaderElectionID: "multicloud-operators-multiclusterstatusaggregation-leader.open-cluster-management.io",
LeaderElectionNamespace: "kube-system",
Expand Down
19 changes: 11 additions & 8 deletions cmd/propagation/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
argov1alpha1 "open-cluster-management.io/multicloud-integrations/pkg/apis/argocd/v1alpha1"
"open-cluster-management.io/multicloud-integrations/propagation-controller/application"
"sigs.k8s.io/controller-runtime/pkg/client"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
)

// PropagationCMDOptions for command line flag parsing
Expand All @@ -62,11 +63,10 @@ var options = PropagationCMDOptions{
}

var (
scheme = runtime.NewScheme()
setupLog = ctrl.Log.WithName("setup")
metricsHost = "0.0.0.0"
metricsPort = 8386
operatorMetricsPort = 8698
scheme = runtime.NewScheme()
setupLog = ctrl.Log.WithName("setup")
metricsHost = "0.0.0.0"
metricsPort = 8386
)

func init() {
Expand All @@ -79,6 +79,7 @@ func init() {

func main() {
var enableLeaderElection bool

flag.StringVar(
&options.MetricsAddr,
"metrics-addr",
Expand Down Expand Up @@ -137,9 +138,10 @@ func main() {

// Create a new Cmd to provide shared dependencies and start components
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: fmt.Sprintf("%s:%d", metricsHost, metricsPort),
Port: operatorMetricsPort,
Scheme: scheme,
Metrics: metricsserver.Options{
BindAddress: fmt.Sprintf("%s:%d", metricsHost, metricsPort),
},
LeaderElection: enableLeaderElection,
LeaderElectionID: "multicloud-operators-propagation-leader.open-cluster-management.io",
LeaderElectionNamespace: "kube-system",
Expand Down Expand Up @@ -189,6 +191,7 @@ func main() {
}

setupLog.Info("starting manager")

if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {
setupLog.Error(err, "problem running manager")
os.Exit(1)
Expand Down
69 changes: 42 additions & 27 deletions common/config/.golangci.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,16 @@
service:
# When updating this, also update the version stored in docker/build-tools/Dockerfile in the multicloudlab/tools repo.
golangci-lint-version: 1.51.x # use the fixed version to not introduce new linters unexpectedly
golangci-lint-version: 1.57.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;
# default value is empty list, but next dirs are always skipped independently
# from this option's value:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs:
- genfiles$
- vendor$
- vbh$
- pkg/apis/argocd/v1alpha1$
- propagation-controller/application$
- cmd/propagation$

# which files to skip: they will be analyzed, but issues from them
# won't be reported. Default value is empty list, but there is
# no need to include all autogenerated files, we confidently recognize
# autogenerated files. If it's not please let us know.
skip-files:
- ".*\\.pb\\.go"
- ".*\\.gen\\.go"

linters:
enable-all: true
disable:
- asasalint
- bodyclose
- containedctx
- contextcheck
- cyclop
- deadcode
Expand Down Expand Up @@ -61,36 +39,61 @@ linters:
- gosec
- ifshort
- ineffassign
- interfacebloat
- interfacer
- ireturn
- loggercheck
- maintidx
- maligned
- musttag
- nakedret
- nestif
- nilerr
- nilnil
- nlreturn
- noctx
- nosnakecase
- nonamedreturns
- nosnakecase
- paralleltest
- prealloc
- predeclared
- rowserrcheck
- scopelint
- staticcheck
- structcheck
- scopelint
- sqlclosecheck
- tagliatelle
- tenv
- testpackage
- thelper
- usestdlibvars
- varcheck
- varnamelen
- wastedassign
- wrapcheck
- varcheck
- inamedparam
- revive
- mirror
- godox
- lll
- tagalign
- stylecheck
fast: false

linters-settings:
testifylint:
disable:
- require-error
- expected-actual
perfsprint:
errorf: false
sprintf1: false
strconcat: false
wsl:
allow-assign-and-anything: true
strict-append: false

errcheck:
# report about not checking of errors in type assetions: `a := b.(MyStruct)`;
# default is false: such cases aren't reported by default.
Expand All @@ -111,7 +114,7 @@ linters-settings:
min-confidence: 0.0
gocognit:
# minimal code complexity to report, 30 by default (but we recommend 10-20)
min-complexity: 75
min-complexity: 200
gofmt:
# simplify code: gofmt with `-s` option, true by default
simplify: true
Expand Down Expand Up @@ -213,6 +216,7 @@ linters-settings:
# - unnamedResult
# - wrapperFunc


issues:
# List of regexps of issue texts to exclude, empty list by default.
# But independently from this option we use default exclude patterns,
Expand All @@ -228,6 +232,17 @@ issues:
- errcheck
- maligned

skip-dirs:
- genfiles$
- vendor$
- vbh

skip-files:
- ".*\\.pb\\.go"
- ".*\\.gen\\.go"
- ".*.helmrelease.*\\.go"
- ".*.ansiblejob.*\\.go"

# Independently from option `exclude` we use default exclude patterns,
# it can be disabled by this option. To list all
# excluded by default patterns execute `golangci-lint run --help`.
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.51.2
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.57.2

export GOLANGCI_LINT_CACHE=/tmp/golangci-cache
export GOROOT=`go env GOROOT`
Expand Down
2 changes: 1 addition & 1 deletion deploy/ocm/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ KUBECTL=${KUBECTL:-kubectl}
rm -rf ocm

echo "############ Cloning ocm"
git clone https://github.com/open-cluster-management-io/ocm.git
git clone --depth 1 --branch release-0.13 https://github.com/open-cluster-management-io/ocm.git

cd ocm || {
printf "cd failed, ocm does not exist"
Expand Down
Loading
Loading