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