Merge pull request #125005 from brianpursley/fix-deprecated-ptr
Use ptr.To instead of deprecated pointer functions
This commit is contained in:
		@@ -59,7 +59,7 @@ import (
 | 
			
		||||
	cmdutil "k8s.io/kubectl/pkg/cmd/util"
 | 
			
		||||
	"k8s.io/kubectl/pkg/scheme"
 | 
			
		||||
	"k8s.io/kubectl/pkg/util/openapi"
 | 
			
		||||
	utilpointer "k8s.io/utils/pointer"
 | 
			
		||||
	"k8s.io/utils/ptr"
 | 
			
		||||
	"k8s.io/utils/strings/slices"
 | 
			
		||||
	"sigs.k8s.io/yaml"
 | 
			
		||||
)
 | 
			
		||||
@@ -2115,7 +2115,7 @@ func TestForceApply(t *testing.T) {
 | 
			
		||||
								var bodyRC io.ReadCloser
 | 
			
		||||
								if isScaledDownToZero {
 | 
			
		||||
									rcObj := readReplicationControllerFromFile(t, filenameRC)
 | 
			
		||||
									rcObj.Spec.Replicas = utilpointer.Int32Ptr(0)
 | 
			
		||||
									rcObj.Spec.Replicas = ptr.To[int32](0)
 | 
			
		||||
									rcBytes, err := runtime.Encode(codec, rcObj)
 | 
			
		||||
									if err != nil {
 | 
			
		||||
										t.Fatal(err)
 | 
			
		||||
 
 | 
			
		||||
@@ -39,7 +39,7 @@ import (
 | 
			
		||||
	"k8s.io/kubectl/pkg/util/completion"
 | 
			
		||||
	"k8s.io/kubectl/pkg/util/templates"
 | 
			
		||||
	"k8s.io/kubectl/pkg/util/term"
 | 
			
		||||
	"k8s.io/utils/pointer"
 | 
			
		||||
	"k8s.io/utils/ptr"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// TokenOptions is the data required to perform a token request operation.
 | 
			
		||||
@@ -247,7 +247,7 @@ func (o *TokenOptions) Run() error {
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
	if o.Duration > 0 {
 | 
			
		||||
		request.Spec.ExpirationSeconds = pointer.Int64(int64(o.Duration / time.Second))
 | 
			
		||||
		request.Spec.ExpirationSeconds = ptr.To(int64(o.Duration / time.Second))
 | 
			
		||||
	}
 | 
			
		||||
	if len(o.BoundObjectKind) > 0 {
 | 
			
		||||
		request.Spec.BoundObjectRef = &authenticationv1.BoundObjectReference{
 | 
			
		||||
 
 | 
			
		||||
@@ -27,7 +27,6 @@ import (
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"github.com/google/go-cmp/cmp"
 | 
			
		||||
	"k8s.io/utils/pointer"
 | 
			
		||||
	kjson "sigs.k8s.io/json"
 | 
			
		||||
 | 
			
		||||
	authenticationv1 "k8s.io/api/authentication/v1"
 | 
			
		||||
@@ -39,6 +38,7 @@ import (
 | 
			
		||||
	cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
 | 
			
		||||
	cmdutil "k8s.io/kubectl/pkg/cmd/util"
 | 
			
		||||
	"k8s.io/kubectl/pkg/scheme"
 | 
			
		||||
	"k8s.io/utils/ptr"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestCreateToken(t *testing.T) {
 | 
			
		||||
@@ -237,7 +237,7 @@ status:
 | 
			
		||||
			expectTokenRequest: &authenticationv1.TokenRequest{
 | 
			
		||||
				TypeMeta: metav1.TypeMeta{APIVersion: "authentication.k8s.io/v1", Kind: "TokenRequest"},
 | 
			
		||||
				Spec: authenticationv1.TokenRequestSpec{
 | 
			
		||||
					ExpirationSeconds: pointer.Int64(1000),
 | 
			
		||||
					ExpirationSeconds: ptr.To[int64](1000),
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			serverResponseToken: "abc",
 | 
			
		||||
 
 | 
			
		||||
@@ -25,8 +25,6 @@ import (
 | 
			
		||||
 | 
			
		||||
	"github.com/distribution/reference"
 | 
			
		||||
	"github.com/spf13/cobra"
 | 
			
		||||
	"k8s.io/klog/v2"
 | 
			
		||||
	"k8s.io/utils/pointer"
 | 
			
		||||
 | 
			
		||||
	corev1 "k8s.io/api/core/v1"
 | 
			
		||||
	"k8s.io/apimachinery/pkg/api/errors"
 | 
			
		||||
@@ -46,6 +44,7 @@ import (
 | 
			
		||||
	corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
 | 
			
		||||
	"k8s.io/client-go/tools/cache"
 | 
			
		||||
	watchtools "k8s.io/client-go/tools/watch"
 | 
			
		||||
	"k8s.io/klog/v2"
 | 
			
		||||
	"k8s.io/kubectl/pkg/cmd/attach"
 | 
			
		||||
	"k8s.io/kubectl/pkg/cmd/exec"
 | 
			
		||||
	"k8s.io/kubectl/pkg/cmd/logs"
 | 
			
		||||
@@ -56,6 +55,7 @@ import (
 | 
			
		||||
	"k8s.io/kubectl/pkg/util/interrupt"
 | 
			
		||||
	"k8s.io/kubectl/pkg/util/templates"
 | 
			
		||||
	"k8s.io/kubectl/pkg/util/term"
 | 
			
		||||
	"k8s.io/utils/ptr"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
@@ -737,7 +737,7 @@ func (o *DebugOptions) generatePodCopyWithDebugContainer(pod *corev1.Pod) (*core
 | 
			
		||||
	copied.Spec.EphemeralContainers = nil
 | 
			
		||||
	// change ShareProcessNamespace configuration only when commanded explicitly
 | 
			
		||||
	if o.shareProcessedChanged {
 | 
			
		||||
		copied.Spec.ShareProcessNamespace = pointer.Bool(o.ShareProcesses)
 | 
			
		||||
		copied.Spec.ShareProcessNamespace = ptr.To(o.ShareProcesses)
 | 
			
		||||
	}
 | 
			
		||||
	if !o.SameNode {
 | 
			
		||||
		copied.Spec.NodeName = ""
 | 
			
		||||
 
 | 
			
		||||
@@ -32,7 +32,7 @@ import (
 | 
			
		||||
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
			
		||||
	"k8s.io/cli-runtime/pkg/genericiooptions"
 | 
			
		||||
	cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
 | 
			
		||||
	"k8s.io/utils/pointer"
 | 
			
		||||
	"k8s.io/utils/ptr"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestGenerateDebugContainer(t *testing.T) {
 | 
			
		||||
@@ -287,11 +287,11 @@ func TestGenerateDebugContainer(t *testing.T) {
 | 
			
		||||
					ImagePullPolicy:          corev1.PullIfNotPresent,
 | 
			
		||||
					TerminationMessagePolicy: corev1.TerminationMessageReadFile,
 | 
			
		||||
					SecurityContext: &corev1.SecurityContext{
 | 
			
		||||
						RunAsNonRoot: pointer.Bool(true),
 | 
			
		||||
						RunAsNonRoot: ptr.To(true),
 | 
			
		||||
						Capabilities: &corev1.Capabilities{
 | 
			
		||||
							Drop: []corev1.Capability{"ALL"},
 | 
			
		||||
						},
 | 
			
		||||
						AllowPrivilegeEscalation: pointer.Bool(false),
 | 
			
		||||
						AllowPrivilegeEscalation: ptr.To(false),
 | 
			
		||||
						SeccompProfile:           &corev1.SeccompProfile{Type: "RuntimeDefault"},
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
@@ -332,7 +332,7 @@ func TestGenerateDebugContainer(t *testing.T) {
 | 
			
		||||
					ImagePullPolicy:          corev1.PullIfNotPresent,
 | 
			
		||||
					TerminationMessagePolicy: corev1.TerminationMessageReadFile,
 | 
			
		||||
					SecurityContext: &corev1.SecurityContext{
 | 
			
		||||
						Privileged: pointer.Bool(true),
 | 
			
		||||
						Privileged: ptr.To(true),
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
@@ -996,7 +996,7 @@ func TestGeneratePodCopyWithDebugContainer(t *testing.T) {
 | 
			
		||||
							TerminationMessagePolicy: corev1.TerminationMessageReadFile,
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
					ShareProcessNamespace: pointer.Bool(true),
 | 
			
		||||
					ShareProcessNamespace: ptr.To(true),
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
@@ -1241,7 +1241,7 @@ func TestGeneratePodCopyWithDebugContainer(t *testing.T) {
 | 
			
		||||
							},
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
					ShareProcessNamespace: pointer.Bool(true),
 | 
			
		||||
					ShareProcessNamespace: ptr.To(true),
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
@@ -1279,7 +1279,7 @@ func TestGeneratePodCopyWithDebugContainer(t *testing.T) {
 | 
			
		||||
							ImagePullPolicy: corev1.PullIfNotPresent,
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
					ShareProcessNamespace: pointer.Bool(true),
 | 
			
		||||
					ShareProcessNamespace: ptr.To(true),
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
@@ -1319,7 +1319,7 @@ func TestGeneratePodCopyWithDebugContainer(t *testing.T) {
 | 
			
		||||
							ImagePullPolicy: corev1.PullIfNotPresent,
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
					ShareProcessNamespace: pointer.Bool(false),
 | 
			
		||||
					ShareProcessNamespace: ptr.To(false),
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
@@ -1356,16 +1356,16 @@ func TestGeneratePodCopyWithDebugContainer(t *testing.T) {
 | 
			
		||||
							Image:           "busybox",
 | 
			
		||||
							ImagePullPolicy: corev1.PullIfNotPresent,
 | 
			
		||||
							SecurityContext: &corev1.SecurityContext{
 | 
			
		||||
								RunAsNonRoot: pointer.Bool(true),
 | 
			
		||||
								RunAsNonRoot: ptr.To(true),
 | 
			
		||||
								Capabilities: &corev1.Capabilities{
 | 
			
		||||
									Drop: []corev1.Capability{"ALL"},
 | 
			
		||||
								},
 | 
			
		||||
								AllowPrivilegeEscalation: pointer.Bool(false),
 | 
			
		||||
								AllowPrivilegeEscalation: ptr.To(false),
 | 
			
		||||
								SeccompProfile:           &corev1.SeccompProfile{Type: "RuntimeDefault"},
 | 
			
		||||
							},
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
					ShareProcessNamespace: pointer.Bool(true),
 | 
			
		||||
					ShareProcessNamespace: ptr.To(true),
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
@@ -1408,7 +1408,7 @@ func TestGeneratePodCopyWithDebugContainer(t *testing.T) {
 | 
			
		||||
							},
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
					ShareProcessNamespace: pointer.Bool(true),
 | 
			
		||||
					ShareProcessNamespace: ptr.To(true),
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
@@ -1735,11 +1735,11 @@ func TestGenerateNodeDebugPod(t *testing.T) {
 | 
			
		||||
							TerminationMessagePolicy: corev1.TerminationMessageReadFile,
 | 
			
		||||
							VolumeMounts:             nil,
 | 
			
		||||
							SecurityContext: &corev1.SecurityContext{
 | 
			
		||||
								RunAsNonRoot: pointer.Bool(true),
 | 
			
		||||
								RunAsNonRoot: ptr.To(true),
 | 
			
		||||
								Capabilities: &corev1.Capabilities{
 | 
			
		||||
									Drop: []corev1.Capability{"ALL"},
 | 
			
		||||
								},
 | 
			
		||||
								AllowPrivilegeEscalation: pointer.Bool(false),
 | 
			
		||||
								AllowPrivilegeEscalation: ptr.To(false),
 | 
			
		||||
								SeccompProfile:           &corev1.SeccompProfile{Type: "RuntimeDefault"},
 | 
			
		||||
							},
 | 
			
		||||
						},
 | 
			
		||||
@@ -1858,7 +1858,7 @@ func TestGenerateNodeDebugPodCustomProfile(t *testing.T) {
 | 
			
		||||
						Capabilities: &corev1.Capabilities{
 | 
			
		||||
							Drop: []corev1.Capability{"ALL"},
 | 
			
		||||
						},
 | 
			
		||||
						RunAsNonRoot: pointer.Bool(false),
 | 
			
		||||
						RunAsNonRoot: ptr.To(false),
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
@@ -1877,7 +1877,7 @@ func TestGenerateNodeDebugPodCustomProfile(t *testing.T) {
 | 
			
		||||
							Stdin:                    true,
 | 
			
		||||
							TTY:                      false,
 | 
			
		||||
							SecurityContext: &corev1.SecurityContext{
 | 
			
		||||
								RunAsNonRoot: pointer.Bool(false),
 | 
			
		||||
								RunAsNonRoot: ptr.To(false),
 | 
			
		||||
								Capabilities: &corev1.Capabilities{
 | 
			
		||||
									Drop: []corev1.Capability{"ALL"},
 | 
			
		||||
								},
 | 
			
		||||
@@ -1930,11 +1930,11 @@ func TestGenerateNodeDebugPodCustomProfile(t *testing.T) {
 | 
			
		||||
							Stdin:                    true,
 | 
			
		||||
							TTY:                      false,
 | 
			
		||||
							SecurityContext: &corev1.SecurityContext{
 | 
			
		||||
								RunAsNonRoot: pointer.Bool(true),
 | 
			
		||||
								RunAsNonRoot: ptr.To(true),
 | 
			
		||||
								Capabilities: &corev1.Capabilities{
 | 
			
		||||
									Drop: []corev1.Capability{"ALL"},
 | 
			
		||||
								},
 | 
			
		||||
								AllowPrivilegeEscalation: pointer.Bool(false),
 | 
			
		||||
								AllowPrivilegeEscalation: ptr.To(false),
 | 
			
		||||
								SeccompProfile:           &corev1.SeccompProfile{Type: "RuntimeDefault"},
 | 
			
		||||
							},
 | 
			
		||||
						},
 | 
			
		||||
@@ -2058,7 +2058,7 @@ func TestGenerateNodeDebugPodCustomProfile(t *testing.T) {
 | 
			
		||||
								},
 | 
			
		||||
							},
 | 
			
		||||
							SecurityContext: &corev1.SecurityContext{
 | 
			
		||||
								Privileged: pointer.Bool(true),
 | 
			
		||||
								Privileged: ptr.To(true),
 | 
			
		||||
							},
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
@@ -2145,7 +2145,7 @@ func TestGenerateCopyDebugPodCustomProfile(t *testing.T) {
 | 
			
		||||
						Capabilities: &corev1.Capabilities{
 | 
			
		||||
							Drop: []corev1.Capability{"ALL"},
 | 
			
		||||
						},
 | 
			
		||||
						RunAsNonRoot: pointer.Bool(false),
 | 
			
		||||
						RunAsNonRoot: ptr.To(false),
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
@@ -2162,7 +2162,7 @@ func TestGenerateCopyDebugPodCustomProfile(t *testing.T) {
 | 
			
		||||
							Stdin:                    true,
 | 
			
		||||
							TTY:                      false,
 | 
			
		||||
							SecurityContext: &corev1.SecurityContext{
 | 
			
		||||
								RunAsNonRoot: pointer.Bool(false),
 | 
			
		||||
								RunAsNonRoot: ptr.To(false),
 | 
			
		||||
								Capabilities: &corev1.Capabilities{
 | 
			
		||||
									Drop: []corev1.Capability{"ALL"},
 | 
			
		||||
								},
 | 
			
		||||
@@ -2173,7 +2173,7 @@ func TestGenerateCopyDebugPodCustomProfile(t *testing.T) {
 | 
			
		||||
					HostNetwork:           false,
 | 
			
		||||
					HostPID:               false,
 | 
			
		||||
					Volumes:               nil,
 | 
			
		||||
					ShareProcessNamespace: pointer.Bool(true),
 | 
			
		||||
					ShareProcessNamespace: ptr.To(true),
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
@@ -2198,7 +2198,7 @@ func TestGenerateCopyDebugPodCustomProfile(t *testing.T) {
 | 
			
		||||
						Capabilities: &corev1.Capabilities{
 | 
			
		||||
							Drop: []corev1.Capability{"ALL"},
 | 
			
		||||
						},
 | 
			
		||||
						RunAsNonRoot: pointer.Bool(false),
 | 
			
		||||
						RunAsNonRoot: ptr.To(false),
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
@@ -2215,8 +2215,8 @@ func TestGenerateCopyDebugPodCustomProfile(t *testing.T) {
 | 
			
		||||
							Stdin:                    true,
 | 
			
		||||
							TTY:                      false,
 | 
			
		||||
							SecurityContext: &corev1.SecurityContext{
 | 
			
		||||
								AllowPrivilegeEscalation: pointer.Bool(false),
 | 
			
		||||
								RunAsNonRoot:             pointer.Bool(false),
 | 
			
		||||
								AllowPrivilegeEscalation: ptr.To(false),
 | 
			
		||||
								RunAsNonRoot:             ptr.To(false),
 | 
			
		||||
								Capabilities: &corev1.Capabilities{
 | 
			
		||||
									Drop: []corev1.Capability{"ALL"},
 | 
			
		||||
								},
 | 
			
		||||
@@ -2231,7 +2231,7 @@ func TestGenerateCopyDebugPodCustomProfile(t *testing.T) {
 | 
			
		||||
					HostNetwork:           false,
 | 
			
		||||
					HostPID:               false,
 | 
			
		||||
					Volumes:               nil,
 | 
			
		||||
					ShareProcessNamespace: pointer.Bool(true),
 | 
			
		||||
					ShareProcessNamespace: ptr.To(true),
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
@@ -2256,7 +2256,7 @@ func TestGenerateCopyDebugPodCustomProfile(t *testing.T) {
 | 
			
		||||
						Capabilities: &corev1.Capabilities{
 | 
			
		||||
							Drop: []corev1.Capability{"ALL"},
 | 
			
		||||
						},
 | 
			
		||||
						RunAsNonRoot: pointer.Bool(false),
 | 
			
		||||
						RunAsNonRoot: ptr.To(false),
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
@@ -2273,8 +2273,8 @@ func TestGenerateCopyDebugPodCustomProfile(t *testing.T) {
 | 
			
		||||
							Stdin:                    true,
 | 
			
		||||
							TTY:                      false,
 | 
			
		||||
							SecurityContext: &corev1.SecurityContext{
 | 
			
		||||
								AllowPrivilegeEscalation: pointer.Bool(false),
 | 
			
		||||
								RunAsNonRoot:             pointer.Bool(false),
 | 
			
		||||
								AllowPrivilegeEscalation: ptr.To(false),
 | 
			
		||||
								RunAsNonRoot:             ptr.To(false),
 | 
			
		||||
								Capabilities: &corev1.Capabilities{
 | 
			
		||||
									Drop: []corev1.Capability{"ALL"},
 | 
			
		||||
								},
 | 
			
		||||
@@ -2289,7 +2289,7 @@ func TestGenerateCopyDebugPodCustomProfile(t *testing.T) {
 | 
			
		||||
					HostNetwork:           false,
 | 
			
		||||
					HostPID:               false,
 | 
			
		||||
					Volumes:               nil,
 | 
			
		||||
					ShareProcessNamespace: pointer.Bool(true),
 | 
			
		||||
					ShareProcessNamespace: ptr.To(true),
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
@@ -2353,7 +2353,7 @@ func TestGenerateEphemeralDebugPodCustomProfile(t *testing.T) {
 | 
			
		||||
						Capabilities: &corev1.Capabilities{
 | 
			
		||||
							Drop: []corev1.Capability{"ALL"},
 | 
			
		||||
						},
 | 
			
		||||
						RunAsNonRoot: pointer.Bool(false),
 | 
			
		||||
						RunAsNonRoot: ptr.To(false),
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
@@ -2372,7 +2372,7 @@ func TestGenerateEphemeralDebugPodCustomProfile(t *testing.T) {
 | 
			
		||||
								Stdin:                    true,
 | 
			
		||||
								TTY:                      false,
 | 
			
		||||
								SecurityContext: &corev1.SecurityContext{
 | 
			
		||||
									RunAsNonRoot: pointer.Bool(false),
 | 
			
		||||
									RunAsNonRoot: ptr.To(false),
 | 
			
		||||
									Capabilities: &corev1.Capabilities{
 | 
			
		||||
										Drop: []corev1.Capability{"ALL"},
 | 
			
		||||
									},
 | 
			
		||||
@@ -2408,7 +2408,7 @@ func TestGenerateEphemeralDebugPodCustomProfile(t *testing.T) {
 | 
			
		||||
						Capabilities: &corev1.Capabilities{
 | 
			
		||||
							Drop: []corev1.Capability{"ALL"},
 | 
			
		||||
						},
 | 
			
		||||
						RunAsNonRoot: pointer.Bool(false),
 | 
			
		||||
						RunAsNonRoot: ptr.To(false),
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
@@ -2427,8 +2427,8 @@ func TestGenerateEphemeralDebugPodCustomProfile(t *testing.T) {
 | 
			
		||||
								Stdin:                    true,
 | 
			
		||||
								TTY:                      false,
 | 
			
		||||
								SecurityContext: &corev1.SecurityContext{
 | 
			
		||||
									AllowPrivilegeEscalation: pointer.Bool(false),
 | 
			
		||||
									RunAsNonRoot:             pointer.Bool(false),
 | 
			
		||||
									AllowPrivilegeEscalation: ptr.To(false),
 | 
			
		||||
									RunAsNonRoot:             ptr.To(false),
 | 
			
		||||
									Capabilities: &corev1.Capabilities{
 | 
			
		||||
										Drop: []corev1.Capability{"ALL"},
 | 
			
		||||
									},
 | 
			
		||||
@@ -2468,7 +2468,7 @@ func TestGenerateEphemeralDebugPodCustomProfile(t *testing.T) {
 | 
			
		||||
						Capabilities: &corev1.Capabilities{
 | 
			
		||||
							Drop: []corev1.Capability{"ALL"},
 | 
			
		||||
						},
 | 
			
		||||
						RunAsNonRoot: pointer.Bool(false),
 | 
			
		||||
						RunAsNonRoot: ptr.To(false),
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
@@ -2487,8 +2487,8 @@ func TestGenerateEphemeralDebugPodCustomProfile(t *testing.T) {
 | 
			
		||||
								Stdin:                    true,
 | 
			
		||||
								TTY:                      false,
 | 
			
		||||
								SecurityContext: &corev1.SecurityContext{
 | 
			
		||||
									AllowPrivilegeEscalation: pointer.Bool(false),
 | 
			
		||||
									RunAsNonRoot:             pointer.Bool(false),
 | 
			
		||||
									AllowPrivilegeEscalation: ptr.To(false),
 | 
			
		||||
									RunAsNonRoot:             ptr.To(false),
 | 
			
		||||
									Capabilities: &corev1.Capabilities{
 | 
			
		||||
										Drop: []corev1.Capability{"ALL"},
 | 
			
		||||
									},
 | 
			
		||||
 
 | 
			
		||||
@@ -22,7 +22,7 @@ import (
 | 
			
		||||
	corev1 "k8s.io/api/core/v1"
 | 
			
		||||
	"k8s.io/apimachinery/pkg/runtime"
 | 
			
		||||
	"k8s.io/kubectl/pkg/util/podutils"
 | 
			
		||||
	"k8s.io/utils/pointer"
 | 
			
		||||
	"k8s.io/utils/ptr"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type debugStyle int
 | 
			
		||||
@@ -353,7 +353,7 @@ func useHostNamespaces(p *corev1.Pod) {
 | 
			
		||||
// process namespace.
 | 
			
		||||
func shareProcessNamespace(p *corev1.Pod) {
 | 
			
		||||
	if p.Spec.ShareProcessNamespace == nil {
 | 
			
		||||
		p.Spec.ShareProcessNamespace = pointer.Bool(true)
 | 
			
		||||
		p.Spec.ShareProcessNamespace = ptr.To(true)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -377,7 +377,7 @@ func setPrivileged(p *corev1.Pod, containerName string) {
 | 
			
		||||
		if c.SecurityContext == nil {
 | 
			
		||||
			c.SecurityContext = &corev1.SecurityContext{}
 | 
			
		||||
		}
 | 
			
		||||
		c.SecurityContext.Privileged = pointer.Bool(true)
 | 
			
		||||
		c.SecurityContext.Privileged = ptr.To(true)
 | 
			
		||||
		return false
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
@@ -391,7 +391,7 @@ func disallowRoot(p *corev1.Pod, containerName string) {
 | 
			
		||||
		if c.SecurityContext == nil {
 | 
			
		||||
			c.SecurityContext = &corev1.SecurityContext{}
 | 
			
		||||
		}
 | 
			
		||||
		c.SecurityContext.RunAsNonRoot = pointer.Bool(true)
 | 
			
		||||
		c.SecurityContext.RunAsNonRoot = ptr.To(true)
 | 
			
		||||
		return false
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
@@ -456,7 +456,7 @@ func disallowPrivilegeEscalation(p *corev1.Pod, containerName string) {
 | 
			
		||||
		if c.SecurityContext == nil {
 | 
			
		||||
			c.SecurityContext = &corev1.SecurityContext{}
 | 
			
		||||
		}
 | 
			
		||||
		c.SecurityContext.AllowPrivilegeEscalation = pointer.Bool(false)
 | 
			
		||||
		c.SecurityContext.AllowPrivilegeEscalation = ptr.To(false)
 | 
			
		||||
		return false
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -25,7 +25,7 @@ import (
 | 
			
		||||
	corev1 "k8s.io/api/core/v1"
 | 
			
		||||
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
			
		||||
	"k8s.io/apimachinery/pkg/runtime"
 | 
			
		||||
	"k8s.io/utils/pointer"
 | 
			
		||||
	"k8s.io/utils/ptr"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var testNode = &corev1.Node{
 | 
			
		||||
@@ -349,7 +349,7 @@ func TestGeneralProfile(t *testing.T) {
 | 
			
		||||
							},
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
					ShareProcessNamespace: pointer.Bool(true),
 | 
			
		||||
					ShareProcessNamespace: ptr.To(true),
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
@@ -509,7 +509,7 @@ func TestBaselineProfile(t *testing.T) {
 | 
			
		||||
			expectPod: &corev1.Pod{
 | 
			
		||||
				ObjectMeta: metav1.ObjectMeta{Name: "podcopy"},
 | 
			
		||||
				Spec: corev1.PodSpec{
 | 
			
		||||
					ShareProcessNamespace: pointer.Bool(true),
 | 
			
		||||
					ShareProcessNamespace: ptr.To(true),
 | 
			
		||||
					InitContainers:        []corev1.Container{{Name: "init-container"}},
 | 
			
		||||
					Containers: []corev1.Container{
 | 
			
		||||
						{Name: "app", Image: "appimage"},
 | 
			
		||||
@@ -604,11 +604,11 @@ func TestRestrictedProfile(t *testing.T) {
 | 
			
		||||
						EphemeralContainerCommon: corev1.EphemeralContainerCommon{
 | 
			
		||||
							Name: "dbg", Image: "dbgimage",
 | 
			
		||||
							SecurityContext: &corev1.SecurityContext{
 | 
			
		||||
								RunAsNonRoot: pointer.Bool(true),
 | 
			
		||||
								RunAsNonRoot: ptr.To(true),
 | 
			
		||||
								Capabilities: &corev1.Capabilities{
 | 
			
		||||
									Drop: []corev1.Capability{"ALL"},
 | 
			
		||||
								},
 | 
			
		||||
								AllowPrivilegeEscalation: pointer.Bool(false),
 | 
			
		||||
								AllowPrivilegeEscalation: ptr.To(false),
 | 
			
		||||
								SeccompProfile:           &corev1.SeccompProfile{Type: "RuntimeDefault"},
 | 
			
		||||
							},
 | 
			
		||||
						},
 | 
			
		||||
@@ -668,7 +668,7 @@ func TestRestrictedProfile(t *testing.T) {
 | 
			
		||||
			expectPod: &corev1.Pod{
 | 
			
		||||
				ObjectMeta: metav1.ObjectMeta{Name: "podcopy"},
 | 
			
		||||
				Spec: corev1.PodSpec{
 | 
			
		||||
					ShareProcessNamespace: pointer.Bool(true),
 | 
			
		||||
					ShareProcessNamespace: ptr.To(true),
 | 
			
		||||
					InitContainers:        []corev1.Container{{Name: "init-container"}},
 | 
			
		||||
					Containers: []corev1.Container{
 | 
			
		||||
						{Name: "app", Image: "appimage"},
 | 
			
		||||
@@ -676,11 +676,11 @@ func TestRestrictedProfile(t *testing.T) {
 | 
			
		||||
							Name:  "dbg",
 | 
			
		||||
							Image: "dbgimage",
 | 
			
		||||
							SecurityContext: &corev1.SecurityContext{
 | 
			
		||||
								RunAsNonRoot: pointer.Bool(true),
 | 
			
		||||
								RunAsNonRoot: ptr.To(true),
 | 
			
		||||
								Capabilities: &corev1.Capabilities{
 | 
			
		||||
									Drop: []corev1.Capability{"ALL"},
 | 
			
		||||
								},
 | 
			
		||||
								AllowPrivilegeEscalation: pointer.Bool(false),
 | 
			
		||||
								AllowPrivilegeEscalation: ptr.To(false),
 | 
			
		||||
								SeccompProfile:           &corev1.SeccompProfile{Type: "RuntimeDefault"},
 | 
			
		||||
							},
 | 
			
		||||
						},
 | 
			
		||||
@@ -700,7 +700,7 @@ func TestRestrictedProfile(t *testing.T) {
 | 
			
		||||
								Capabilities: &corev1.Capabilities{
 | 
			
		||||
									Add: []corev1.Capability{"ALL"},
 | 
			
		||||
								},
 | 
			
		||||
								AllowPrivilegeEscalation: pointer.Bool(false),
 | 
			
		||||
								AllowPrivilegeEscalation: ptr.To(false),
 | 
			
		||||
								SeccompProfile:           &corev1.SeccompProfile{Type: "RuntimeDefault"},
 | 
			
		||||
							},
 | 
			
		||||
						},
 | 
			
		||||
@@ -717,11 +717,11 @@ func TestRestrictedProfile(t *testing.T) {
 | 
			
		||||
							Name:  "dbg",
 | 
			
		||||
							Image: "dbgimage",
 | 
			
		||||
							SecurityContext: &corev1.SecurityContext{
 | 
			
		||||
								RunAsNonRoot: pointer.Bool(true),
 | 
			
		||||
								RunAsNonRoot: ptr.To(true),
 | 
			
		||||
								Capabilities: &corev1.Capabilities{
 | 
			
		||||
									Drop: []corev1.Capability{"ALL"},
 | 
			
		||||
								},
 | 
			
		||||
								AllowPrivilegeEscalation: pointer.Bool(false),
 | 
			
		||||
								AllowPrivilegeEscalation: ptr.To(false),
 | 
			
		||||
								SeccompProfile:           &corev1.SeccompProfile{Type: "RuntimeDefault"},
 | 
			
		||||
							},
 | 
			
		||||
						},
 | 
			
		||||
@@ -849,7 +849,7 @@ func TestNetAdminProfile(t *testing.T) {
 | 
			
		||||
			expectPod: &corev1.Pod{
 | 
			
		||||
				ObjectMeta: metav1.ObjectMeta{Name: "podcopy"},
 | 
			
		||||
				Spec: corev1.PodSpec{
 | 
			
		||||
					ShareProcessNamespace: pointer.Bool(true),
 | 
			
		||||
					ShareProcessNamespace: ptr.To(true),
 | 
			
		||||
					InitContainers:        []corev1.Container{{Name: "init-container"}},
 | 
			
		||||
					Containers: []corev1.Container{
 | 
			
		||||
						{Name: "app", Image: "appimage"},
 | 
			
		||||
@@ -909,7 +909,7 @@ func TestNetAdminProfile(t *testing.T) {
 | 
			
		||||
			expectPod: &corev1.Pod{
 | 
			
		||||
				ObjectMeta: metav1.ObjectMeta{Name: "podcopy"},
 | 
			
		||||
				Spec: corev1.PodSpec{
 | 
			
		||||
					ShareProcessNamespace: pointer.Bool(true),
 | 
			
		||||
					ShareProcessNamespace: ptr.To(true),
 | 
			
		||||
					Containers: []corev1.Container{
 | 
			
		||||
						{Name: "app", Image: "appimage"},
 | 
			
		||||
						{
 | 
			
		||||
@@ -1055,7 +1055,7 @@ func TestSysAdminProfile(t *testing.T) {
 | 
			
		||||
						EphemeralContainerCommon: corev1.EphemeralContainerCommon{
 | 
			
		||||
							Name: "dbg", Image: "dbgimage",
 | 
			
		||||
							SecurityContext: &corev1.SecurityContext{
 | 
			
		||||
								Privileged: pointer.Bool(true),
 | 
			
		||||
								Privileged: ptr.To(true),
 | 
			
		||||
							},
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
@@ -1122,11 +1122,11 @@ func TestSysAdminProfile(t *testing.T) {
 | 
			
		||||
							Name:  "dbg",
 | 
			
		||||
							Image: "dbgimage",
 | 
			
		||||
							SecurityContext: &corev1.SecurityContext{
 | 
			
		||||
								Privileged: pointer.Bool(true),
 | 
			
		||||
								Privileged: ptr.To(true),
 | 
			
		||||
							},
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
					ShareProcessNamespace: pointer.Bool(true),
 | 
			
		||||
					ShareProcessNamespace: ptr.To(true),
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
@@ -1179,14 +1179,14 @@ func TestSysAdminProfile(t *testing.T) {
 | 
			
		||||
							Name:  "dbg",
 | 
			
		||||
							Image: "dbgimage",
 | 
			
		||||
							SecurityContext: &corev1.SecurityContext{
 | 
			
		||||
								Privileged: pointer.Bool(true),
 | 
			
		||||
								Privileged: ptr.To(true),
 | 
			
		||||
								Capabilities: &corev1.Capabilities{
 | 
			
		||||
									Add: []corev1.Capability{"SYS_PTRACE"},
 | 
			
		||||
								},
 | 
			
		||||
							},
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
					ShareProcessNamespace: pointer.Bool(true),
 | 
			
		||||
					ShareProcessNamespace: ptr.To(true),
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
@@ -1219,7 +1219,7 @@ func TestSysAdminProfile(t *testing.T) {
 | 
			
		||||
							Name:  "dbg",
 | 
			
		||||
							Image: "dbgimage",
 | 
			
		||||
							SecurityContext: &corev1.SecurityContext{
 | 
			
		||||
								Privileged: pointer.Bool(true),
 | 
			
		||||
								Privileged: ptr.To(true),
 | 
			
		||||
							},
 | 
			
		||||
							VolumeMounts: []corev1.VolumeMount{{Name: "host-root", MountPath: "/host"}},
 | 
			
		||||
						},
 | 
			
		||||
@@ -1264,7 +1264,7 @@ func TestSysAdminProfile(t *testing.T) {
 | 
			
		||||
							Name:  "dbg",
 | 
			
		||||
							Image: "dbgimage",
 | 
			
		||||
							SecurityContext: &corev1.SecurityContext{
 | 
			
		||||
								Privileged: pointer.Bool(true),
 | 
			
		||||
								Privileged: ptr.To(true),
 | 
			
		||||
								Capabilities: &corev1.Capabilities{
 | 
			
		||||
									Add: []corev1.Capability{"SYS_PTRACE"},
 | 
			
		||||
								},
 | 
			
		||||
 
 | 
			
		||||
@@ -36,7 +36,7 @@ import (
 | 
			
		||||
	cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
 | 
			
		||||
	cmdutil "k8s.io/kubectl/pkg/cmd/util"
 | 
			
		||||
	"k8s.io/kubectl/pkg/scheme"
 | 
			
		||||
	"k8s.io/utils/pointer"
 | 
			
		||||
	"k8s.io/utils/ptr"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func fakecmd() *cobra.Command {
 | 
			
		||||
@@ -60,8 +60,8 @@ func TestDeleteFlagValidation(t *testing.T) {
 | 
			
		||||
	}{
 | 
			
		||||
		{
 | 
			
		||||
			flags: DeleteFlags{
 | 
			
		||||
				Raw:         pointer.String("test"),
 | 
			
		||||
				Interactive: pointer.Bool(true),
 | 
			
		||||
				Raw:         ptr.To("test"),
 | 
			
		||||
				Interactive: ptr.To(true),
 | 
			
		||||
			},
 | 
			
		||||
			expectedErr: "--interactive can not be used with --raw",
 | 
			
		||||
		},
 | 
			
		||||
@@ -306,7 +306,7 @@ func TestDeleteObject(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
func TestPreviewResultEqualToResult(t *testing.T) {
 | 
			
		||||
	deleteFlags := NewDeleteCommandFlags("")
 | 
			
		||||
	deleteFlags.Interactive = pointer.Bool(true)
 | 
			
		||||
	deleteFlags.Interactive = ptr.To(true)
 | 
			
		||||
 | 
			
		||||
	tf := cmdtesting.NewTestFactory().WithNamespace("test")
 | 
			
		||||
	defer tf.Cleanup()
 | 
			
		||||
 
 | 
			
		||||
@@ -42,7 +42,7 @@ import (
 | 
			
		||||
	cmdutil "k8s.io/kubectl/pkg/cmd/util"
 | 
			
		||||
	"k8s.io/kubectl/pkg/drain"
 | 
			
		||||
	"k8s.io/kubectl/pkg/scheme"
 | 
			
		||||
	utilpointer "k8s.io/utils/pointer"
 | 
			
		||||
	"k8s.io/utils/ptr"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
@@ -277,8 +277,8 @@ func TestDrain(t *testing.T) {
 | 
			
		||||
					Kind:               "ReplicationController",
 | 
			
		||||
					Name:               "rc",
 | 
			
		||||
					UID:                "123",
 | 
			
		||||
					BlockOwnerDeletion: utilpointer.BoolPtr(true),
 | 
			
		||||
					Controller:         utilpointer.BoolPtr(true),
 | 
			
		||||
					BlockOwnerDeletion: ptr.To(true),
 | 
			
		||||
					Controller:         ptr.To(true),
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
@@ -309,8 +309,8 @@ func TestDrain(t *testing.T) {
 | 
			
		||||
					APIVersion:         "apps/v1",
 | 
			
		||||
					Kind:               "DaemonSet",
 | 
			
		||||
					Name:               "ds",
 | 
			
		||||
					BlockOwnerDeletion: utilpointer.BoolPtr(true),
 | 
			
		||||
					Controller:         utilpointer.BoolPtr(true),
 | 
			
		||||
					BlockOwnerDeletion: ptr.To(true),
 | 
			
		||||
					Controller:         ptr.To(true),
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
@@ -330,8 +330,8 @@ func TestDrain(t *testing.T) {
 | 
			
		||||
					APIVersion:         "apps/v1",
 | 
			
		||||
					Kind:               "DaemonSet",
 | 
			
		||||
					Name:               "ds",
 | 
			
		||||
					BlockOwnerDeletion: utilpointer.BoolPtr(true),
 | 
			
		||||
					Controller:         utilpointer.BoolPtr(true),
 | 
			
		||||
					BlockOwnerDeletion: ptr.To(true),
 | 
			
		||||
					Controller:         ptr.To(true),
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
@@ -354,8 +354,8 @@ func TestDrain(t *testing.T) {
 | 
			
		||||
					APIVersion:         "apps/v1",
 | 
			
		||||
					Kind:               "DaemonSet",
 | 
			
		||||
					Name:               "ds",
 | 
			
		||||
					BlockOwnerDeletion: utilpointer.BoolPtr(true),
 | 
			
		||||
					Controller:         utilpointer.BoolPtr(true),
 | 
			
		||||
					BlockOwnerDeletion: ptr.To(true),
 | 
			
		||||
					Controller:         ptr.To(true),
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
@@ -404,8 +404,8 @@ func TestDrain(t *testing.T) {
 | 
			
		||||
					APIVersion:         "v1",
 | 
			
		||||
					Kind:               "Job",
 | 
			
		||||
					Name:               "job",
 | 
			
		||||
					BlockOwnerDeletion: utilpointer.BoolPtr(true),
 | 
			
		||||
					Controller:         utilpointer.BoolPtr(true),
 | 
			
		||||
					BlockOwnerDeletion: ptr.To(true),
 | 
			
		||||
					Controller:         ptr.To(true),
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
@@ -431,8 +431,8 @@ func TestDrain(t *testing.T) {
 | 
			
		||||
					APIVersion:         "v1",
 | 
			
		||||
					Kind:               "Job",
 | 
			
		||||
					Name:               "job",
 | 
			
		||||
					BlockOwnerDeletion: utilpointer.BoolPtr(true),
 | 
			
		||||
					Controller:         utilpointer.BoolPtr(true),
 | 
			
		||||
					BlockOwnerDeletion: ptr.To(true),
 | 
			
		||||
					Controller:         ptr.To(true),
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
@@ -473,8 +473,8 @@ func TestDrain(t *testing.T) {
 | 
			
		||||
					APIVersion:         "v1",
 | 
			
		||||
					Kind:               "ReplicaSet",
 | 
			
		||||
					Name:               "rs",
 | 
			
		||||
					BlockOwnerDeletion: utilpointer.BoolPtr(true),
 | 
			
		||||
					Controller:         utilpointer.BoolPtr(true),
 | 
			
		||||
					BlockOwnerDeletion: ptr.To(true),
 | 
			
		||||
					Controller:         ptr.To(true),
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
 
 | 
			
		||||
@@ -49,7 +49,7 @@ import (
 | 
			
		||||
	"k8s.io/kubectl/pkg/util/interrupt"
 | 
			
		||||
	"k8s.io/kubectl/pkg/util/slice"
 | 
			
		||||
	"k8s.io/kubectl/pkg/util/templates"
 | 
			
		||||
	utilpointer "k8s.io/utils/pointer"
 | 
			
		||||
	"k8s.io/utils/ptr"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// GetOptions contains the input to the get command.
 | 
			
		||||
@@ -631,7 +631,7 @@ func (o *GetOptions) watch(f cmdutil.Factory, args []string) error {
 | 
			
		||||
 | 
			
		||||
	info := infos[0]
 | 
			
		||||
	mapping := info.ResourceMapping()
 | 
			
		||||
	outputObjects := utilpointer.BoolPtr(!o.WatchOnly)
 | 
			
		||||
	outputObjects := ptr.To(!o.WatchOnly)
 | 
			
		||||
	printer, err := o.ToPrinter(mapping, outputObjects, o.AllNamespaces, false)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
 
 | 
			
		||||
@@ -31,6 +31,7 @@ import (
 | 
			
		||||
	metav1beta1 "k8s.io/apimachinery/pkg/apis/meta/v1beta1"
 | 
			
		||||
	"k8s.io/apimachinery/pkg/runtime"
 | 
			
		||||
	"k8s.io/kubectl/pkg/scheme"
 | 
			
		||||
	"k8s.io/utils/ptr"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func toUnstructuredOrDie(data []byte) *unstructured.Unstructured {
 | 
			
		||||
@@ -103,8 +104,6 @@ func createUnstructuredPodResource(t *testing.T, memReq, memLimit, cpuReq, cpuLi
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestSortingPrinter(t *testing.T) {
 | 
			
		||||
	intPtr := func(val int32) *int32 { return &val }
 | 
			
		||||
 | 
			
		||||
	a := &corev1.Pod{
 | 
			
		||||
		ObjectMeta: metav1.ObjectMeta{
 | 
			
		||||
			Name: "a",
 | 
			
		||||
@@ -272,17 +271,17 @@ func TestSortingPrinter(t *testing.T) {
 | 
			
		||||
				Items: []corev1.ReplicationController{
 | 
			
		||||
					{
 | 
			
		||||
						Spec: corev1.ReplicationControllerSpec{
 | 
			
		||||
							Replicas: intPtr(5),
 | 
			
		||||
							Replicas: ptr.To[int32](5),
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
					{
 | 
			
		||||
						Spec: corev1.ReplicationControllerSpec{
 | 
			
		||||
							Replicas: intPtr(1),
 | 
			
		||||
							Replicas: ptr.To[int32](1),
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
					{
 | 
			
		||||
						Spec: corev1.ReplicationControllerSpec{
 | 
			
		||||
							Replicas: intPtr(9),
 | 
			
		||||
							Replicas: ptr.To[int32](9),
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
@@ -291,17 +290,17 @@ func TestSortingPrinter(t *testing.T) {
 | 
			
		||||
				Items: []corev1.ReplicationController{
 | 
			
		||||
					{
 | 
			
		||||
						Spec: corev1.ReplicationControllerSpec{
 | 
			
		||||
							Replicas: intPtr(1),
 | 
			
		||||
							Replicas: ptr.To[int32](1),
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
					{
 | 
			
		||||
						Spec: corev1.ReplicationControllerSpec{
 | 
			
		||||
							Replicas: intPtr(5),
 | 
			
		||||
							Replicas: ptr.To[int32](5),
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
					{
 | 
			
		||||
						Spec: corev1.ReplicationControllerSpec{
 | 
			
		||||
							Replicas: intPtr(9),
 | 
			
		||||
							Replicas: ptr.To[int32](9),
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
 
 | 
			
		||||
@@ -52,7 +52,6 @@ import (
 | 
			
		||||
	"k8s.io/apimachinery/pkg/util/intstr"
 | 
			
		||||
	"k8s.io/client-go/kubernetes"
 | 
			
		||||
	"k8s.io/client-go/kubernetes/fake"
 | 
			
		||||
	utilpointer "k8s.io/utils/pointer"
 | 
			
		||||
	"k8s.io/utils/ptr"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@@ -1374,7 +1373,7 @@ func TestDefaultDescribers(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
	out, err = DefaultObjectDescriber.DescribeObject(&corev1.ReplicationController{
 | 
			
		||||
		ObjectMeta: metav1.ObjectMeta{Name: "foo"},
 | 
			
		||||
		Spec:       corev1.ReplicationControllerSpec{Replicas: utilpointer.Int32(1)},
 | 
			
		||||
		Spec:       corev1.ReplicationControllerSpec{Replicas: ptr.To[int32](1)},
 | 
			
		||||
	})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Fatalf("unexpected error: %v", err)
 | 
			
		||||
@@ -1393,7 +1392,7 @@ func TestDefaultDescribers(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
	out, err = DefaultObjectDescriber.DescribeObject(&appsv1.StatefulSet{
 | 
			
		||||
		ObjectMeta: metav1.ObjectMeta{Name: "foo"},
 | 
			
		||||
		Spec:       appsv1.StatefulSetSpec{Replicas: utilpointer.Int32(1)},
 | 
			
		||||
		Spec:       appsv1.StatefulSetSpec{Replicas: ptr.To[int32](1)},
 | 
			
		||||
	})
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Fatalf("unexpected error: %v", err)
 | 
			
		||||
@@ -2263,7 +2262,7 @@ func TestDescribeDeployment(t *testing.T) {
 | 
			
		||||
						CreationTimestamp: metav1.NewTime(time.Date(2021, time.Month(1), 1, 0, 0, 0, 0, time.UTC)),
 | 
			
		||||
					},
 | 
			
		||||
					Spec: appsv1.DeploymentSpec{
 | 
			
		||||
						Replicas: utilpointer.Int32Ptr(1),
 | 
			
		||||
						Replicas: ptr.To[int32](1),
 | 
			
		||||
						Selector: &metav1.LabelSelector{
 | 
			
		||||
							MatchLabels: labels,
 | 
			
		||||
						},
 | 
			
		||||
@@ -2308,13 +2307,13 @@ func TestDescribeDeployment(t *testing.T) {
 | 
			
		||||
						Labels:    labels,
 | 
			
		||||
						OwnerReferences: []metav1.OwnerReference{
 | 
			
		||||
							{
 | 
			
		||||
								Controller: utilpointer.BoolPtr(true),
 | 
			
		||||
								Controller: ptr.To(true),
 | 
			
		||||
								UID:        "00000000-0000-0000-0000-000000000001",
 | 
			
		||||
							},
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
					Spec: appsv1.ReplicaSetSpec{
 | 
			
		||||
						Replicas: utilpointer.Int32Ptr(1),
 | 
			
		||||
						Replicas: ptr.To[int32](1),
 | 
			
		||||
						Selector: &metav1.LabelSelector{
 | 
			
		||||
							MatchLabels: labels,
 | 
			
		||||
						},
 | 
			
		||||
@@ -2386,7 +2385,7 @@ func TestDescribeDeployment(t *testing.T) {
 | 
			
		||||
						CreationTimestamp: metav1.NewTime(time.Date(2021, time.Month(1), 1, 0, 0, 0, 0, time.UTC)),
 | 
			
		||||
					},
 | 
			
		||||
					Spec: appsv1.DeploymentSpec{
 | 
			
		||||
						Replicas: utilpointer.Int32Ptr(2),
 | 
			
		||||
						Replicas: ptr.To[int32](2),
 | 
			
		||||
						Selector: &metav1.LabelSelector{
 | 
			
		||||
							MatchLabels: labels,
 | 
			
		||||
						},
 | 
			
		||||
@@ -2438,13 +2437,13 @@ func TestDescribeDeployment(t *testing.T) {
 | 
			
		||||
						UID:       "00000000-0000-0000-0000-000000000001",
 | 
			
		||||
						OwnerReferences: []metav1.OwnerReference{
 | 
			
		||||
							{
 | 
			
		||||
								Controller: utilpointer.BoolPtr(true),
 | 
			
		||||
								Controller: ptr.To(true),
 | 
			
		||||
								UID:        "00000000-0000-0000-0000-000000000001",
 | 
			
		||||
							},
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
					Spec: appsv1.ReplicaSetSpec{
 | 
			
		||||
						Replicas: utilpointer.Int32Ptr(2),
 | 
			
		||||
						Replicas: ptr.To[int32](2),
 | 
			
		||||
						Selector: &metav1.LabelSelector{
 | 
			
		||||
							MatchLabels: labels,
 | 
			
		||||
						},
 | 
			
		||||
@@ -2495,13 +2494,13 @@ func TestDescribeDeployment(t *testing.T) {
 | 
			
		||||
						UID:       "00000000-0000-0000-0000-000000000002",
 | 
			
		||||
						OwnerReferences: []metav1.OwnerReference{
 | 
			
		||||
							{
 | 
			
		||||
								Controller: utilpointer.BoolPtr(true),
 | 
			
		||||
								Controller: ptr.To(true),
 | 
			
		||||
								UID:        "00000000-0000-0000-0000-000000000001",
 | 
			
		||||
							},
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
					Spec: appsv1.ReplicaSetSpec{
 | 
			
		||||
						Replicas: utilpointer.Int32Ptr(1),
 | 
			
		||||
						Replicas: ptr.To[int32](1),
 | 
			
		||||
						Selector: &metav1.LabelSelector{
 | 
			
		||||
							MatchLabels: labels,
 | 
			
		||||
						},
 | 
			
		||||
@@ -2646,7 +2645,7 @@ func TestDescribeDeployment(t *testing.T) {
 | 
			
		||||
						CreationTimestamp: metav1.NewTime(time.Date(2021, time.Month(1), 1, 0, 0, 0, 0, time.UTC)),
 | 
			
		||||
					},
 | 
			
		||||
					Spec: appsv1.DeploymentSpec{
 | 
			
		||||
						Replicas: utilpointer.Int32Ptr(2),
 | 
			
		||||
						Replicas: ptr.To[int32](2),
 | 
			
		||||
						Selector: &metav1.LabelSelector{
 | 
			
		||||
							MatchLabels: labels,
 | 
			
		||||
						},
 | 
			
		||||
@@ -2698,13 +2697,13 @@ func TestDescribeDeployment(t *testing.T) {
 | 
			
		||||
						UID:       "00000000-0000-0000-0000-000000000001",
 | 
			
		||||
						OwnerReferences: []metav1.OwnerReference{
 | 
			
		||||
							{
 | 
			
		||||
								Controller: utilpointer.BoolPtr(true),
 | 
			
		||||
								Controller: ptr.To(true),
 | 
			
		||||
								UID:        "00000000-0000-0000-0000-000000000001",
 | 
			
		||||
							},
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
					Spec: appsv1.ReplicaSetSpec{
 | 
			
		||||
						Replicas: utilpointer.Int32Ptr(0),
 | 
			
		||||
						Replicas: ptr.To[int32](0),
 | 
			
		||||
						Selector: &metav1.LabelSelector{
 | 
			
		||||
							MatchLabels: labels,
 | 
			
		||||
						},
 | 
			
		||||
@@ -2755,13 +2754,13 @@ func TestDescribeDeployment(t *testing.T) {
 | 
			
		||||
						UID:       "00000000-0000-0000-0000-000000000002",
 | 
			
		||||
						OwnerReferences: []metav1.OwnerReference{
 | 
			
		||||
							{
 | 
			
		||||
								Controller: utilpointer.BoolPtr(true),
 | 
			
		||||
								Controller: ptr.To(true),
 | 
			
		||||
								UID:        "00000000-0000-0000-0000-000000000001",
 | 
			
		||||
							},
 | 
			
		||||
						},
 | 
			
		||||
					},
 | 
			
		||||
					Spec: appsv1.ReplicaSetSpec{
 | 
			
		||||
						Replicas: utilpointer.Int32Ptr(2),
 | 
			
		||||
						Replicas: ptr.To[int32](2),
 | 
			
		||||
						Selector: &metav1.LabelSelector{
 | 
			
		||||
							MatchLabels: labels,
 | 
			
		||||
						},
 | 
			
		||||
@@ -3017,8 +3016,8 @@ func TestDescribeJob(t *testing.T) {
 | 
			
		||||
				},
 | 
			
		||||
				Spec: batchv1.JobSpec{
 | 
			
		||||
					Suspend:                 ptr.To(true),
 | 
			
		||||
					TTLSecondsAfterFinished: ptr.To(int32(123)),
 | 
			
		||||
					BackoffLimit:            ptr.To(int32(1)),
 | 
			
		||||
					TTLSecondsAfterFinished: ptr.To[int32](123),
 | 
			
		||||
					BackoffLimit:            ptr.To[int32](1),
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			wantElements: []string{
 | 
			
		||||
@@ -3138,7 +3137,7 @@ func TestDescribeIngress(t *testing.T) {
 | 
			
		||||
 | 
			
		||||
	backendResource := networkingv1.IngressBackend{
 | 
			
		||||
		Resource: &corev1.TypedLocalObjectReference{
 | 
			
		||||
			APIGroup: utilpointer.StringPtr("example.com"),
 | 
			
		||||
			APIGroup: ptr.To("example.com"),
 | 
			
		||||
			Kind:     "foo",
 | 
			
		||||
			Name:     "bar",
 | 
			
		||||
		},
 | 
			
		||||
@@ -3632,7 +3631,7 @@ Events:       <none>
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestDescribeCSINode(t *testing.T) {
 | 
			
		||||
	limit := utilpointer.Int32Ptr(int32(2))
 | 
			
		||||
	limit := ptr.To[int32](2)
 | 
			
		||||
	f := fake.NewSimpleClientset(&storagev1.CSINode{
 | 
			
		||||
		ObjectMeta: metav1.ObjectMeta{Name: "foo"},
 | 
			
		||||
		Spec: storagev1.CSINodeSpec{
 | 
			
		||||
@@ -4538,7 +4537,7 @@ func TestDescribeHorizontalPodAutoscaler(t *testing.T) {
 | 
			
		||||
					},
 | 
			
		||||
					Behavior: &autoscalingv2.HorizontalPodAutoscalerBehavior{
 | 
			
		||||
						ScaleUp: &autoscalingv2.HPAScalingRules{
 | 
			
		||||
							StabilizationWindowSeconds: utilpointer.Int32Ptr(30),
 | 
			
		||||
							StabilizationWindowSeconds: ptr.To[int32](30),
 | 
			
		||||
							SelectPolicy:               &maxSelectPolicy,
 | 
			
		||||
							Policies: []autoscalingv2.HPAScalingPolicy{
 | 
			
		||||
								{Type: autoscalingv2.PodsScalingPolicy, Value: 10, PeriodSeconds: 10},
 | 
			
		||||
@@ -4573,7 +4572,7 @@ func TestDescribeHorizontalPodAutoscaler(t *testing.T) {
 | 
			
		||||
					},
 | 
			
		||||
					Behavior: &autoscalingv2.HorizontalPodAutoscalerBehavior{
 | 
			
		||||
						ScaleDown: &autoscalingv2.HPAScalingRules{
 | 
			
		||||
							StabilizationWindowSeconds: utilpointer.Int32Ptr(30),
 | 
			
		||||
							StabilizationWindowSeconds: ptr.To[int32](30),
 | 
			
		||||
							Policies: []autoscalingv2.HPAScalingPolicy{
 | 
			
		||||
								{Type: autoscalingv2.PodsScalingPolicy, Value: 10, PeriodSeconds: 10},
 | 
			
		||||
								{Type: autoscalingv2.PercentScalingPolicy, Value: 10, PeriodSeconds: 10},
 | 
			
		||||
@@ -4749,7 +4748,7 @@ func TestDescribeEvents(t *testing.T) {
 | 
			
		||||
					Namespace: "foo",
 | 
			
		||||
				},
 | 
			
		||||
				Spec: appsv1.DeploymentSpec{
 | 
			
		||||
					Replicas: utilpointer.Int32Ptr(1),
 | 
			
		||||
					Replicas: ptr.To[int32](1),
 | 
			
		||||
					Selector: &metav1.LabelSelector{},
 | 
			
		||||
				},
 | 
			
		||||
			}, events),
 | 
			
		||||
@@ -4815,7 +4814,7 @@ func TestDescribeEvents(t *testing.T) {
 | 
			
		||||
					Namespace: "foo",
 | 
			
		||||
				},
 | 
			
		||||
				Spec: appsv1.ReplicaSetSpec{
 | 
			
		||||
					Replicas: utilpointer.Int32Ptr(1),
 | 
			
		||||
					Replicas: ptr.To[int32](1),
 | 
			
		||||
				},
 | 
			
		||||
			}, events),
 | 
			
		||||
		},
 | 
			
		||||
@@ -4826,7 +4825,7 @@ func TestDescribeEvents(t *testing.T) {
 | 
			
		||||
					Namespace: "foo",
 | 
			
		||||
				},
 | 
			
		||||
				Spec: corev1.ReplicationControllerSpec{
 | 
			
		||||
					Replicas: utilpointer.Int32Ptr(1),
 | 
			
		||||
					Replicas: ptr.To[int32](1),
 | 
			
		||||
				},
 | 
			
		||||
			}, events),
 | 
			
		||||
		},
 | 
			
		||||
@@ -5088,7 +5087,7 @@ Parameters:
 | 
			
		||||
				Spec: networkingv1beta1.IngressClassSpec{
 | 
			
		||||
					Controller: "example.com/controller",
 | 
			
		||||
					Parameters: &networkingv1beta1.IngressClassParametersReference{
 | 
			
		||||
						APIGroup: utilpointer.StringPtr("v1"),
 | 
			
		||||
						APIGroup: ptr.To("v1"),
 | 
			
		||||
						Kind:     "ConfigMap",
 | 
			
		||||
						Name:     "example-parameters",
 | 
			
		||||
					},
 | 
			
		||||
@@ -5104,7 +5103,7 @@ Parameters:
 | 
			
		||||
				Spec: networkingv1.IngressClassSpec{
 | 
			
		||||
					Controller: "example.com/controller",
 | 
			
		||||
					Parameters: &networkingv1.IngressClassParametersReference{
 | 
			
		||||
						APIGroup: utilpointer.StringPtr("v1"),
 | 
			
		||||
						APIGroup: ptr.To("v1"),
 | 
			
		||||
						Kind:     "ConfigMap",
 | 
			
		||||
						Name:     "example-parameters",
 | 
			
		||||
					},
 | 
			
		||||
@@ -6186,7 +6185,7 @@ func TestDescribeEndpointSlice(t *testing.T) {
 | 
			
		||||
				Endpoints: []discoveryv1beta1.Endpoint{
 | 
			
		||||
					{
 | 
			
		||||
						Addresses:  []string{"1.2.3.4", "1.2.3.5"},
 | 
			
		||||
						Conditions: discoveryv1beta1.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
 | 
			
		||||
						Conditions: discoveryv1beta1.EndpointConditions{Ready: ptr.To(true)},
 | 
			
		||||
						TargetRef:  &corev1.ObjectReference{Kind: "Pod", Name: "test-123"},
 | 
			
		||||
						Topology: map[string]string{
 | 
			
		||||
							"topology.kubernetes.io/zone":   "us-central1-a",
 | 
			
		||||
@@ -6194,7 +6193,7 @@ func TestDescribeEndpointSlice(t *testing.T) {
 | 
			
		||||
						},
 | 
			
		||||
					}, {
 | 
			
		||||
						Addresses:  []string{"1.2.3.6", "1.2.3.7"},
 | 
			
		||||
						Conditions: discoveryv1beta1.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
 | 
			
		||||
						Conditions: discoveryv1beta1.EndpointConditions{Ready: ptr.To(true)},
 | 
			
		||||
						TargetRef:  &corev1.ObjectReference{Kind: "Pod", Name: "test-124"},
 | 
			
		||||
						Topology: map[string]string{
 | 
			
		||||
							"topology.kubernetes.io/zone":   "us-central1-b",
 | 
			
		||||
@@ -6246,15 +6245,15 @@ Events:         <none>` + "\n",
 | 
			
		||||
				Endpoints: []discoveryv1.Endpoint{
 | 
			
		||||
					{
 | 
			
		||||
						Addresses:  []string{"1.2.3.4", "1.2.3.5"},
 | 
			
		||||
						Conditions: discoveryv1.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
 | 
			
		||||
						Conditions: discoveryv1.EndpointConditions{Ready: ptr.To(true)},
 | 
			
		||||
						TargetRef:  &corev1.ObjectReference{Kind: "Pod", Name: "test-123"},
 | 
			
		||||
						Zone:       utilpointer.StringPtr("us-central1-a"),
 | 
			
		||||
						NodeName:   utilpointer.StringPtr("node-1"),
 | 
			
		||||
						Zone:       ptr.To("us-central1-a"),
 | 
			
		||||
						NodeName:   ptr.To("node-1"),
 | 
			
		||||
					}, {
 | 
			
		||||
						Addresses:  []string{"1.2.3.6", "1.2.3.7"},
 | 
			
		||||
						Conditions: discoveryv1.EndpointConditions{Ready: utilpointer.BoolPtr(true)},
 | 
			
		||||
						Conditions: discoveryv1.EndpointConditions{Ready: ptr.To(true)},
 | 
			
		||||
						TargetRef:  &corev1.ObjectReference{Kind: "Pod", Name: "test-124"},
 | 
			
		||||
						NodeName:   utilpointer.StringPtr("node-2"),
 | 
			
		||||
						NodeName:   ptr.To("node-2"),
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
				Ports: []discoveryv1.EndpointPort{
 | 
			
		||||
@@ -6457,7 +6456,7 @@ func TestControllerRef(t *testing.T) {
 | 
			
		||||
				Name:            "barpod",
 | 
			
		||||
				Namespace:       "foo",
 | 
			
		||||
				Labels:          map[string]string{"abc": "xyz"},
 | 
			
		||||
				OwnerReferences: []metav1.OwnerReference{{Name: "bar", UID: "123456", Controller: utilpointer.BoolPtr(true)}},
 | 
			
		||||
				OwnerReferences: []metav1.OwnerReference{{Name: "bar", UID: "123456", Controller: ptr.To(true)}},
 | 
			
		||||
			},
 | 
			
		||||
			TypeMeta: metav1.TypeMeta{
 | 
			
		||||
				Kind: "Pod",
 | 
			
		||||
@@ -6494,7 +6493,7 @@ func TestControllerRef(t *testing.T) {
 | 
			
		||||
				Name:            "buzpod",
 | 
			
		||||
				Namespace:       "foo",
 | 
			
		||||
				Labels:          map[string]string{"abc": "xyz"},
 | 
			
		||||
				OwnerReferences: []metav1.OwnerReference{{Name: "buz", UID: "654321", Controller: utilpointer.BoolPtr(true)}},
 | 
			
		||||
				OwnerReferences: []metav1.OwnerReference{{Name: "buz", UID: "654321", Controller: ptr.To(true)}},
 | 
			
		||||
			},
 | 
			
		||||
			TypeMeta: metav1.TypeMeta{
 | 
			
		||||
				Kind: "Pod",
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user