openshift / aws-account-operator

Operator to manage pool of AWS accounts for Hive
Apache License 2.0
32 stars 75 forks source link

Migrate fakeclient to envtest #550

Closed drpaneas closed 3 years ago

drpaneas commented 3 years ago

If we update the golangci-lint from 1.30 to the latest version (1.39) it's going to fail with:

GOLANGCI_LINT_CACHE=/tmp/golangci-cache golangci-lint run -c boilerplate/openshift/golang-osd-operator/golangci.yml ./...
pkg/totalaccountwatcher/totalaccountwatcher_test.go:21:2: SA1019: package sigs.k8s.io/controller-runtime/pkg/client/fake is deprecated: please use pkg/envtest for testing. This package will be dropped before the v1.0.0 release. Package fake provides a fake client for testing. (staticcheck)
        fakekubeclient "sigs.k8s.io/controller-runtime/pkg/client/fake"
        ^
pkg/controller/accountpool/accountpool_controller_test.go:17:2: SA1019: package sigs.k8s.io/controller-runtime/pkg/client/fake is deprecated: please use pkg/envtest for testing. This package will be dropped before the v1.0.0 release. Package fake provides a fake client for testing. (staticcheck)
        "sigs.k8s.io/controller-runtime/pkg/client/fake"
        ^
pkg/controller/accountclaim/accountclaim_controller_test.go:20:2: SA1019: package sigs.k8s.io/controller-runtime/pkg/client/fake is deprecated: please use pkg/envtest for testing. This package will be dropped before the v1.0.0 release. Package fake provides a fake client for testing. (staticcheck)
        "sigs.k8s.io/controller-runtime/pkg/client/fake"
        ^
make: *** [go-check] Error 1

Changing the fake client with pkg/envtest will cause problems because the NewFakeClient has been dropped in the envtest pkg. See: https://github.com/kubernetes-sigs/controller-runtime/pull/1101

How to test this:

Current version works: docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.30.0 golangci-lint run -v Latest version fails: docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.39.0 golangci-lint run -v

Workaround

Since I am working on multiple Golang projects which they are using different version of golang-ci, one way to overcome this issue is doing this at your .bashrc or .zshenv: alias golangci-lint="docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.30.0 golangci-lint"

openshift-bot commented 3 years ago

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

openshift-bot commented 3 years ago

Stale issues rot after 30d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity. Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle rotten /remove-lifecycle stale

openshift-bot commented 3 years ago

Rotten issues close after 30d of inactivity.

Reopen the issue by commenting /reopen. Mark the issue as fresh by commenting /remove-lifecycle rotten. Exclude this issue from closing again by commenting /lifecycle frozen.

/close

openshift-ci[bot] commented 3 years ago

@openshift-bot: Closing this issue.

In response to [this](https://github.com/openshift/aws-account-operator/issues/550#issuecomment-920359822): >Rotten issues close after 30d of inactivity. > >Reopen the issue by commenting `/reopen`. >Mark the issue as fresh by commenting `/remove-lifecycle rotten`. >Exclude this issue from closing again by commenting `/lifecycle frozen`. > >/close Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.