Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Kvapil <[email protected]>
  • Loading branch information
kvaps committed Oct 7, 2024
1 parent ec7e454 commit d550079
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
4 changes: 1 addition & 3 deletions cmd/kubevirt-cloud-controller-manager/kubevirteps.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ import (

func StartKubevirtCloudControllerWrapper(initContext app.ControllerInitContext, completedConfig *config.CompletedConfig, cloud cloudprovider.Interface) app.InitFunc {
return func(ctx context.Context, controllerContext genericcontrollermanager.ControllerContext) (controller.Interface, bool, error) {
return startKubevirtCloudController(ctx, initContext, controllerContext, completedConfig, cloud)
return startKubevirtCloudController(controllerContext, completedConfig, cloud)
}
}

func startKubevirtCloudController(
ctx context.Context,
initContext app.ControllerInitContext,
controllerContext genericcontrollermanager.ControllerContext,
ccmConfig *config.CompletedConfig,
cloud cloudprovider.Interface) (controller.Interface, bool, error) {
Expand Down
4 changes: 3 additions & 1 deletion cmd/kubevirt-cloud-controller-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import (
_ "k8s.io/component-base/metrics/prometheus/clientgo" // load all the prometheus client-go plugins
_ "k8s.io/component-base/metrics/prometheus/version" // for version metric registration
"k8s.io/klog/v2"

_ "kubevirt.io/cloud-provider-kubevirt/pkg/provider"
)

func main() {
Expand All @@ -51,7 +53,7 @@ func main() {
Constructor: StartKubevirtCloudControllerWrapper,
}

command := app.NewCloudControllerManagerCommand(ccmOptions, cloudInitializer, controllerInitializers, fss, wait.NeverStop)
command := app.NewCloudControllerManagerCommand(ccmOptions, cloudInitializer, controllerInitializers, map[string]string{}, fss, wait.NeverStop)
code := cli.Run(command)
os.Exit(code)
}
Expand Down
9 changes: 6 additions & 3 deletions pkg/controller/kubevirteps/kubevirteps_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ func (c *Controller) Init() error {
eps := obj.(*discovery.EndpointSlice)
if c.tenantEPSTracker.contains(eps) {
klog.Infof("get Infra Service for Tenant EndpointSlice: %v/%v", eps.Namespace, eps.Name)
infraSvc, err := c.getInfraServiceFromTenantEPS(context.TODO(), eps)
var infraSvc *v1.Service
infraSvc, err = c.getInfraServiceFromTenantEPS(context.TODO(), eps)
if err != nil {
klog.Errorf("Failed to get Service in Infra cluster for EndpointSlice %s/%s: %v", eps.Namespace, eps.Name, err)
return
Expand All @@ -163,7 +164,8 @@ func (c *Controller) Init() error {
eps := newObj.(*discovery.EndpointSlice)
if c.tenantEPSTracker.contains(eps) {
klog.Infof("get Infra Service for Tenant EndpointSlice: %v/%v", eps.Namespace, eps.Name)
infraSvc, err := c.getInfraServiceFromTenantEPS(context.TODO(), eps)
var infraSvc *v1.Service
infraSvc, err = c.getInfraServiceFromTenantEPS(context.TODO(), eps)
if err != nil {
klog.Errorf("Failed to get Service in Infra cluster for EndpointSlice %s/%s: %v", eps.Namespace, eps.Name, err)
return
Expand All @@ -177,7 +179,8 @@ func (c *Controller) Init() error {
if c.tenantEPSTracker.contains(eps) {
c.tenantEPSTracker.remove(eps)
klog.Infof("get Infra Service for Tenant EndpointSlice: %v/%v", eps.Namespace, eps.Name)
infraSvc, err := c.getInfraServiceFromTenantEPS(context.TODO(), eps)
var infraSvc *v1.Service
infraSvc, err = c.getInfraServiceFromTenantEPS(context.TODO(), eps)
if err != nil {
klog.Errorf("Failed to get Service in Infra cluster for EndpointSlice %s/%s: %v", eps.Namespace, eps.Name, err)
return
Expand Down
11 changes: 6 additions & 5 deletions pkg/controller/kubevirteps/kubevirteps_controller_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//nolint:unparam
package kubevirteps

import (
Expand Down Expand Up @@ -172,7 +173,7 @@ func createAndAssertInfraServiceLB(name, tenantServiceName, clusterName string,
}).Should(BeTrue(), "")
}

func setupTestKubevirtEPSController(ctx context.Context) *testKubevirtEPSController {
func setupTestKubevirtEPSController() *testKubevirtEPSController {
var tenantClient *fake.Clientset
var infraClient *fake.Clientset

Expand All @@ -181,7 +182,7 @@ func setupTestKubevirtEPSController(ctx context.Context) *testKubevirtEPSControl

s := runtime.NewScheme()
infraDynamic := dfake.NewSimpleDynamicClientWithCustomListKinds(s, map[schema.GroupVersionResource]string{
schema.GroupVersionResource{
{
Group: kubevirtv1.GroupVersion.Group,
Version: kubevirtv1.GroupVersion.Version,
Resource: "virtualmachineinstances",
Expand Down Expand Up @@ -215,7 +216,7 @@ var _ = g.Describe("KubevirtEPSController start", g.Ordered, func() {
g.It("Should start the controller", func() {
ctx, stop := context.WithCancel(context.Background())
defer stop()
testVals := setupTestKubevirtEPSController(ctx)
testVals = setupTestKubevirtEPSController()
testVals.runKubevirtEPSController(ctx)
})
})
Expand All @@ -233,7 +234,7 @@ var _ = g.Describe("KubevirtEPSController", g.Ordered, func() {
g.It("Should start the controller", func() {
ctx, stop = context.WithCancel(context.Background())
defer stop()
testVals := setupTestKubevirtEPSController(ctx)
testVals = setupTestKubevirtEPSController()
testVals.runKubevirtEPSController(ctx)

cache.WaitForCacheSync(ctx.Done(),
Expand All @@ -246,7 +247,7 @@ var _ = g.Describe("KubevirtEPSController", g.Ordered, func() {
// Startup and wait for cache sync
g.BeforeEach(func() {
ctx, stop = context.WithCancel(context.Background())
testVals = setupTestKubevirtEPSController(ctx)
testVals = setupTestKubevirtEPSController()
testVals.runKubevirtEPSController(ctx)

cache.WaitForCacheSync(ctx.Done(),
Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/kubevirteps/kubevirteps_controller_utils.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package kubevirteps

import (
"sync"

v1 "k8s.io/api/core/v1"
discovery "k8s.io/api/discovery/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/klog/v2"
utilnet "k8s.io/utils/net"
"sync"
)

// source: https://github.com/kubernetes/endpointslice/blob/master/utils.go#L280
Expand Down

0 comments on commit d550079

Please sign in to comment.