Skip to content

Commit

Permalink
Fix go-lint error
Browse files Browse the repository at this point in the history
Signed-off-by: clarklee92 <[email protected]>
  • Loading branch information
clarklee92 authored and chrisliu1995 committed Jun 21, 2024
1 parent 782a250 commit ad0744d
Show file tree
Hide file tree
Showing 17 changed files with 180 additions and 160 deletions.
6 changes: 3 additions & 3 deletions cloudprovider/alibabacloud/nlb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
"reflect"
"sigs.k8s.io/controller-runtime/pkg/client"
"sync"
Expand Down Expand Up @@ -278,8 +278,8 @@ func TestNlbPlugin_consSvc(t *testing.T) {
Kind: "pod",
Name: "test-pod",
UID: "32fqwfqfew",
Controller: pointer.BoolPtr(true),
BlockOwnerDeletion: pointer.BoolPtr(true),
Controller: ptr.To[bool](true),
BlockOwnerDeletion: ptr.To[bool](true),
},
},
},
Expand Down
30 changes: 16 additions & 14 deletions cloudprovider/alibabacloud/slb.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,25 @@ package alibabacloud
import (
"context"
"fmt"
gamekruiseiov1alpha1 "github.com/openkruise/kruise-game/apis/v1alpha1"
"github.com/openkruise/kruise-game/cloudprovider"
cperrors "github.com/openkruise/kruise-game/cloudprovider/errors"
provideroptions "github.com/openkruise/kruise-game/cloudprovider/options"
"github.com/openkruise/kruise-game/cloudprovider/utils"
"github.com/openkruise/kruise-game/pkg/util"
"strconv"
"strings"
"sync"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/intstr"
log "k8s.io/klog/v2"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/client"
"strconv"
"strings"
"sync"

gamekruiseiov1alpha1 "github.com/openkruise/kruise-game/apis/v1alpha1"
"github.com/openkruise/kruise-game/cloudprovider"
cperrors "github.com/openkruise/kruise-game/cloudprovider/errors"
provideroptions "github.com/openkruise/kruise-game/cloudprovider/options"
"github.com/openkruise/kruise-game/cloudprovider/utils"
"github.com/openkruise/kruise-game/pkg/util"
)

const (
Expand Down Expand Up @@ -596,8 +598,8 @@ func getSvcOwnerReference(c client.Client, ctx context.Context, pod *corev1.Pod,
Kind: pod.Kind,
Name: pod.GetName(),
UID: pod.GetUID(),
Controller: pointer.BoolPtr(true),
BlockOwnerDeletion: pointer.BoolPtr(true),
Controller: ptr.To[bool](true),
BlockOwnerDeletion: ptr.To[bool](true),
},
}
if isFixed {
Expand All @@ -609,8 +611,8 @@ func getSvcOwnerReference(c client.Client, ctx context.Context, pod *corev1.Pod,
Kind: gss.Kind,
Name: gss.GetName(),
UID: gss.GetUID(),
Controller: pointer.BoolPtr(true),
BlockOwnerDeletion: pointer.BoolPtr(true),
Controller: ptr.To[bool](true),
BlockOwnerDeletion: ptr.To[bool](true),
},
}
}
Expand Down
12 changes: 6 additions & 6 deletions cloudprovider/kubernetes/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/client"
"strconv"
"strings"
Expand Down Expand Up @@ -222,7 +222,7 @@ func parseIngConfig(conf []gamekruiseiov1alpha1.NetworkConfParams, pod *corev1.P
return ingConfig{}, fmt.Errorf("%s", paramsError)
}
case IngressClassNameKey:
ic.ingressClassName = pointer.String(c.Value)
ic.ingressClassName = ptr.To[string](c.Value)
case TlsSecretNameKey:
ic.tlsSecretName = c.Value
case TlsHostsKey:
Expand Down Expand Up @@ -358,8 +358,8 @@ func consOwnerReference(c client.Client, ctx context.Context, pod *corev1.Pod, i
Kind: pod.Kind,
Name: pod.GetName(),
UID: pod.GetUID(),
Controller: pointer.BoolPtr(true),
BlockOwnerDeletion: pointer.BoolPtr(true),
Controller: ptr.To[bool](true),
BlockOwnerDeletion: ptr.To[bool](true),
},
}
if isFixed {
Expand All @@ -371,8 +371,8 @@ func consOwnerReference(c client.Client, ctx context.Context, pod *corev1.Pod, i
Kind: gss.Kind,
Name: gss.GetName(),
UID: gss.GetUID(),
Controller: pointer.BoolPtr(true),
BlockOwnerDeletion: pointer.BoolPtr(true),
Controller: ptr.To[bool](true),
BlockOwnerDeletion: ptr.To[bool](true),
},
}
}
Expand Down
20 changes: 11 additions & 9 deletions cloudprovider/kubernetes/ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ package kubernetes

