mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	This commit does two things in pkg package:
1. Remove unused ptr functions. 2. Replace ptr functions with k8s.io/utils/pointer
This commit is contained in:
		@@ -23,6 +23,7 @@ go_test(
 | 
				
			|||||||
        "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
 | 
					        "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
 | 
				
			||||||
        "//staging/src/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
 | 
					        "//staging/src/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
 | 
				
			||||||
        "//vendor/github.com/stretchr/testify/require:go_default_library",
 | 
					        "//vendor/github.com/stretchr/testify/require:go_default_library",
 | 
				
			||||||
 | 
					        "//vendor/k8s.io/utils/pointer:go_default_library",
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,6 +24,7 @@ import (
 | 
				
			|||||||
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
						metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/util/validation/field"
 | 
						"k8s.io/apimachinery/pkg/util/validation/field"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/apis/auditregistration"
 | 
						"k8s.io/kubernetes/pkg/apis/auditregistration"
 | 
				
			||||||
 | 
						utilpointer "k8s.io/utils/pointer"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestValidateAuditSink(t *testing.T) {
 | 
					func TestValidateAuditSink(t *testing.T) {
 | 
				
			||||||
@@ -133,8 +134,6 @@ func TestValidatePolicy(t *testing.T) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func strPtr(s string) *string { return &s }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func TestValidateWebhookConfiguration(t *testing.T) {
 | 
					func TestValidateWebhookConfiguration(t *testing.T) {
 | 
				
			||||||
	tests := []struct {
 | 
						tests := []struct {
 | 
				
			||||||
		name          string
 | 
							name          string
 | 
				
			||||||
@@ -157,7 +156,7 @@ func TestValidateWebhookConfiguration(t *testing.T) {
 | 
				
			|||||||
						Name:      "n",
 | 
											Name:      "n",
 | 
				
			||||||
						Port:      443,
 | 
											Port:      443,
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
					URL: strPtr("example.com/k8s/webhook"),
 | 
										URL: utilpointer.StringPtr("example.com/k8s/webhook"),
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expectedError: `webhook.clientConfig: Required value: exactly one of url or service is required`,
 | 
								expectedError: `webhook.clientConfig: Required value: exactly one of url or service is required`,
 | 
				
			||||||
@@ -166,7 +165,7 @@ func TestValidateWebhookConfiguration(t *testing.T) {
 | 
				
			|||||||
			name: "blank URL",
 | 
								name: "blank URL",
 | 
				
			||||||
			config: auditregistration.Webhook{
 | 
								config: auditregistration.Webhook{
 | 
				
			||||||
				ClientConfig: auditregistration.WebhookClientConfig{
 | 
									ClientConfig: auditregistration.WebhookClientConfig{
 | 
				
			||||||
					URL: strPtr(""),
 | 
										URL: utilpointer.StringPtr(""),
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expectedError: `webhook.clientConfig.url: Invalid value: "": host must be provided`,
 | 
								expectedError: `webhook.clientConfig.url: Invalid value: "": host must be provided`,
 | 
				
			||||||
@@ -175,7 +174,7 @@ func TestValidateWebhookConfiguration(t *testing.T) {
 | 
				
			|||||||
			name: "missing host",
 | 
								name: "missing host",
 | 
				
			||||||
			config: auditregistration.Webhook{
 | 
								config: auditregistration.Webhook{
 | 
				
			||||||
				ClientConfig: auditregistration.WebhookClientConfig{
 | 
									ClientConfig: auditregistration.WebhookClientConfig{
 | 
				
			||||||
					URL: strPtr("https:///fancy/webhook"),
 | 
										URL: utilpointer.StringPtr("https:///fancy/webhook"),
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expectedError: `host must be provided`,
 | 
								expectedError: `host must be provided`,
 | 
				
			||||||
@@ -184,7 +183,7 @@ func TestValidateWebhookConfiguration(t *testing.T) {
 | 
				
			|||||||
			name: "fragment",
 | 
								name: "fragment",
 | 
				
			||||||
			config: auditregistration.Webhook{
 | 
								config: auditregistration.Webhook{
 | 
				
			||||||
				ClientConfig: auditregistration.WebhookClientConfig{
 | 
									ClientConfig: auditregistration.WebhookClientConfig{
 | 
				
			||||||
					URL: strPtr("https://example.com/#bookmark"),
 | 
										URL: utilpointer.StringPtr("https://example.com/#bookmark"),
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expectedError: `"bookmark": fragments are not permitted`,
 | 
								expectedError: `"bookmark": fragments are not permitted`,
 | 
				
			||||||
@@ -193,7 +192,7 @@ func TestValidateWebhookConfiguration(t *testing.T) {
 | 
				
			|||||||
			name: "query",
 | 
								name: "query",
 | 
				
			||||||
			config: auditregistration.Webhook{
 | 
								config: auditregistration.Webhook{
 | 
				
			||||||
				ClientConfig: auditregistration.WebhookClientConfig{
 | 
									ClientConfig: auditregistration.WebhookClientConfig{
 | 
				
			||||||
					URL: strPtr("https://example.com?arg=value"),
 | 
										URL: utilpointer.StringPtr("https://example.com?arg=value"),
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expectedError: `"arg=value": query parameters are not permitted`,
 | 
								expectedError: `"arg=value": query parameters are not permitted`,
 | 
				
			||||||
@@ -202,7 +201,7 @@ func TestValidateWebhookConfiguration(t *testing.T) {
 | 
				
			|||||||
			name: "user",
 | 
								name: "user",
 | 
				
			||||||
			config: auditregistration.Webhook{
 | 
								config: auditregistration.Webhook{
 | 
				
			||||||
				ClientConfig: auditregistration.WebhookClientConfig{
 | 
									ClientConfig: auditregistration.WebhookClientConfig{
 | 
				
			||||||
					URL: strPtr("https://harry.potter@example.com/"),
 | 
										URL: utilpointer.StringPtr("https://harry.potter@example.com/"),
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expectedError: `"harry.potter": user information is not permitted`,
 | 
								expectedError: `"harry.potter": user information is not permitted`,
 | 
				
			||||||
@@ -211,7 +210,7 @@ func TestValidateWebhookConfiguration(t *testing.T) {
 | 
				
			|||||||
			name: "just totally wrong",
 | 
								name: "just totally wrong",
 | 
				
			||||||
			config: auditregistration.Webhook{
 | 
								config: auditregistration.Webhook{
 | 
				
			||||||
				ClientConfig: auditregistration.WebhookClientConfig{
 | 
									ClientConfig: auditregistration.WebhookClientConfig{
 | 
				
			||||||
					URL: strPtr("arg#backwards=thisis?html.index/port:host//:https"),
 | 
										URL: utilpointer.StringPtr("arg#backwards=thisis?html.index/port:host//:https"),
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			expectedError: `host must be provided`,
 | 
								expectedError: `host must be provided`,
 | 
				
			||||||
@@ -223,7 +222,7 @@ func TestValidateWebhookConfiguration(t *testing.T) {
 | 
				
			|||||||
					Service: &auditregistration.ServiceReference{
 | 
										Service: &auditregistration.ServiceReference{
 | 
				
			||||||
						Namespace: "ns",
 | 
											Namespace: "ns",
 | 
				
			||||||
						Name:      "n",
 | 
											Name:      "n",
 | 
				
			||||||
						Path:      strPtr("foo/"),
 | 
											Path:      utilpointer.StringPtr("foo/"),
 | 
				
			||||||
						Port:      443,
 | 
											Port:      443,
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
@@ -237,7 +236,7 @@ func TestValidateWebhookConfiguration(t *testing.T) {
 | 
				
			|||||||
					Service: &auditregistration.ServiceReference{
 | 
										Service: &auditregistration.ServiceReference{
 | 
				
			||||||
						Namespace: "ns",
 | 
											Namespace: "ns",
 | 
				
			||||||
						Name:      "n",
 | 
											Name:      "n",
 | 
				
			||||||
						Path:      strPtr("foo/"),
 | 
											Path:      utilpointer.StringPtr("foo/"),
 | 
				
			||||||
						Port:      65536,
 | 
											Port:      65536,
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
@@ -251,7 +250,7 @@ func TestValidateWebhookConfiguration(t *testing.T) {
 | 
				
			|||||||
					Service: &auditregistration.ServiceReference{
 | 
										Service: &auditregistration.ServiceReference{
 | 
				
			||||||
						Namespace: "ns",
 | 
											Namespace: "ns",
 | 
				
			||||||
						Name:      "n",
 | 
											Name:      "n",
 | 
				
			||||||
						Path:      strPtr("foo/"),
 | 
											Path:      utilpointer.StringPtr("foo/"),
 | 
				
			||||||
						Port:      0,
 | 
											Port:      0,
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
@@ -265,7 +264,7 @@ func TestValidateWebhookConfiguration(t *testing.T) {
 | 
				
			|||||||
					Service: &auditregistration.ServiceReference{
 | 
										Service: &auditregistration.ServiceReference{
 | 
				
			||||||
						Namespace: "ns",
 | 
											Namespace: "ns",
 | 
				
			||||||
						Name:      "n",
 | 
											Name:      "n",
 | 
				
			||||||
						Path:      strPtr("/"),
 | 
											Path:      utilpointer.StringPtr("/"),
 | 
				
			||||||
						Port:      443,
 | 
											Port:      443,
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
@@ -279,7 +278,7 @@ func TestValidateWebhookConfiguration(t *testing.T) {
 | 
				
			|||||||
					Service: &auditregistration.ServiceReference{
 | 
										Service: &auditregistration.ServiceReference{
 | 
				
			||||||
						Namespace: "ns",
 | 
											Namespace: "ns",
 | 
				
			||||||
						Name:      "n",
 | 
											Name:      "n",
 | 
				
			||||||
						Path:      strPtr("/foo"),
 | 
											Path:      utilpointer.StringPtr("/foo"),
 | 
				
			||||||
						Port:      443,
 | 
											Port:      443,
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
@@ -293,7 +292,7 @@ func TestValidateWebhookConfiguration(t *testing.T) {
 | 
				
			|||||||
					Service: &auditregistration.ServiceReference{
 | 
										Service: &auditregistration.ServiceReference{
 | 
				
			||||||
						Namespace: "ns",
 | 
											Namespace: "ns",
 | 
				
			||||||
						Name:      "n",
 | 
											Name:      "n",
 | 
				
			||||||
						Path:      strPtr("//"),
 | 
											Path:      utilpointer.StringPtr("//"),
 | 
				
			||||||
						Port:      443,
 | 
											Port:      443,
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
@@ -307,7 +306,7 @@ func TestValidateWebhookConfiguration(t *testing.T) {
 | 
				
			|||||||
					Service: &auditregistration.ServiceReference{
 | 
										Service: &auditregistration.ServiceReference{
 | 
				
			||||||
						Namespace: "ns",
 | 
											Namespace: "ns",
 | 
				
			||||||
						Name:      "n",
 | 
											Name:      "n",
 | 
				
			||||||
						Path:      strPtr("/foo//bar/"),
 | 
											Path:      utilpointer.StringPtr("/foo//bar/"),
 | 
				
			||||||
						Port:      443,
 | 
											Port:      443,
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
@@ -320,7 +319,7 @@ func TestValidateWebhookConfiguration(t *testing.T) {
 | 
				
			|||||||
					Service: &auditregistration.ServiceReference{
 | 
										Service: &auditregistration.ServiceReference{
 | 
				
			||||||
						Namespace: "ns",
 | 
											Namespace: "ns",
 | 
				
			||||||
						Name:      "n",
 | 
											Name:      "n",
 | 
				
			||||||
						Path:      strPtr("/foo/bar//"),
 | 
											Path:      utilpointer.StringPtr("/foo/bar//"),
 | 
				
			||||||
						Port:      443,
 | 
											Port:      443,
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
@@ -334,7 +333,7 @@ func TestValidateWebhookConfiguration(t *testing.T) {
 | 
				
			|||||||
					Service: &auditregistration.ServiceReference{
 | 
										Service: &auditregistration.ServiceReference{
 | 
				
			||||||
						Namespace: "ns",
 | 
											Namespace: "ns",
 | 
				
			||||||
						Name:      "n",
 | 
											Name:      "n",
 | 
				
			||||||
						Path:      strPtr("/apis/foo.bar/v1alpha1/--bad"),
 | 
											Path:      utilpointer.StringPtr("/apis/foo.bar/v1alpha1/--bad"),
 | 
				
			||||||
						Port:      443,
 | 
											Port:      443,
 | 
				
			||||||
					},
 | 
										},
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12560,7 +12560,7 @@ func TestValidateSecurityContext(t *testing.T) {
 | 
				
			|||||||
	runAsUser := int64(1)
 | 
						runAsUser := int64(1)
 | 
				
			||||||
	fullValidSC := func() *core.SecurityContext {
 | 
						fullValidSC := func() *core.SecurityContext {
 | 
				
			||||||
		return &core.SecurityContext{
 | 
							return &core.SecurityContext{
 | 
				
			||||||
			Privileged: boolPtr(false),
 | 
								Privileged: utilpointer.BoolPtr(false),
 | 
				
			||||||
			Capabilities: &core.Capabilities{
 | 
								Capabilities: &core.Capabilities{
 | 
				
			||||||
				Add:  []core.Capability{"foo"},
 | 
									Add:  []core.Capability{"foo"},
 | 
				
			||||||
				Drop: []core.Capability{"bar"},
 | 
									Drop: []core.Capability{"bar"},
 | 
				
			||||||
@@ -12605,19 +12605,19 @@ func TestValidateSecurityContext(t *testing.T) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	privRequestWithGlobalDeny := fullValidSC()
 | 
						privRequestWithGlobalDeny := fullValidSC()
 | 
				
			||||||
	privRequestWithGlobalDeny.Privileged = boolPtr(true)
 | 
						privRequestWithGlobalDeny.Privileged = utilpointer.BoolPtr(true)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	negativeRunAsUser := fullValidSC()
 | 
						negativeRunAsUser := fullValidSC()
 | 
				
			||||||
	negativeUser := int64(-1)
 | 
						negativeUser := int64(-1)
 | 
				
			||||||
	negativeRunAsUser.RunAsUser = &negativeUser
 | 
						negativeRunAsUser.RunAsUser = &negativeUser
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	privWithoutEscalation := fullValidSC()
 | 
						privWithoutEscalation := fullValidSC()
 | 
				
			||||||
	privWithoutEscalation.Privileged = boolPtr(true)
 | 
						privWithoutEscalation.Privileged = utilpointer.BoolPtr(true)
 | 
				
			||||||
	privWithoutEscalation.AllowPrivilegeEscalation = boolPtr(false)
 | 
						privWithoutEscalation.AllowPrivilegeEscalation = utilpointer.BoolPtr(false)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	capSysAdminWithoutEscalation := fullValidSC()
 | 
						capSysAdminWithoutEscalation := fullValidSC()
 | 
				
			||||||
	capSysAdminWithoutEscalation.Capabilities.Add = []core.Capability{"CAP_SYS_ADMIN"}
 | 
						capSysAdminWithoutEscalation.Capabilities.Add = []core.Capability{"CAP_SYS_ADMIN"}
 | 
				
			||||||
	capSysAdminWithoutEscalation.AllowPrivilegeEscalation = boolPtr(false)
 | 
						capSysAdminWithoutEscalation.AllowPrivilegeEscalation = utilpointer.BoolPtr(false)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	errorCases := map[string]struct {
 | 
						errorCases := map[string]struct {
 | 
				
			||||||
		sc           *core.SecurityContext
 | 
							sc           *core.SecurityContext
 | 
				
			||||||
@@ -13145,7 +13145,3 @@ func TestValidateOrSetClientIPAffinityConfig(t *testing.T) {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
func boolPtr(b bool) *bool {
 | 
					 | 
				
			||||||
	return &b
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -55,6 +55,7 @@ go_test(
 | 
				
			|||||||
        "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
 | 
					        "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
 | 
				
			||||||
        "//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
 | 
					        "//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
 | 
				
			||||||
        "//staging/src/k8s.io/client-go/tools/record:go_default_library",
 | 
					        "//staging/src/k8s.io/client-go/tools/record:go_default_library",
 | 
				
			||||||
 | 
					        "//vendor/k8s.io/utils/pointer:go_default_library",
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,10 +28,9 @@ import (
 | 
				
			|||||||
	"k8s.io/api/core/v1"
 | 
						"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/types"
 | 
						"k8s.io/apimachinery/pkg/types"
 | 
				
			||||||
 | 
						utilpointer "k8s.io/utils/pointer"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func boolptr(b bool) *bool { return &b }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func TestGetJobFromTemplate(t *testing.T) {
 | 
					func TestGetJobFromTemplate(t *testing.T) {
 | 
				
			||||||
	// getJobFromTemplate() needs to take the job template and copy the labels and annotations
 | 
						// getJobFromTemplate() needs to take the job template and copy the labels and annotations
 | 
				
			||||||
	// and other fields, and add a created-by reference.
 | 
						// and other fields, and add a created-by reference.
 | 
				
			||||||
@@ -134,7 +133,7 @@ func TestGetParentUIDFromJob(t *testing.T) {
 | 
				
			|||||||
			{
 | 
								{
 | 
				
			||||||
				Kind:       "CronJob",
 | 
									Kind:       "CronJob",
 | 
				
			||||||
				UID:        types.UID("5ef034e0-1890-11e6-8935-42010af0003e"),
 | 
									UID:        types.UID("5ef034e0-1890-11e6-8935-42010af0003e"),
 | 
				
			||||||
				Controller: boolptr(true),
 | 
									Controller: utilpointer.BoolPtr(true),
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		})
 | 
							})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -158,19 +157,19 @@ func TestGroupJobsByParent(t *testing.T) {
 | 
				
			|||||||
	ownerReference1 := metav1.OwnerReference{
 | 
						ownerReference1 := metav1.OwnerReference{
 | 
				
			||||||
		Kind:       "CronJob",
 | 
							Kind:       "CronJob",
 | 
				
			||||||
		UID:        uid1,
 | 
							UID:        uid1,
 | 
				
			||||||
		Controller: boolptr(true),
 | 
							Controller: utilpointer.BoolPtr(true),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ownerReference2 := metav1.OwnerReference{
 | 
						ownerReference2 := metav1.OwnerReference{
 | 
				
			||||||
		Kind:       "CronJob",
 | 
							Kind:       "CronJob",
 | 
				
			||||||
		UID:        uid2,
 | 
							UID:        uid2,
 | 
				
			||||||
		Controller: boolptr(true),
 | 
							Controller: utilpointer.BoolPtr(true),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ownerReference3 := metav1.OwnerReference{
 | 
						ownerReference3 := metav1.OwnerReference{
 | 
				
			||||||
		Kind:       "CronJob",
 | 
							Kind:       "CronJob",
 | 
				
			||||||
		UID:        uid3,
 | 
							UID:        uid3,
 | 
				
			||||||
		Controller: boolptr(true),
 | 
							Controller: utilpointer.BoolPtr(true),
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -46,5 +46,6 @@ go_test(
 | 
				
			|||||||
        "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
 | 
					        "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
 | 
				
			||||||
        "//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
 | 
					        "//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
 | 
				
			||||||
        "//staging/src/k8s.io/apiserver/pkg/util/feature/testing:go_default_library",
 | 
					        "//staging/src/k8s.io/apiserver/pkg/util/feature/testing:go_default_library",
 | 
				
			||||||
 | 
					        "//vendor/k8s.io/utils/pointer:go_default_library",
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,6 +28,7 @@ import (
 | 
				
			|||||||
	utilfeaturetesting "k8s.io/apiserver/pkg/util/feature/testing"
 | 
						utilfeaturetesting "k8s.io/apiserver/pkg/util/feature/testing"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/features"
 | 
						"k8s.io/kubernetes/pkg/features"
 | 
				
			||||||
	schedulerapi "k8s.io/kubernetes/pkg/scheduler/api"
 | 
						schedulerapi "k8s.io/kubernetes/pkg/scheduler/api"
 | 
				
			||||||
 | 
						utilpointer "k8s.io/utils/pointer"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func newPod(podName string, nodeName string, label map[string]string) *v1.Pod {
 | 
					func newPod(podName string, nodeName string, label map[string]string) *v1.Pod {
 | 
				
			||||||
@@ -51,8 +52,8 @@ func newPod(podName string, nodeName string, label map[string]string) *v1.Pod {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func TestIsPodUpdated(t *testing.T) {
 | 
					func TestIsPodUpdated(t *testing.T) {
 | 
				
			||||||
	templateGeneration := int64Ptr(12345)
 | 
						templateGeneration := utilpointer.Int64Ptr(12345)
 | 
				
			||||||
	badGeneration := int64Ptr(12345)
 | 
						badGeneration := utilpointer.Int64Ptr(12345)
 | 
				
			||||||
	hash := "55555"
 | 
						hash := "55555"
 | 
				
			||||||
	labels := map[string]string{extensions.DaemonSetTemplateGenerationKey: fmt.Sprint(templateGeneration), extensions.DefaultDaemonSetUniqueLabelKey: hash}
 | 
						labels := map[string]string{extensions.DaemonSetTemplateGenerationKey: fmt.Sprint(templateGeneration), extensions.DefaultDaemonSetUniqueLabelKey: hash}
 | 
				
			||||||
	labelsNoHash := map[string]string{extensions.DaemonSetTemplateGenerationKey: fmt.Sprint(templateGeneration)}
 | 
						labelsNoHash := map[string]string{extensions.DaemonSetTemplateGenerationKey: fmt.Sprint(templateGeneration)}
 | 
				
			||||||
@@ -148,8 +149,8 @@ func TestCreatePodTemplate(t *testing.T) {
 | 
				
			|||||||
		hash               string
 | 
							hash               string
 | 
				
			||||||
		expectUniqueLabel  bool
 | 
							expectUniqueLabel  bool
 | 
				
			||||||
	}{
 | 
						}{
 | 
				
			||||||
		{int64Ptr(1), "", false},
 | 
							{utilpointer.Int64Ptr(1), "", false},
 | 
				
			||||||
		{int64Ptr(2), "3242341807", true},
 | 
							{utilpointer.Int64Ptr(2), "3242341807", true},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for _, test := range tests {
 | 
						for _, test := range tests {
 | 
				
			||||||
		podTemplateSpec := v1.PodTemplateSpec{}
 | 
							podTemplateSpec := v1.PodTemplateSpec{}
 | 
				
			||||||
@@ -168,11 +169,6 @@ func TestCreatePodTemplate(t *testing.T) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func int64Ptr(i int) *int64 {
 | 
					 | 
				
			||||||
	li := int64(i)
 | 
					 | 
				
			||||||
	return &li
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func TestReplaceDaemonSetPodNodeNameNodeAffinity(t *testing.T) {
 | 
					func TestReplaceDaemonSetPodNodeNameNodeAffinity(t *testing.T) {
 | 
				
			||||||
	tests := []struct {
 | 
						tests := []struct {
 | 
				
			||||||
		affinity *v1.Affinity
 | 
							affinity *v1.Affinity
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -36,6 +36,7 @@ go_test(
 | 
				
			|||||||
        "//staging/src/k8s.io/api/batch/v1:go_default_library",
 | 
					        "//staging/src/k8s.io/api/batch/v1:go_default_library",
 | 
				
			||||||
        "//staging/src/k8s.io/api/core/v1:go_default_library",
 | 
					        "//staging/src/k8s.io/api/core/v1:go_default_library",
 | 
				
			||||||
        "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
 | 
					        "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
 | 
				
			||||||
 | 
					        "//vendor/k8s.io/utils/pointer:go_default_library",
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,6 +24,7 @@ import (
 | 
				
			|||||||
	batch "k8s.io/api/batch/v1"
 | 
						batch "k8s.io/api/batch/v1"
 | 
				
			||||||
	"k8s.io/api/core/v1"
 | 
						"k8s.io/api/core/v1"
 | 
				
			||||||
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
						metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
				
			||||||
 | 
						utilpointer "k8s.io/utils/pointer"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func newJob(completionTime, failedTime metav1.Time, ttl *int32) *batch.Job {
 | 
					func newJob(completionTime, failedTime metav1.Time, ttl *int32) *batch.Job {
 | 
				
			||||||
@@ -74,10 +75,6 @@ func durationPointer(n int) *time.Duration {
 | 
				
			|||||||
	return &s
 | 
						return &s
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func int32Ptr(n int32) *int32 {
 | 
					 | 
				
			||||||
	return &n
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func TestTimeLeft(t *testing.T) {
 | 
					func TestTimeLeft(t *testing.T) {
 | 
				
			||||||
	now := metav1.Now()
 | 
						now := metav1.Now()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -93,7 +90,7 @@ func TestTimeLeft(t *testing.T) {
 | 
				
			|||||||
	}{
 | 
						}{
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name:         "Error case: Job unfinished",
 | 
								name:         "Error case: Job unfinished",
 | 
				
			||||||
			ttl:          int32Ptr(100),
 | 
								ttl:          utilpointer.Int32Ptr(100),
 | 
				
			||||||
			since:        &now.Time,
 | 
								since:        &now.Time,
 | 
				
			||||||
			expectErr:    true,
 | 
								expectErr:    true,
 | 
				
			||||||
			expectErrStr: "should not be cleaned up",
 | 
								expectErrStr: "should not be cleaned up",
 | 
				
			||||||
@@ -108,21 +105,21 @@ func TestTimeLeft(t *testing.T) {
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
			name:             "Job completed now, 0s TTL",
 | 
								name:             "Job completed now, 0s TTL",
 | 
				
			||||||
			completionTime:   now,
 | 
								completionTime:   now,
 | 
				
			||||||
			ttl:              int32Ptr(0),
 | 
								ttl:              utilpointer.Int32Ptr(0),
 | 
				
			||||||
			since:            &now.Time,
 | 
								since:            &now.Time,
 | 
				
			||||||
			expectedTimeLeft: durationPointer(0),
 | 
								expectedTimeLeft: durationPointer(0),
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name:             "Job completed now, 10s TTL",
 | 
								name:             "Job completed now, 10s TTL",
 | 
				
			||||||
			completionTime:   now,
 | 
								completionTime:   now,
 | 
				
			||||||
			ttl:              int32Ptr(10),
 | 
								ttl:              utilpointer.Int32Ptr(10),
 | 
				
			||||||
			since:            &now.Time,
 | 
								since:            &now.Time,
 | 
				
			||||||
			expectedTimeLeft: durationPointer(10),
 | 
								expectedTimeLeft: durationPointer(10),
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name:             "Job completed 10s ago, 15s TTL",
 | 
								name:             "Job completed 10s ago, 15s TTL",
 | 
				
			||||||
			completionTime:   metav1.NewTime(now.Add(-10 * time.Second)),
 | 
								completionTime:   metav1.NewTime(now.Add(-10 * time.Second)),
 | 
				
			||||||
			ttl:              int32Ptr(15),
 | 
								ttl:              utilpointer.Int32Ptr(15),
 | 
				
			||||||
			since:            &now.Time,
 | 
								since:            &now.Time,
 | 
				
			||||||
			expectedTimeLeft: durationPointer(5),
 | 
								expectedTimeLeft: durationPointer(5),
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
@@ -136,21 +133,21 @@ func TestTimeLeft(t *testing.T) {
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
			name:             "Job failed now, 0s TTL",
 | 
								name:             "Job failed now, 0s TTL",
 | 
				
			||||||
			failedTime:       now,
 | 
								failedTime:       now,
 | 
				
			||||||
			ttl:              int32Ptr(0),
 | 
								ttl:              utilpointer.Int32Ptr(0),
 | 
				
			||||||
			since:            &now.Time,
 | 
								since:            &now.Time,
 | 
				
			||||||
			expectedTimeLeft: durationPointer(0),
 | 
								expectedTimeLeft: durationPointer(0),
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name:             "Job failed now, 10s TTL",
 | 
								name:             "Job failed now, 10s TTL",
 | 
				
			||||||
			failedTime:       now,
 | 
								failedTime:       now,
 | 
				
			||||||
			ttl:              int32Ptr(10),
 | 
								ttl:              utilpointer.Int32Ptr(10),
 | 
				
			||||||
			since:            &now.Time,
 | 
								since:            &now.Time,
 | 
				
			||||||
			expectedTimeLeft: durationPointer(10),
 | 
								expectedTimeLeft: durationPointer(10),
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			name:             "Job failed 10s ago, 15s TTL",
 | 
								name:             "Job failed 10s ago, 15s TTL",
 | 
				
			||||||
			failedTime:       metav1.NewTime(now.Add(-10 * time.Second)),
 | 
								failedTime:       metav1.NewTime(now.Add(-10 * time.Second)),
 | 
				
			||||||
			ttl:              int32Ptr(15),
 | 
								ttl:              utilpointer.Int32Ptr(15),
 | 
				
			||||||
			since:            &now.Time,
 | 
								since:            &now.Time,
 | 
				
			||||||
			expectedTimeLeft: durationPointer(5),
 | 
								expectedTimeLeft: durationPointer(5),
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -89,6 +89,7 @@ go_library(
 | 
				
			|||||||
        "//staging/src/k8s.io/client-go/scale:go_default_library",
 | 
					        "//staging/src/k8s.io/client-go/scale:go_default_library",
 | 
				
			||||||
        "//staging/src/k8s.io/client-go/util/retry:go_default_library",
 | 
					        "//staging/src/k8s.io/client-go/util/retry:go_default_library",
 | 
				
			||||||
        "//vendor/k8s.io/utils/integer:go_default_library",
 | 
					        "//vendor/k8s.io/utils/integer:go_default_library",
 | 
				
			||||||
 | 
					        "//vendor/k8s.io/utils/pointer:go_default_library",
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -75,6 +75,7 @@ go_test(
 | 
				
			|||||||
        "//staging/src/k8s.io/client-go/testing:go_default_library",
 | 
					        "//staging/src/k8s.io/client-go/testing:go_default_library",
 | 
				
			||||||
        "//vendor/github.com/googleapis/gnostic/OpenAPIv2:go_default_library",
 | 
					        "//vendor/github.com/googleapis/gnostic/OpenAPIv2:go_default_library",
 | 
				
			||||||
        "//vendor/github.com/spf13/cobra:go_default_library",
 | 
					        "//vendor/github.com/spf13/cobra:go_default_library",
 | 
				
			||||||
 | 
					        "//vendor/k8s.io/utils/pointer:go_default_library",
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -50,6 +50,7 @@ import (
 | 
				
			|||||||
	cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
 | 
						cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubectl/cmd/util/openapi"
 | 
						"k8s.io/kubernetes/pkg/kubectl/cmd/util/openapi"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubectl/scheme"
 | 
						"k8s.io/kubernetes/pkg/kubectl/scheme"
 | 
				
			||||||
 | 
						utilpointer "k8s.io/utils/pointer"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var (
 | 
					var (
 | 
				
			||||||
@@ -1251,7 +1252,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 = cmdtesting.Int32ptr(0)
 | 
												rcObj.Spec.Replicas = utilpointer.Int32Ptr(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)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -50,6 +50,7 @@ go_test(
 | 
				
			|||||||
        "//staging/src/k8s.io/cli-runtime/pkg/printers:go_default_library",
 | 
					        "//staging/src/k8s.io/cli-runtime/pkg/printers:go_default_library",
 | 
				
			||||||
        "//staging/src/k8s.io/client-go/rest/fake:go_default_library",
 | 
					        "//staging/src/k8s.io/client-go/rest/fake:go_default_library",
 | 
				
			||||||
        "//vendor/github.com/spf13/cobra:go_default_library",
 | 
					        "//vendor/github.com/spf13/cobra:go_default_library",
 | 
				
			||||||
 | 
					        "//vendor/k8s.io/utils/pointer:go_default_library",
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -51,6 +51,7 @@ import (
 | 
				
			|||||||
	cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
 | 
						cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubectl/drain"
 | 
						"k8s.io/kubernetes/pkg/kubectl/drain"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubectl/scheme"
 | 
						"k8s.io/kubernetes/pkg/kubectl/scheme"
 | 
				
			||||||
 | 
						utilpointer "k8s.io/utils/pointer"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const (
 | 
					const (
 | 
				
			||||||
@@ -61,8 +62,6 @@ const (
 | 
				
			|||||||
var node *corev1.Node
 | 
					var node *corev1.Node
 | 
				
			||||||
var cordonedNode *corev1.Node
 | 
					var cordonedNode *corev1.Node
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func boolptr(b bool) *bool { return &b }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func TestMain(m *testing.M) {
 | 
					func TestMain(m *testing.M) {
 | 
				
			||||||
	// Create a node.
 | 
						// Create a node.
 | 
				
			||||||
	node = &corev1.Node{
 | 
						node = &corev1.Node{
 | 
				
			||||||
@@ -286,8 +285,8 @@ func TestDrain(t *testing.T) {
 | 
				
			|||||||
					Kind:               "ReplicationController",
 | 
										Kind:               "ReplicationController",
 | 
				
			||||||
					Name:               "rc",
 | 
										Name:               "rc",
 | 
				
			||||||
					UID:                "123",
 | 
										UID:                "123",
 | 
				
			||||||
					BlockOwnerDeletion: boolptr(true),
 | 
										BlockOwnerDeletion: utilpointer.BoolPtr(true),
 | 
				
			||||||
					Controller:         boolptr(true),
 | 
										Controller:         utilpointer.BoolPtr(true),
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
@@ -318,8 +317,8 @@ func TestDrain(t *testing.T) {
 | 
				
			|||||||
					APIVersion:         "apps/v1",
 | 
										APIVersion:         "apps/v1",
 | 
				
			||||||
					Kind:               "DaemonSet",
 | 
										Kind:               "DaemonSet",
 | 
				
			||||||
					Name:               "ds",
 | 
										Name:               "ds",
 | 
				
			||||||
					BlockOwnerDeletion: boolptr(true),
 | 
										BlockOwnerDeletion: utilpointer.BoolPtr(true),
 | 
				
			||||||
					Controller:         boolptr(true),
 | 
										Controller:         utilpointer.BoolPtr(true),
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
@@ -339,8 +338,8 @@ func TestDrain(t *testing.T) {
 | 
				
			|||||||
					APIVersion:         "apps/v1",
 | 
										APIVersion:         "apps/v1",
 | 
				
			||||||
					Kind:               "DaemonSet",
 | 
										Kind:               "DaemonSet",
 | 
				
			||||||
					Name:               "ds",
 | 
										Name:               "ds",
 | 
				
			||||||
					BlockOwnerDeletion: boolptr(true),
 | 
										BlockOwnerDeletion: utilpointer.BoolPtr(true),
 | 
				
			||||||
					Controller:         boolptr(true),
 | 
										Controller:         utilpointer.BoolPtr(true),
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
@@ -363,8 +362,8 @@ func TestDrain(t *testing.T) {
 | 
				
			|||||||
					APIVersion:         "apps/v1",
 | 
										APIVersion:         "apps/v1",
 | 
				
			||||||
					Kind:               "DaemonSet",
 | 
										Kind:               "DaemonSet",
 | 
				
			||||||
					Name:               "ds",
 | 
										Name:               "ds",
 | 
				
			||||||
					BlockOwnerDeletion: boolptr(true),
 | 
										BlockOwnerDeletion: utilpointer.BoolPtr(true),
 | 
				
			||||||
					Controller:         boolptr(true),
 | 
										Controller:         utilpointer.BoolPtr(true),
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
@@ -413,8 +412,8 @@ func TestDrain(t *testing.T) {
 | 
				
			|||||||
					APIVersion:         "v1",
 | 
										APIVersion:         "v1",
 | 
				
			||||||
					Kind:               "Job",
 | 
										Kind:               "Job",
 | 
				
			||||||
					Name:               "job",
 | 
										Name:               "job",
 | 
				
			||||||
					BlockOwnerDeletion: boolptr(true),
 | 
										BlockOwnerDeletion: utilpointer.BoolPtr(true),
 | 
				
			||||||
					Controller:         boolptr(true),
 | 
										Controller:         utilpointer.BoolPtr(true),
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
@@ -440,8 +439,8 @@ func TestDrain(t *testing.T) {
 | 
				
			|||||||
					APIVersion:         "v1",
 | 
										APIVersion:         "v1",
 | 
				
			||||||
					Kind:               "Job",
 | 
										Kind:               "Job",
 | 
				
			||||||
					Name:               "job",
 | 
										Name:               "job",
 | 
				
			||||||
					BlockOwnerDeletion: boolptr(true),
 | 
										BlockOwnerDeletion: utilpointer.BoolPtr(true),
 | 
				
			||||||
					Controller:         boolptr(true),
 | 
										Controller:         utilpointer.BoolPtr(true),
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
@@ -482,8 +481,8 @@ func TestDrain(t *testing.T) {
 | 
				
			|||||||
					APIVersion:         "v1",
 | 
										APIVersion:         "v1",
 | 
				
			||||||
					Kind:               "ReplicaSet",
 | 
										Kind:               "ReplicaSet",
 | 
				
			||||||
					Name:               "rs",
 | 
										Name:               "rs",
 | 
				
			||||||
					BlockOwnerDeletion: boolptr(true),
 | 
										BlockOwnerDeletion: utilpointer.BoolPtr(true),
 | 
				
			||||||
					Controller:         boolptr(true),
 | 
										Controller:         utilpointer.BoolPtr(true),
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -139,8 +139,3 @@ func InitTestErrorHandler(t *testing.T) {
 | 
				
			|||||||
		t.Errorf("Error running command (exit code %d): %s", code, str)
 | 
							t.Errorf("Error running command (exit code %d): %s", code, str)
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
func Int32ptr(val int) *int32 {
 | 
					 | 
				
			||||||
	t := int32(val)
 | 
					 | 
				
			||||||
	return &t
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3088,12 +3088,6 @@ func TestDescribeStatefulSet(t *testing.T) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// boolPtr returns a pointer to a bool
 | 
					 | 
				
			||||||
func boolPtr(b bool) *bool {
 | 
					 | 
				
			||||||
	o := b
 | 
					 | 
				
			||||||
	return &o
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func TestControllerRef(t *testing.T) {
 | 
					func TestControllerRef(t *testing.T) {
 | 
				
			||||||
	var replicas int32 = 1
 | 
						var replicas int32 = 1
 | 
				
			||||||
	f := fake.NewSimpleClientset(
 | 
						f := fake.NewSimpleClientset(
 | 
				
			||||||
@@ -3123,7 +3117,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: boolPtr(true)}},
 | 
									OwnerReferences: []metav1.OwnerReference{{Name: "bar", UID: "123456", Controller: utilpointer.BoolPtr(true)}},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			TypeMeta: metav1.TypeMeta{
 | 
								TypeMeta: metav1.TypeMeta{
 | 
				
			||||||
				Kind: "Pod",
 | 
									Kind: "Pod",
 | 
				
			||||||
@@ -3160,7 +3154,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: boolPtr(true)}},
 | 
									OwnerReferences: []metav1.OwnerReference{{Name: "buz", UID: "654321", Controller: utilpointer.BoolPtr(true)}},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
			TypeMeta: metav1.TypeMeta{
 | 
								TypeMeta: metav1.TypeMeta{
 | 
				
			||||||
				Kind: "Pod",
 | 
									Kind: "Pod",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -38,13 +38,9 @@ import (
 | 
				
			|||||||
	deploymentutil "k8s.io/kubernetes/pkg/kubectl/util/deployment"
 | 
						deploymentutil "k8s.io/kubernetes/pkg/kubectl/util/deployment"
 | 
				
			||||||
	"k8s.io/kubernetes/pkg/kubectl/util/podutils"
 | 
						"k8s.io/kubernetes/pkg/kubectl/util/podutils"
 | 
				
			||||||
	"k8s.io/utils/integer"
 | 
						"k8s.io/utils/integer"
 | 
				
			||||||
 | 
						utilpointer "k8s.io/utils/pointer"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func newInt32Ptr(val int) *int32 {
 | 
					 | 
				
			||||||
	ret := int32(val)
 | 
					 | 
				
			||||||
	return &ret
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func valOrZero(val *int32) int32 {
 | 
					func valOrZero(val *int32) int32 {
 | 
				
			||||||
	if val == nil {
 | 
						if val == nil {
 | 
				
			||||||
		return int32(0)
 | 
							return int32(0)
 | 
				
			||||||
@@ -393,12 +389,12 @@ func (r *RollingUpdater) scaleDown(newRc, oldRc *corev1.ReplicationController, d
 | 
				
			|||||||
	nextOldVal := valOrZero(oldRc.Spec.Replicas) - decrement
 | 
						nextOldVal := valOrZero(oldRc.Spec.Replicas) - decrement
 | 
				
			||||||
	oldRc.Spec.Replicas = &nextOldVal
 | 
						oldRc.Spec.Replicas = &nextOldVal
 | 
				
			||||||
	if valOrZero(oldRc.Spec.Replicas) < 0 {
 | 
						if valOrZero(oldRc.Spec.Replicas) < 0 {
 | 
				
			||||||
		oldRc.Spec.Replicas = newInt32Ptr(0)
 | 
							oldRc.Spec.Replicas = utilpointer.Int32Ptr(0)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	// If the new is already fully scaled and available up to the desired size, go
 | 
						// If the new is already fully scaled and available up to the desired size, go
 | 
				
			||||||
	// ahead and scale old all the way down.
 | 
						// ahead and scale old all the way down.
 | 
				
			||||||
	if valOrZero(newRc.Spec.Replicas) == desired && newAvailable == desired {
 | 
						if valOrZero(newRc.Spec.Replicas) == desired && newAvailable == desired {
 | 
				
			||||||
		oldRc.Spec.Replicas = newInt32Ptr(0)
 | 
							oldRc.Spec.Replicas = utilpointer.Int32Ptr(0)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	// Perform the scale-down.
 | 
						// Perform the scale-down.
 | 
				
			||||||
	fmt.Fprintf(config.Out, "Scaling %s down to %d\n", oldRc.Name, valOrZero(oldRc.Spec.Replicas))
 | 
						fmt.Fprintf(config.Out, "Scaling %s down to %d\n", oldRc.Name, valOrZero(oldRc.Spec.Replicas))
 | 
				
			||||||
@@ -482,7 +478,7 @@ func (r *RollingUpdater) getOrCreateTargetControllerWithClient(controller *corev
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		controller.Annotations[desiredReplicasAnnotation] = fmt.Sprintf("%d", valOrZero(controller.Spec.Replicas))
 | 
							controller.Annotations[desiredReplicasAnnotation] = fmt.Sprintf("%d", valOrZero(controller.Spec.Replicas))
 | 
				
			||||||
		controller.Annotations[sourceIDAnnotation] = sourceID
 | 
							controller.Annotations[sourceIDAnnotation] = sourceID
 | 
				
			||||||
		controller.Spec.Replicas = newInt32Ptr(0)
 | 
							controller.Spec.Replicas = utilpointer.Int32Ptr(0)
 | 
				
			||||||
		newRc, err := r.rcClient.ReplicationControllers(r.ns).Create(controller)
 | 
							newRc, err := r.rcClient.ReplicationControllers(r.ns).Create(controller)
 | 
				
			||||||
		return newRc, false, err
 | 
							return newRc, false, err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -49,6 +49,7 @@ go_test(
 | 
				
			|||||||
        "//vendor/k8s.io/klog:go_default_library",
 | 
					        "//vendor/k8s.io/klog:go_default_library",
 | 
				
			||||||
        "//vendor/k8s.io/utils/exec:go_default_library",
 | 
					        "//vendor/k8s.io/utils/exec:go_default_library",
 | 
				
			||||||
        "//vendor/k8s.io/utils/exec/testing:go_default_library",
 | 
					        "//vendor/k8s.io/utils/exec/testing:go_default_library",
 | 
				
			||||||
 | 
					        "//vendor/k8s.io/utils/pointer:go_default_library",
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -41,6 +41,7 @@ import (
 | 
				
			|||||||
	iptablestest "k8s.io/kubernetes/pkg/util/iptables/testing"
 | 
						iptablestest "k8s.io/kubernetes/pkg/util/iptables/testing"
 | 
				
			||||||
	"k8s.io/utils/exec"
 | 
						"k8s.io/utils/exec"
 | 
				
			||||||
	fakeexec "k8s.io/utils/exec/testing"
 | 
						fakeexec "k8s.io/utils/exec/testing"
 | 
				
			||||||
 | 
						utilpointer "k8s.io/utils/pointer"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func checkAllLines(t *testing.T, table utiliptables.Table, save []byte, expectedLines map[utiliptables.Chain]string) {
 | 
					func checkAllLines(t *testing.T, table utiliptables.Table, save []byte, expectedLines map[utiliptables.Chain]string) {
 | 
				
			||||||
@@ -845,10 +846,6 @@ func TestNodePortReject(t *testing.T) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func strPtr(s string) *string {
 | 
					 | 
				
			||||||
	return &s
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func TestOnlyLocalLoadBalancing(t *testing.T) {
 | 
					func TestOnlyLocalLoadBalancing(t *testing.T) {
 | 
				
			||||||
	ipt := iptablestest.NewFake()
 | 
						ipt := iptablestest.NewFake()
 | 
				
			||||||
	fp := NewFakeProxier(ipt)
 | 
						fp := NewFakeProxier(ipt)
 | 
				
			||||||
@@ -895,7 +892,7 @@ func TestOnlyLocalLoadBalancing(t *testing.T) {
 | 
				
			|||||||
					NodeName: nil,
 | 
										NodeName: nil,
 | 
				
			||||||
				}, {
 | 
									}, {
 | 
				
			||||||
					IP:       epIP2,
 | 
										IP:       epIP2,
 | 
				
			||||||
					NodeName: strPtr(testHostname),
 | 
										NodeName: utilpointer.StringPtr(testHostname),
 | 
				
			||||||
				}},
 | 
									}},
 | 
				
			||||||
				Ports: []v1.EndpointPort{{
 | 
									Ports: []v1.EndpointPort{{
 | 
				
			||||||
					Name: svcPortName.Port,
 | 
										Name: svcPortName.Port,
 | 
				
			||||||
@@ -989,7 +986,7 @@ func onlyLocalNodePorts(t *testing.T, fp *Proxier, ipt *iptablestest.FakeIPTable
 | 
				
			|||||||
					NodeName: nil,
 | 
										NodeName: nil,
 | 
				
			||||||
				}, {
 | 
									}, {
 | 
				
			||||||
					IP:       epIP2,
 | 
										IP:       epIP2,
 | 
				
			||||||
					NodeName: strPtr(testHostname),
 | 
										NodeName: utilpointer.StringPtr(testHostname),
 | 
				
			||||||
				}},
 | 
									}},
 | 
				
			||||||
				Ports: []v1.EndpointPort{{
 | 
									Ports: []v1.EndpointPort{{
 | 
				
			||||||
					Name: svcPortName.Port,
 | 
										Name: svcPortName.Port,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,6 +28,7 @@
 | 
				
			|||||||
  - k8s.io/cli-runtime/pkg/printers
 | 
					  - k8s.io/cli-runtime/pkg/printers
 | 
				
			||||||
  - k8s.io/cli-runtime/pkg/resource
 | 
					  - k8s.io/cli-runtime/pkg/resource
 | 
				
			||||||
  - k8s.io/cli-runtime/pkg/kustomize
 | 
					  - k8s.io/cli-runtime/pkg/kustomize
 | 
				
			||||||
 | 
					  - k8s.io/utils/pointer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- baseImportPath: "./vendor/k8s.io/apimachinery/"
 | 
					- baseImportPath: "./vendor/k8s.io/apimachinery/"
 | 
				
			||||||
  allowedImports:
 | 
					  allowedImports:
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user