Skip to content

Commit

Permalink
fix(lint): Update golangci-lint cfg, fix klogr.New deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
hrak committed Jul 11, 2024
1 parent 383b8b5 commit 7bedbb6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
14 changes: 11 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ linters-settings:
limitations under the License.
gocyclo:
min-complexity: 15
revive:
rules:
- name: dot-imports
arguments:
# dot import should be ONLY allowed for ginkgo testing packages
allowedPackages:
- "github.com/onsi/ginkgo/v2"
- "github.com/onsi/gomega"

linters:
enable:
Expand All @@ -32,12 +40,12 @@ linters:

run:
issues-exit-code: 1
skip-dirs:
- pkg/mocks
- test

issues:
# Excluding configuration per-path, per-linter, per-text and per-source
exclude-dirs:
- pkg/mocks
- test
exclude-rules:
# Exclude some linters from running on tests files.
- path: _test\.go
Expand Down
8 changes: 3 additions & 5 deletions controllers/controllers_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,16 @@ import (
"k8s.io/client-go/tools/record"
"sigs.k8s.io/cluster-api-provider-cloudstack/test/fakes"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/klog/v2"
"k8s.io/klog/v2/klogr"

"github.com/apache/cloudstack-go/v2/cloudstack"
"github.com/go-logr/logr"
"github.com/golang/mock/gomock"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/pkg/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
"k8s.io/klog/v2"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
Expand Down Expand Up @@ -154,7 +152,7 @@ var _ = BeforeSuite(func() {
Ω(flag.Lookup("v").Value.Set("1")).Should(Succeed())
flag.Parse()

logger = klogr.New()
logger = klog.Background()
})

// A mock fo the CloudClient interface used in controller utils.
Expand Down
8 changes: 2 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ package main
import (
"context"
"fmt"
"os"

"k8s.io/klog/v2"
"k8s.io/klog/v2/klogr"
"os"

flag "github.com/spf13/pflag"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
Expand Down Expand Up @@ -67,8 +65,6 @@ var (
)

func init() {
klog.InitFlags(nil)

utilruntime.Must(clientgoscheme.AddToScheme(scheme))
utilruntime.Must(clusterv1.AddToScheme(scheme))
utilruntime.Must(infrav1b1.AddToScheme(scheme))
Expand Down Expand Up @@ -188,7 +184,7 @@ func main() {
os.Exit(1)
}

ctrl.SetLogger(klogr.New())
ctrl.SetLogger(klog.Background())

tlsOptionOverrides, err := flags.GetTLSOptionOverrideFuncs(tlsOptions)
if err != nil {
Expand Down

0 comments on commit 7bedbb6

Please sign in to comment.