import (
"fmt"
gamekruiseiov1alpha1 "github.com/openkruise/kruise-game/apis/v1alpha1"
"github.com/openkruise/kruise-game/pkg/util"
"reflect"
"testing"

corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
"reflect"
"testing"
"k8s.io/utils/ptr"

gamekruiseiov1alpha1 "github.com/openkruise/kruise-game/apis/v1alpha1"
"github.com/openkruise/kruise-game/pkg/util"
)

func TestParseIngConfig(t *testing.T) {
Expand Down Expand Up @@ -187,8 +189,8 @@ func TestConsIngress(t *testing.T) {
Kind: "Pod",
Name: "pod-3",
UID: "bff0afd6-bb30-4641-8607-8329547324eb",
Controller: pointer.BoolPtr(true),
BlockOwnerDeletion: pointer.BoolPtr(true),
Controller: ptr.To[bool](true),
BlockOwnerDeletion: ptr.To[bool](true),
},
},
}
Expand Down Expand Up @@ -378,8 +380,8 @@ func TestConsSvc(t *testing.T) {
Kind: "Pod",
Name: "pod-3",
UID: "bff0afd6-bb30-4641-8607-8329547324eb",
Controller: pointer.BoolPtr(true),
BlockOwnerDeletion: pointer.BoolPtr(true),
Controller: ptr.To[bool](true),
BlockOwnerDeletion: ptr.To[bool](true),
},
},
}
Expand Down
20 changes: 11 additions & 9 deletions cloudprovider/kubernetes/nodeport_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package kubernetes

import (
gamekruiseiov1alpha1 "github.com/openkruise/kruise-game/apis/v1alpha1"
"github.com/openkruise/kruise-game/pkg/util"
"reflect"
"testing"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/utils/pointer"
"reflect"
"testing"
"k8s.io/utils/ptr"

gamekruiseiov1alpha1 "github.com/openkruise/kruise-game/apis/v1alpha1"
"github.com/openkruise/kruise-game/pkg/util"
)

func TestParseNPConfig(t *testing.T) {
Expand Down Expand Up @@ -89,8 +91,8 @@ func TestConsNPSvc(t *testing.T) {
Kind: "Pod",
Name: "pod-3",
UID: "bff0afd6-bb30-4641-8607-8329547324eb",
Controller: pointer.BoolPtr(true),
BlockOwnerDeletion: pointer.BoolPtr(true),
Controller: ptr.To[bool](true),
BlockOwnerDeletion: ptr.To[bool](true),
},
},
},
Expand Down Expand Up @@ -139,8 +141,8 @@ func TestConsNPSvc(t *testing.T) {
Kind: "Pod",
Name: "pod-3",
UID: "bff0afd6-bb30-4641-8607-8329547324eb",
Controller: pointer.BoolPtr(true),
BlockOwnerDeletion: pointer.BoolPtr(true),
Controller: ptr.To[bool](true),
BlockOwnerDeletion: ptr.To[bool](true),
},
},
},
Expand Down
32 changes: 17 additions & 15 deletions cloudprovider/volcengine/clb.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,25 @@ package volcengine
import (
"context"
"fmt"
gamekruiseiov1alpha1 "github.com/openkruise/kruise-game/apis/v1alpha1"
"github.com/openkruise/kruise-game/cloudprovider"
cperrors "github.com/openkruise/kruise-game/cloudprovider/errors"
provideroptions "github.com/openkruise/kruise-game/cloudprovider/options"
"github.com/openkruise/kruise-game/cloudprovider/utils"
"github.com/openkruise/kruise-game/pkg/util"
"strconv"
"strings"
"sync"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/intstr"
log "k8s.io/klog/v2"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/client"
"strconv"
"strings"
"sync"

gamekruiseiov1alpha1 "github.com/openkruise/kruise-game/apis/v1alpha1"
"github.com/openkruise/kruise-game/cloudprovider"
cperrors "github.com/openkruise/kruise-game/cloudprovider/errors"
provideroptions "github.com/openkruise/kruise-game/cloudprovider/options"
"github.com/openkruise/kruise-game/cloudprovider/utils"
"github.com/openkruise/kruise-game/pkg/util"
)

