convert pointer to ptr for sig-apps integration tests

This commit is contained in:
Kevin Hannon 2023-09-30 11:05:30 -04:00
parent 1596bc962b
commit 1a41ed394d
6 changed files with 189 additions and 190 deletions

View File

@ -59,7 +59,7 @@ import (
"k8s.io/kubernetes/test/integration/util" "k8s.io/kubernetes/test/integration/util"
"k8s.io/kubernetes/test/utils/ktesting" "k8s.io/kubernetes/test/utils/ktesting"
"k8s.io/utils/clock" "k8s.io/utils/clock"
"k8s.io/utils/pointer" "k8s.io/utils/ptr"
) )
const stalePodDisruptionTimeout = 3 * time.Second const stalePodDisruptionTimeout = 3 * time.Second
@ -585,7 +585,7 @@ func TestPatchCompatibility(t *testing.T) {
version: "v1", version: "v1",
patchType: types.ApplyPatchType, patchType: types.ApplyPatchType,
patch: `{"apiVersion":"policy/v1","kind":"PodDisruptionBudget","spec":{"selector":{"matchLabels":{"patchmatch":"true"},"matchExpressions":[{"key":"patchexpression","operator":"In","values":["true"]}]}}}`, patch: `{"apiVersion":"policy/v1","kind":"PodDisruptionBudget","spec":{"selector":{"matchLabels":{"patchmatch":"true"},"matchExpressions":[{"key":"patchexpression","operator":"In","values":["true"]}]}}}`,
force: pointer.Bool(true), force: ptr.To(true),
fieldManager: "test", fieldManager: "test",
// entire selector is replaced (because structType=atomic) // entire selector is replaced (because structType=atomic)
expectSelector: &metav1.LabelSelector{ expectSelector: &metav1.LabelSelector{

View File

@ -52,7 +52,7 @@ import (
"k8s.io/kubernetes/pkg/controller/garbagecollector" "k8s.io/kubernetes/pkg/controller/garbagecollector"
"k8s.io/kubernetes/test/integration" "k8s.io/kubernetes/test/integration"
"k8s.io/kubernetes/test/integration/framework" "k8s.io/kubernetes/test/integration/framework"
"k8s.io/utils/pointer" "k8s.io/utils/ptr"
) )
func getForegroundOptions() metav1.DeleteOptions { func getForegroundOptions() metav1.DeleteOptions {
@ -355,7 +355,7 @@ func testCrossNamespaceReferences(t *testing.T, watchCache bool) {
} }
for i := 0; i < validChildrenCount; i++ { for i := 0; i < validChildrenCount; i++ {
_, err := clientSet.CoreV1().Secrets(namespaceB).Create(context.TODO(), &v1.Secret{ObjectMeta: metav1.ObjectMeta{GenerateName: "child-", OwnerReferences: []metav1.OwnerReference{ _, err := clientSet.CoreV1().Secrets(namespaceB).Create(context.TODO(), &v1.Secret{ObjectMeta: metav1.ObjectMeta{GenerateName: "child-", OwnerReferences: []metav1.OwnerReference{
{Name: "parent", Kind: "ConfigMap", APIVersion: "v1", UID: parent.UID, Controller: pointer.BoolPtr(false)}, {Name: "parent", Kind: "ConfigMap", APIVersion: "v1", UID: parent.UID, Controller: ptr.To(false)},
}}}, metav1.CreateOptions{}) }}}, metav1.CreateOptions{})
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -369,7 +369,7 @@ func testCrossNamespaceReferences(t *testing.T, watchCache bool) {
for i := 0; i < 25; i++ { for i := 0; i < 25; i++ {
invalidOwnerReferences = append(invalidOwnerReferences, metav1.OwnerReference{Name: "invalid", UID: types.UID(fmt.Sprintf("invalid-%d", i)), APIVersion: "test/v1", Kind: fmt.Sprintf("invalid%d", i)}) invalidOwnerReferences = append(invalidOwnerReferences, metav1.OwnerReference{Name: "invalid", UID: types.UID(fmt.Sprintf("invalid-%d", i)), APIVersion: "test/v1", Kind: fmt.Sprintf("invalid%d", i)})
} }
invalidOwnerReferences = append(invalidOwnerReferences, metav1.OwnerReference{Name: "invalid", UID: parent.UID, APIVersion: "v1", Kind: "Pod", Controller: pointer.BoolPtr(false)}) invalidOwnerReferences = append(invalidOwnerReferences, metav1.OwnerReference{Name: "invalid", UID: parent.UID, APIVersion: "v1", Kind: "Pod", Controller: ptr.To(false)})
for i := 0; i < workers; i++ { for i := 0; i < workers; i++ {
_, err := clientSet.CoreV1().ConfigMaps(namespaceA).Create(context.TODO(), &v1.ConfigMap{ObjectMeta: metav1.ObjectMeta{GenerateName: "invalid-child-", OwnerReferences: invalidOwnerReferences}}, metav1.CreateOptions{}) _, err := clientSet.CoreV1().ConfigMaps(namespaceA).Create(context.TODO(), &v1.ConfigMap{ObjectMeta: metav1.ObjectMeta{GenerateName: "invalid-child-", OwnerReferences: invalidOwnerReferences}}, metav1.CreateOptions{})
@ -384,7 +384,7 @@ func testCrossNamespaceReferences(t *testing.T, watchCache bool) {
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{"single-bad-reference": "true"}, Labels: map[string]string{"single-bad-reference": "true"},
GenerateName: "invalid-child-b-", GenerateName: "invalid-child-b-",
OwnerReferences: []metav1.OwnerReference{{Name: "invalid", UID: parent.UID, APIVersion: "v1", Kind: "Pod", Controller: pointer.BoolPtr(false)}}, OwnerReferences: []metav1.OwnerReference{{Name: "invalid", UID: parent.UID, APIVersion: "v1", Kind: "Pod", Controller: ptr.To(false)}},
}, },
}, metav1.CreateOptions{}) }, metav1.CreateOptions{})
if err != nil { if err != nil {
@ -434,7 +434,7 @@ func testCrossNamespaceReferences(t *testing.T, watchCache bool) {
invalidChild, err := clientSet.CoreV1().Secrets(namespaceA).Create(context.TODO(), &v1.Secret{ invalidChild, err := clientSet.CoreV1().Secrets(namespaceA).Create(context.TODO(), &v1.Secret{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
GenerateName: "invalid-child-c-", GenerateName: "invalid-child-c-",
OwnerReferences: []metav1.OwnerReference{{Name: "invalid", UID: parent.UID, APIVersion: "v1", Kind: "Pod", Controller: pointer.BoolPtr(false)}}, OwnerReferences: []metav1.OwnerReference{{Name: "invalid", UID: parent.UID, APIVersion: "v1", Kind: "Pod", Controller: ptr.To(false)}},
}, },
}, metav1.CreateOptions{}) }, metav1.CreateOptions{})
if err != nil { if err != nil {

File diff suppressed because it is too large Load Diff

View File

@ -34,7 +34,7 @@ import (
"k8s.io/kubernetes/pkg/controller/podgc" "k8s.io/kubernetes/pkg/controller/podgc"
"k8s.io/kubernetes/pkg/features" "k8s.io/kubernetes/pkg/features"
testutils "k8s.io/kubernetes/test/integration/util" testutils "k8s.io/kubernetes/test/integration/util"
"k8s.io/utils/pointer" "k8s.io/utils/ptr"
) )
// TestPodGcOrphanedPodsWithFinalizer tests deletion of orphaned pods // TestPodGcOrphanedPodsWithFinalizer tests deletion of orphaned pods
@ -256,7 +256,7 @@ func TestTerminatingOnOutOfServiceNode(t *testing.T) {
} }
// trigger termination of the pod, but with long grace period so that it is not removed immediately // trigger termination of the pod, but with long grace period so that it is not removed immediately
err = cs.CoreV1().Pods(testCtx.NS.Name).Delete(testCtx.Ctx, pod.Name, metav1.DeleteOptions{GracePeriodSeconds: pointer.Int64(300)}) err = cs.CoreV1().Pods(testCtx.NS.Name).Delete(testCtx.Ctx, pod.Name, metav1.DeleteOptions{GracePeriodSeconds: ptr.To[int64](300)})
if err != nil { if err != nil {
t.Fatalf("Error: '%v' while deleting pod: '%v'", err, klog.KObj(pod)) t.Fatalf("Error: '%v' while deleting pod: '%v'", err, klog.KObj(pod))
} }

View File

@ -48,7 +48,7 @@ import (
"k8s.io/kubernetes/pkg/features" "k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/test/integration/framework" "k8s.io/kubernetes/test/integration/framework"
testutil "k8s.io/kubernetes/test/utils" testutil "k8s.io/kubernetes/test/utils"
"k8s.io/utils/pointer" "k8s.io/utils/ptr"
) )
const ( const (
@ -681,7 +681,7 @@ func TestPodDeletionCost(t *testing.T) {
// Change RS's number of replics to 1 // Change RS's number of replics to 1
rsClient := c.AppsV1().ReplicaSets(ns.Name) rsClient := c.AppsV1().ReplicaSets(ns.Name)
updateRS(t, rsClient, rs.Name, func(rs *apps.ReplicaSet) { updateRS(t, rsClient, rs.Name, func(rs *apps.ReplicaSet) {
rs.Spec.Replicas = pointer.Int32(1) rs.Spec.Replicas = ptr.To[int32](1)
}) })
// Poll until ReplicaSet is downscaled to 1. // Poll until ReplicaSet is downscaled to 1.

View File

@ -67,7 +67,7 @@ import (
"k8s.io/kubernetes/test/integration/framework" "k8s.io/kubernetes/test/integration/framework"
imageutils "k8s.io/kubernetes/test/utils/image" imageutils "k8s.io/kubernetes/test/utils/image"
"k8s.io/kubernetes/test/utils/ktesting" "k8s.io/kubernetes/test/utils/ktesting"
"k8s.io/utils/pointer" "k8s.io/utils/ptr"
) )
// ShutdownFunc represents the function handle to be called, typically in a defer handler, to shutdown a running module // ShutdownFunc represents the function handle to be called, typically in a defer handler, to shutdown a running module
@ -652,7 +652,7 @@ func InitTestSchedulerWithNS(t *testing.T, nsPrefix string, opts ...scheduler.Op
func InitTestDisablePreemption(t *testing.T, nsPrefix string) *TestContext { func InitTestDisablePreemption(t *testing.T, nsPrefix string) *TestContext {
cfg := configtesting.V1ToInternalWithDefaults(t, kubeschedulerconfigv1.KubeSchedulerConfiguration{ cfg := configtesting.V1ToInternalWithDefaults(t, kubeschedulerconfigv1.KubeSchedulerConfiguration{
Profiles: []kubeschedulerconfigv1.KubeSchedulerProfile{{ Profiles: []kubeschedulerconfigv1.KubeSchedulerProfile{{
SchedulerName: pointer.String(v1.DefaultSchedulerName), SchedulerName: ptr.To(v1.DefaultSchedulerName),
Plugins: &kubeschedulerconfigv1.Plugins{ Plugins: &kubeschedulerconfigv1.Plugins{
PostFilter: kubeschedulerconfigv1.PluginSet{ PostFilter: kubeschedulerconfigv1.PluginSet{
Disabled: []kubeschedulerconfigv1.Plugin{ Disabled: []kubeschedulerconfigv1.Plugin{