Fix go-lint error
Signed-off-by: clarklee92 <clarklee1992@hotmail.com>
This commit is contained in:
parent
782a250dd7
commit
ad0744df7a
|
|
@ -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"
|
||||
|
|
@ -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),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
|
@ -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 {
|
||||
|
|
@ -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),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
@ -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:
|
||||
|
|
@ -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 {
|
||||
|
|
@ -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),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
@ -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),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -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),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
@ -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),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -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),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
|
@ -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
|
||||
|
|
@ -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 {
|
||||
|
|
@ -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),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
@ -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),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -334,7 +335,7 @@ func TestClbPlugin_consSvc(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
AllocateLoadBalancerNodePorts: pointer.BoolPtr(true),
|
||||
AllocateLoadBalancerNodePorts: ptr.To[bool](true),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
35
main.go
35
main.go
|
|
@ -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
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ package gameserver
|
|||
|
||||
import (
|
||||
"context"
|
||||
gamekruiseiov1alpha1 "github.com/openkruise/kruise-game/apis/v1alpha1"
|
||||
"github.com/openkruise/kruise-game/pkg/util"
|
||||
utildiscovery "github.com/openkruise/kruise-game/pkg/util/discovery"
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
|
@ -32,8 +32,7 @@ import (
|
|||
"k8s.io/client-go/tools/record"
|
||||
"k8s.io/client-go/util/workqueue"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/utils/pointer"
|
||||
"reflect"
|
||||
"k8s.io/utils/ptr"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/controller"
|
||||
|
|
@ -43,7 +42,10 @@ import (
|
|||
"sigs.k8s.io/controller-runtime/pkg/manager"
|
||||
"sigs.k8s.io/controller-runtime/pkg/reconcile"
|
||||
"sigs.k8s.io/controller-runtime/pkg/source"
|
||||
"time"
|
||||
|
||||
gamekruiseiov1alpha1 "github.com/openkruise/kruise-game/apis/v1alpha1"
|
||||
"github.com/openkruise/kruise-game/pkg/util"
|
||||
utildiscovery "github.com/openkruise/kruise-game/pkg/util/discovery"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -297,8 +299,8 @@ func (r *GameServerReconciler) initGameServerByPod(gss *gamekruiseiov1alpha1.Gam
|
|||
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),
|
||||
}
|
||||
ors = append(ors, or)
|
||||
gs.OwnerReferences = ors
|
||||
|
|
|
|||
|
|
@ -18,19 +18,21 @@ package gameserver
|
|||
|
||||
import (
|
||||
"context"
|
||||
gameKruiseV1alpha1 "github.com/openkruise/kruise-game/apis/v1alpha1"
|
||||
"github.com/openkruise/kruise-game/pkg/util"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
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"
|
||||
"k8s.io/utils/pointer"
|
||||
"reflect"
|
||||
"k8s.io/utils/ptr"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client/fake"
|
||||
"testing"
|
||||
|
||||
gameKruiseV1alpha1 "github.com/openkruise/kruise-game/apis/v1alpha1"
|
||||
"github.com/openkruise/kruise-game/pkg/util"
|
||||
)
|
||||
|
||||
func TestGameServerReconcile(t *testing.T) {
|
||||
|
|
@ -117,8 +119,8 @@ func TestGameServerReconcile(t *testing.T) {
|
|||
Kind: podTemplate.Kind,
|
||||
Name: podTemplate.GetName(),
|
||||
UID: podTemplate.GetUID(),
|
||||
Controller: pointer.BoolPtr(true),
|
||||
BlockOwnerDeletion: pointer.BoolPtr(true),
|
||||
Controller: ptr.To[bool](true),
|
||||
BlockOwnerDeletion: ptr.To[bool](true),
|
||||
},
|
||||
}
|
||||
updatePriority := intstr.FromInt(0)
|
||||
|
|
|
|||
|
|
@ -18,10 +18,8 @@ package gameserverset
|
|||
|
||||
import (
|
||||
"context"
|
||||
|
||||
kruiseV1beta1 "github.com/openkruise/kruise-api/apps/v1beta1"
|
||||
gamekruiseiov1alpha1 "github.com/openkruise/kruise-game/apis/v1alpha1"
|
||||
"github.com/openkruise/kruise-game/pkg/util"
|
||||
utildiscovery "github.com/openkruise/kruise-game/pkg/util/discovery"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
|
@ -31,7 +29,7 @@ import (
|
|||
"k8s.io/client-go/tools/record"
|
||||
"k8s.io/client-go/util/workqueue"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/utils/pointer"
|
||||
"k8s.io/utils/ptr"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/controller"
|
||||
|
|
@ -41,6 +39,10 @@ import (
|
|||
"sigs.k8s.io/controller-runtime/pkg/manager"
|
||||
"sigs.k8s.io/controller-runtime/pkg/reconcile"
|
||||
"sigs.k8s.io/controller-runtime/pkg/source"
|
||||
|
||||
gamekruiseiov1alpha1 "github.com/openkruise/kruise-game/apis/v1alpha1"
|
||||
"github.com/openkruise/kruise-game/pkg/util"
|
||||
utildiscovery "github.com/openkruise/kruise-game/pkg/util/discovery"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -274,8 +276,8 @@ func (r *GameServerSetReconciler) initAsts(gss *gamekruiseiov1alpha1.GameServerS
|
|||
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),
|
||||
}
|
||||
ors = append(ors, or)
|
||||
asts.SetOwnerReferences(ors)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import (
|
|||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/utils/pointer"
|
||||
"k8s.io/utils/ptr"
|
||||
"reflect"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client/fake"
|
||||
|
|
@ -34,7 +34,7 @@ func TestInitAsts(t *testing.T) {
|
|||
UID: "xxx0",
|
||||
},
|
||||
Spec: gameKruiseV1alpha1.GameServerSetSpec{
|
||||
Replicas: pointer.Int32(5),
|
||||
Replicas: ptr.To[int32](5),
|
||||
UpdateStrategy: gameKruiseV1alpha1.UpdateStrategy{
|
||||
Type: apps.RollingUpdateStatefulSetStrategyType,
|
||||
RollingUpdate: &gameKruiseV1alpha1.RollingUpdateStatefulSetStrategy{},
|
||||
|
|
@ -55,14 +55,14 @@ func TestInitAsts(t *testing.T) {
|
|||
Kind: "GameServerSet",
|
||||
Name: "case0",
|
||||
UID: "xxx0",
|
||||
Controller: pointer.BoolPtr(true),
|
||||
BlockOwnerDeletion: pointer.BoolPtr(true),
|
||||
Controller: ptr.To[bool](true),
|
||||
BlockOwnerDeletion: ptr.To[bool](true),
|
||||
},
|
||||
},
|
||||
ResourceVersion: "1",
|
||||
},
|
||||
Spec: kruiseV1beta1.StatefulSetSpec{
|
||||
Replicas: pointer.Int32(5),
|
||||
Replicas: ptr.To[int32](5),
|
||||
PodManagementPolicy: apps.ParallelPodManagement,
|
||||
ServiceName: "case0",
|
||||
Selector: &metav1.LabelSelector{
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import (
|
|||
"k8s.io/client-go/tools/record"
|
||||
"k8s.io/client-go/util/retry"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/utils/pointer"
|
||||
"k8s.io/utils/ptr"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sort"
|
||||
"strconv"
|
||||
|
|
@ -93,7 +93,7 @@ func (manager *GameServerSetManager) GetReplicasAfterKilling() *int32 {
|
|||
}
|
||||
|
||||
klog.Infof("GameServerSet %s/%s will kill %d GameServers", gss.GetNamespace(), gss.GetName(), toKill)
|
||||
return pointer.Int32(*gss.Spec.Replicas - int32(toKill))
|
||||
return ptr.To[int32](*gss.Spec.Replicas - int32(toKill))
|
||||
}
|
||||
|
||||
func (manager *GameServerSetManager) IsNeedToScale() bool {
|
||||
|
|
@ -401,8 +401,8 @@ func createPpm(gss *gameKruiseV1alpha1.GameServerSet) *kruiseV1alpha1.PodProbeMa
|
|||
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),
|
||||
}
|
||||
ors = append(ors, or)
|
||||
return &kruiseV1alpha1.PodProbeMarker{
|
||||
|
|
@ -454,8 +454,8 @@ func (manager *GameServerSetManager) SyncStatus() error {
|
|||
ReadyReplicas: asts.Status.ReadyReplicas,
|
||||
UpdatedReplicas: asts.Status.UpdatedReplicas,
|
||||
UpdatedReadyReplicas: asts.Status.UpdatedReadyReplicas,
|
||||
MaintainingReplicas: pointer.Int32Ptr(int32(maintainingGs)),
|
||||
WaitToBeDeletedReplicas: pointer.Int32Ptr(int32(waitToBeDeletedGs)),
|
||||
MaintainingReplicas: ptr.To[int32](int32(maintainingGs)),
|
||||
WaitToBeDeletedReplicas: ptr.To[int32](int32(waitToBeDeletedGs)),
|
||||
LabelSelector: asts.Status.LabelSelector,
|
||||
ObservedGeneration: gss.GetGeneration(),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,11 +2,13 @@ package gameserverset
|
|||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
appspub "github.com/openkruise/kruise-api/apps/pub"
|
||||
kruiseV1alpha1 "github.com/openkruise/kruise-api/apps/v1alpha1"
|
||||
kruiseV1beta1 "github.com/openkruise/kruise-api/apps/v1beta1"
|
||||
gameKruiseV1alpha1 "github.com/openkruise/kruise-game/apis/v1alpha1"
|
||||
"github.com/openkruise/kruise-game/pkg/util"
|
||||
apps "k8s.io/api/apps/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
|
@ -14,12 +16,12 @@ import (
|
|||
"k8s.io/apimachinery/pkg/types"
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
"k8s.io/client-go/tools/record"
|
||||
"k8s.io/utils/pointer"
|
||||
"reflect"
|
||||
"k8s.io/utils/ptr"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client/fake"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
gameKruiseV1alpha1 "github.com/openkruise/kruise-game/apis/v1alpha1"
|
||||
"github.com/openkruise/kruise-game/pkg/util"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -377,12 +379,12 @@ func TestIsNeedToScale(t *testing.T) {
|
|||
{
|
||||
gss: &gameKruiseV1alpha1.GameServerSet{
|
||||
Spec: gameKruiseV1alpha1.GameServerSetSpec{
|
||||
Replicas: pointer.Int32(5),
|
||||
Replicas: ptr.To[int32](5),
|
||||
},
|
||||
},
|
||||
asts: &kruiseV1beta1.StatefulSet{
|
||||
Spec: kruiseV1beta1.StatefulSetSpec{
|
||||
Replicas: pointer.Int32(5),
|
||||
Replicas: ptr.To[int32](5),
|
||||
},
|
||||
Status: kruiseV1beta1.StatefulSetStatus{
|
||||
Replicas: int32(5),
|
||||
|
|
@ -396,13 +398,13 @@ func TestIsNeedToScale(t *testing.T) {
|
|||
Annotations: map[string]string{gameKruiseV1alpha1.GameServerSetReserveIdsKey: "1,5"},
|
||||
},
|
||||
Spec: gameKruiseV1alpha1.GameServerSetSpec{
|
||||
Replicas: pointer.Int32(5),
|
||||
Replicas: ptr.To[int32](5),
|
||||
ReserveGameServerIds: []int{1, 5},
|
||||
},
|
||||
},
|
||||
asts: &kruiseV1beta1.StatefulSet{
|
||||
Spec: kruiseV1beta1.StatefulSetSpec{
|
||||
Replicas: pointer.Int32(5),
|
||||
Replicas: ptr.To[int32](5),
|
||||
},
|
||||
Status: kruiseV1beta1.StatefulSetStatus{
|
||||
Replicas: int32(5),
|
||||
|
|
@ -442,7 +444,7 @@ func TestGameServerScale(t *testing.T) {
|
|||
Annotations: map[string]string{gameKruiseV1alpha1.GameServerSetReserveIdsKey: "1"},
|
||||
},
|
||||
Spec: gameKruiseV1alpha1.GameServerSetSpec{
|
||||
Replicas: pointer.Int32(3),
|
||||
Replicas: ptr.To[int32](3),
|
||||
ReserveGameServerIds: []int{1},
|
||||
},
|
||||
},
|
||||
|
|
@ -452,7 +454,7 @@ func TestGameServerScale(t *testing.T) {
|
|||
Name: "case0",
|
||||
},
|
||||
Spec: kruiseV1beta1.StatefulSetSpec{
|
||||
Replicas: pointer.Int32(4),
|
||||
Replicas: ptr.To[int32](4),
|
||||
ReserveOrdinals: []int{1},
|
||||
},
|
||||
Status: kruiseV1beta1.StatefulSetStatus{
|
||||
|
|
@ -509,7 +511,7 @@ func TestGameServerScale(t *testing.T) {
|
|||
Annotations: map[string]string{gameKruiseV1alpha1.GameServerSetReserveIdsKey: "1"},
|
||||
},
|
||||
Spec: gameKruiseV1alpha1.GameServerSetSpec{
|
||||
Replicas: pointer.Int32(3),
|
||||
Replicas: ptr.To[int32](3),
|
||||
ReserveGameServerIds: []int{1, 0},
|
||||
},
|
||||
},
|
||||
|
|
@ -519,7 +521,7 @@ func TestGameServerScale(t *testing.T) {
|
|||
Name: "case1",
|
||||
},
|
||||
Spec: kruiseV1beta1.StatefulSetSpec{
|
||||
Replicas: pointer.Int32(4),
|
||||
Replicas: ptr.To[int32](4),
|
||||
ReserveOrdinals: []int{1},
|
||||
},
|
||||
Status: kruiseV1beta1.StatefulSetStatus{
|
||||
|
|
@ -576,7 +578,7 @@ func TestGameServerScale(t *testing.T) {
|
|||
Annotations: map[string]string{gameKruiseV1alpha1.GameServerSetReserveIdsKey: "1"},
|
||||
},
|
||||
Spec: gameKruiseV1alpha1.GameServerSetSpec{
|
||||
Replicas: pointer.Int32(5),
|
||||
Replicas: ptr.To[int32](5),
|
||||
ReserveGameServerIds: []int{},
|
||||
},
|
||||
},
|
||||
|
|
@ -586,7 +588,7 @@ func TestGameServerScale(t *testing.T) {
|
|||
Name: "case2",
|
||||
},
|
||||
Spec: kruiseV1beta1.StatefulSetSpec{
|
||||
Replicas: pointer.Int32(4),
|
||||
Replicas: ptr.To[int32](4),
|
||||
ReserveOrdinals: []int{1},
|
||||
},
|
||||
Status: kruiseV1beta1.StatefulSetStatus{
|
||||
|
|
@ -643,7 +645,7 @@ func TestGameServerScale(t *testing.T) {
|
|||
Annotations: map[string]string{gameKruiseV1alpha1.GameServerSetReserveIdsKey: "1"},
|
||||
},
|
||||
Spec: gameKruiseV1alpha1.GameServerSetSpec{
|
||||
Replicas: pointer.Int32(5),
|
||||
Replicas: ptr.To[int32](5),
|
||||
ReserveGameServerIds: []int{},
|
||||
},
|
||||
},
|
||||
|
|
@ -653,7 +655,7 @@ func TestGameServerScale(t *testing.T) {
|
|||
Name: "case3",
|
||||
},
|
||||
Spec: kruiseV1beta1.StatefulSetSpec{
|
||||
Replicas: pointer.Int32(3),
|
||||
Replicas: ptr.To[int32](3),
|
||||
ReserveOrdinals: []int{1, 3},
|
||||
},
|
||||
Status: kruiseV1beta1.StatefulSetStatus{
|
||||
|
|
@ -886,12 +888,12 @@ func TestNumberToKill(t *testing.T) {
|
|||
{
|
||||
gss: &gameKruiseV1alpha1.GameServerSet{
|
||||
Spec: gameKruiseV1alpha1.GameServerSetSpec{
|
||||
Replicas: pointer.Int32(3),
|
||||
Replicas: ptr.To[int32](3),
|
||||
},
|
||||
},
|
||||
asts: &kruiseV1beta1.StatefulSet{
|
||||
Spec: kruiseV1beta1.StatefulSetSpec{
|
||||
Replicas: pointer.Int32(3),
|
||||
Replicas: ptr.To[int32](3),
|
||||
},
|
||||
},
|
||||
podList: []corev1.Pod{
|
||||
|
|
@ -923,7 +925,7 @@ func TestNumberToKill(t *testing.T) {
|
|||
{
|
||||
gss: &gameKruiseV1alpha1.GameServerSet{
|
||||
Spec: gameKruiseV1alpha1.GameServerSetSpec{
|
||||
Replicas: pointer.Int32(3),
|
||||
Replicas: ptr.To[int32](3),
|
||||
},
|
||||
Status: gameKruiseV1alpha1.GameServerSetStatus{
|
||||
Replicas: int32(3),
|
||||
|
|
@ -931,7 +933,7 @@ func TestNumberToKill(t *testing.T) {
|
|||
},
|
||||
asts: &kruiseV1beta1.StatefulSet{
|
||||
Spec: kruiseV1beta1.StatefulSetSpec{
|
||||
Replicas: pointer.Int32(3),
|
||||
Replicas: ptr.To[int32](3),
|
||||
},
|
||||
},
|
||||
podList: []corev1.Pod{
|
||||
|
|
@ -964,7 +966,7 @@ func TestNumberToKill(t *testing.T) {
|
|||
{
|
||||
gss: &gameKruiseV1alpha1.GameServerSet{
|
||||
Spec: gameKruiseV1alpha1.GameServerSetSpec{
|
||||
Replicas: pointer.Int32(2),
|
||||
Replicas: ptr.To[int32](2),
|
||||
},
|
||||
Status: gameKruiseV1alpha1.GameServerSetStatus{
|
||||
Replicas: int32(2),
|
||||
|
|
@ -972,7 +974,7 @@ func TestNumberToKill(t *testing.T) {
|
|||
},
|
||||
asts: &kruiseV1beta1.StatefulSet{
|
||||
Spec: kruiseV1beta1.StatefulSetSpec{
|
||||
Replicas: pointer.Int32(2),
|
||||
Replicas: ptr.To[int32](2),
|
||||
},
|
||||
},
|
||||
podList: []corev1.Pod{
|
||||
|
|
@ -1005,7 +1007,7 @@ func TestNumberToKill(t *testing.T) {
|
|||
{
|
||||
gss: &gameKruiseV1alpha1.GameServerSet{
|
||||
Spec: gameKruiseV1alpha1.GameServerSetSpec{
|
||||
Replicas: pointer.Int32(4),
|
||||
Replicas: ptr.To[int32](4),
|
||||
},
|
||||
Status: gameKruiseV1alpha1.GameServerSetStatus{
|
||||
Replicas: int32(3),
|
||||
|
|
@ -1013,7 +1015,7 @@ func TestNumberToKill(t *testing.T) {
|
|||
},
|
||||
asts: &kruiseV1beta1.StatefulSet{
|
||||
Spec: kruiseV1beta1.StatefulSetSpec{
|
||||
Replicas: pointer.Int32(3),
|
||||
Replicas: ptr.To[int32](3),
|
||||
},
|
||||
},
|
||||
podList: []corev1.Pod{
|
||||
|
|
|
|||
|
|
@ -19,18 +19,20 @@ package util
|
|||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
appspub "github.com/openkruise/kruise-api/apps/pub"
|
||||
kruiseV1beta1 "github.com/openkruise/kruise-api/apps/v1beta1"
|
||||
gameKruiseV1alpha1 "github.com/openkruise/kruise-game/apis/v1alpha1"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
apps "k8s.io/api/apps/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
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"
|
||||
|
||||
appspub "github.com/openkruise/kruise-api/apps/pub"
|
||||
kruiseV1beta1 "github.com/openkruise/kruise-api/apps/v1beta1"
|
||||
gameKruiseV1alpha1 "github.com/openkruise/kruise-game/apis/v1alpha1"
|
||||
)
|
||||
|
||||
type DeleteSequenceGs []corev1.Pod
|
||||
|
|
@ -251,8 +253,8 @@ func InitGameServer(gss *gameKruiseV1alpha1.GameServerSet, name string) *gameKru
|
|||
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),
|
||||
}
|
||||
ors = append(ors, or)
|
||||
gs.OwnerReferences = ors
|
||||
|
|
|
|||
|
|
@ -17,14 +17,16 @@ limitations under the License.
|
|||
package util
|
||||
|
||||
import (
|
||||
gameKruiseV1alpha1 "github.com/openkruise/kruise-game/apis/v1alpha1"
|
||||
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"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
gameKruiseV1alpha1 "github.com/openkruise/kruise-game/apis/v1alpha1"
|
||||
)
|
||||
|
||||
func TestGetIndexFromGsName(t *testing.T) {
|
||||
|
|
@ -406,8 +408,8 @@ func TestInitGameServer(t *testing.T) {
|
|||
APIVersion: "game.kruise.io/v1alpha1",
|
||||
Name: "case0",
|
||||
UID: "xxx0",
|
||||
Controller: pointer.BoolPtr(true),
|
||||
BlockOwnerDeletion: pointer.BoolPtr(true),
|
||||
Controller: ptr.To[bool](true),
|
||||
BlockOwnerDeletion: ptr.To[bool](true),
|
||||
},
|
||||
},
|
||||
Labels: map[string]string{
|
||||
|
|
|
|||
|
|
@ -3,9 +3,8 @@ package client
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
kruiseV1beta1 "github.com/openkruise/kruise-api/apps/v1beta1"
|
||||
gameKruiseV1alpha1 "github.com/openkruise/kruise-game/apis/v1alpha1"
|
||||
kruisegameclientset "github.com/openkruise/kruise-game/pkg/client/clientset/versioned"
|
||||
"time"
|
||||
|
||||
apps "k8s.io/api/apps/v1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
|
|
@ -13,8 +12,11 @@ import (
|
|||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
"k8s.io/utils/pointer"
|
||||
"time"
|
||||
"k8s.io/utils/ptr"
|
||||
|
||||
kruiseV1beta1 "github.com/openkruise/kruise-api/apps/v1beta1"
|
||||
gameKruiseV1alpha1 "github.com/openkruise/kruise-game/apis/v1alpha1"
|
||||
kruisegameclientset "github.com/openkruise/kruise-game/pkg/client/clientset/versioned"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -66,7 +68,7 @@ func (client *Client) DefaultGameServerSet() *gameKruiseV1alpha1.GameServerSet {
|
|||
Namespace: Namespace,
|
||||
},
|
||||
Spec: gameKruiseV1alpha1.GameServerSetSpec{
|
||||
Replicas: pointer.Int32Ptr(3),
|
||||
Replicas: ptr.To[int32](3),
|
||||
UpdateStrategy: gameKruiseV1alpha1.UpdateStrategy{
|
||||
Type: apps.RollingUpdateStatefulSetStrategyType,
|
||||
RollingUpdate: &gameKruiseV1alpha1.RollingUpdateStatefulSetStrategy{
|
||||
|
|
|
|||
Loading…
Reference in New Issue