const (
Expand Down Expand Up @@ -466,7 +468,7 @@ func (c *ClbPlugin) consSvc(config *clbConfig, pod *corev1.Pod, client client.Cl
SvcSelectorKey: pod.GetName(),
},
Ports: svcPorts,
AllocateLoadBalancerNodePorts: pointer.Bool(config.allocateLoadBalancerNodePorts),
AllocateLoadBalancerNodePorts: ptr.To[bool](config.allocateLoadBalancerNodePorts),
},
}
return svc
Expand All @@ -479,8 +481,8 @@ func getSvcOwnerReference(c client.Client, ctx context.Context, pod *corev1.Pod,
Kind: pod.Kind,
Name: pod.GetName(),
UID: pod.GetUID(),
Controller: pointer.BoolPtr(true),
BlockOwnerDeletion: pointer.BoolPtr(true),
Controller: ptr.To[bool](true),
BlockOwnerDeletion: ptr.To[bool](true),
},
}
if isFixed {
Expand All @@ -492,8 +494,8 @@ func getSvcOwnerReference(c client.Client, ctx context.Context, pod *corev1.Pod,
Kind: gss.Kind,
Name: gss.GetName(),
UID: gss.GetUID(),
Controller: pointer.BoolPtr(true),
BlockOwnerDeletion: pointer.BoolPtr(true),
Controller: ptr.To[bool](true),
BlockOwnerDeletion: ptr.To[bool](true),
},
}
}
Expand Down
13 changes: 7 additions & 6 deletions cloudprovider/volcengine/clb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,18 @@ package volcengine

import (
"context"
"k8s.io/utils/ptr"
"reflect"
"sync"
"testing"

gamekruiseiov1alpha1 "github.com/openkruise/kruise-game/apis/v1alpha1"
"github.com/openkruise/kruise-game/pkg/util"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/utils/pointer"
"sigs.k8s.io/controller-runtime/pkg/client"

gamekruiseiov1alpha1 "github.com/openkruise/kruise-game/apis/v1alpha1"
"github.com/openkruise/kruise-game/pkg/util"
)

func TestAllocateDeAllocate(t *testing.T) {
Expand Down Expand Up @@ -314,8 +315,8 @@ func TestClbPlugin_consSvc(t *testing.T) {
Kind: "pod",
Name: "test-pod",
UID: "32fqwfqfew",
Controller: pointer.BoolPtr(true),
BlockOwnerDeletion: pointer.BoolPtr(true),
Controller: ptr.To[bool](true),
BlockOwnerDeletion: ptr.To[bool](true),
},
},
},
Expand All @@ -334,7 +335,7 @@ func TestClbPlugin_consSvc(t *testing.T) {
},
},
},
AllocateLoadBalancerNodePorts: pointer.BoolPtr(true),
AllocateLoadBalancerNodePorts: ptr.To[bool](true),
},
},
},
Expand Down
35 changes: 16 additions & 19 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,37 @@ package main

import (
"flag"

kruiseV1alpha1 "github.com/openkruise/kruise-api/apps/v1alpha1"
kruiseV1beta1 "github.com/openkruise/kruise-api/apps/v1beta1"
"github.com/openkruise/kruise-game/cloudprovider"
cpmanager "github.com/openkruise/kruise-game/cloudprovider/manager"
kruisegameclientset "github.com/openkruise/kruise-game/pkg/client/clientset/versioned"
kruisegamevisions "github.com/openkruise/kruise-game/pkg/client/informers/externalversions"
controller "github.com/openkruise/kruise-game/pkg/controllers"
"github.com/openkruise/kruise-game/pkg/externalscaler"
"github.com/openkruise/kruise-game/pkg/metrics"
"github.com/openkruise/kruise-game/pkg/webhook"
"google.golang.org/grpc"
"k8s.io/client-go/rest"
"net"
"os"

"time"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.
_ "k8s.io/client-go/plugin/pkg/client/auth"

ackv1alpha1 "github.com/aws-controllers-k8s/elbv2-controller/apis/v1alpha1"
aliv1beta1 "github.com/openkruise/kruise-game/cloudprovider/alibabacloud/apis/v1beta1"
kruiseV1alpha1 "github.com/openkruise/kruise-api/apps/v1alpha1"
kruiseV1beta1 "github.com/openkruise/kruise-api/apps/v1beta1"
"google.golang.org/grpc"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.
_ "k8s.io/client-go/plugin/pkg/client/auth"
"k8s.io/client-go/rest"
elbv2api "sigs.k8s.io/aws-load-balancer-controller/apis/elbv2/v1beta1"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

gamekruiseiov1alpha1 "github.com/openkruise/kruise-game/apis/v1alpha1"
"github.com/openkruise/kruise-game/cloudprovider"
aliv1beta1 "github.com/openkruise/kruise-game/cloudprovider/alibabacloud/apis/v1beta1"
cpmanager "github.com/openkruise/kruise-game/cloudprovider/manager"
kruisegameclientset "github.com/openkruise/kruise-game/pkg/client/clientset/versioned"
kruisegamevisions "github.com/openkruise/kruise-game/pkg/client/informers/externalversions"
controller "github.com/openkruise/kruise-game/pkg/controllers"
"github.com/openkruise/kruise-game/pkg/externalscaler"
"github.com/openkruise/kruise-game/pkg/metrics"
utilclient "github.com/openkruise/kruise-game/pkg/util/client"
"github.com/openkruise/kruise-game/pkg/webhook"
//+kubebuilder:scaffold:imports
)

Expand Down
Loading

0 comments on commit ad0744d

Please sign in to comment.