forked from kubernetes/kubernetes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit does two things in pkg package:
1. Remove unused ptr functions. 2. Replace ptr functions with k8s.io/utils/pointer
- Loading branch information
1 parent
4a1da48
commit d0138ca
Showing
20 changed files
with
75 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ import ( | |
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/util/validation/field" | ||
"k8s.io/kubernetes/pkg/apis/auditregistration" | ||
utilpointer "k8s.io/utils/pointer" | ||
) | ||
|
||
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) { | ||
tests := []struct { | ||
name string | ||
|
@@ -157,7 +156,7 @@ func TestValidateWebhookConfiguration(t *testing.T) { | |
Name: "n", | ||
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`, | ||
|
@@ -166,7 +165,7 @@ func TestValidateWebhookConfiguration(t *testing.T) { | |
name: "blank URL", | ||
config: auditregistration.Webhook{ | ||
ClientConfig: auditregistration.WebhookClientConfig{ | ||
URL: strPtr(""), | ||
URL: utilpointer.StringPtr(""), | ||
}, | ||
}, | ||
expectedError: `webhook.clientConfig.url: Invalid value: "": host must be provided`, | ||
|
@@ -175,7 +174,7 @@ func TestValidateWebhookConfiguration(t *testing.T) { | |
name: "missing host", | ||
config: auditregistration.Webhook{ | ||
ClientConfig: auditregistration.WebhookClientConfig{ | ||
URL: strPtr("https:///fancy/webhook"), | ||
URL: utilpointer.StringPtr("https:///fancy/webhook"), | ||
}, | ||
}, | ||
expectedError: `host must be provided`, | ||
|
@@ -184,7 +183,7 @@ func TestValidateWebhookConfiguration(t *testing.T) { | |
name: "fragment", | ||
config: auditregistration.Webhook{ | ||
ClientConfig: auditregistration.WebhookClientConfig{ | ||
URL: strPtr("https://example.com/#bookmark"), | ||
URL: utilpointer.StringPtr("https://example.com/#bookmark"), | ||
}, | ||
}, | ||
expectedError: `"bookmark": fragments are not permitted`, | ||
|
@@ -193,7 +192,7 @@ func TestValidateWebhookConfiguration(t *testing.T) { | |
name: "query", | ||
config: auditregistration.Webhook{ | ||
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`, | ||
|
@@ -202,7 +201,7 @@ func TestValidateWebhookConfiguration(t *testing.T) { | |
name: "user", | ||
config: auditregistration.Webhook{ | ||
ClientConfig: auditregistration.WebhookClientConfig{ | ||
URL: strPtr("https://[email protected]/"), | ||
URL: utilpointer.StringPtr("https://[email protected]/"), | ||
}, | ||
}, | ||
expectedError: `"harry.potter": user information is not permitted`, | ||
|
@@ -211,7 +210,7 @@ func TestValidateWebhookConfiguration(t *testing.T) { | |
name: "just totally wrong", | ||
config: auditregistration.Webhook{ | ||
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`, | ||
|
@@ -223,7 +222,7 @@ func TestValidateWebhookConfiguration(t *testing.T) { | |
Service: &auditregistration.ServiceReference{ | ||
Namespace: "ns", | ||
Name: "n", | ||
Path: strPtr("foo/"), | ||
Path: utilpointer.StringPtr("foo/"), | ||
Port: 443, | ||
}, | ||
}, | ||
|
@@ -237,7 +236,7 @@ func TestValidateWebhookConfiguration(t *testing.T) { | |
Service: &auditregistration.ServiceReference{ | ||
Namespace: "ns", | ||
Name: "n", | ||
Path: strPtr("foo/"), | ||
Path: utilpointer.StringPtr("foo/"), | ||
Port: 65536, | ||
}, | ||
}, | ||
|
@@ -251,7 +250,7 @@ func TestValidateWebhookConfiguration(t *testing.T) { | |
Service: &auditregistration.ServiceReference{ | ||
Namespace: "ns", | ||
Name: "n", | ||
Path: strPtr("foo/"), | ||
Path: utilpointer.StringPtr("foo/"), | ||
Port: 0, | ||
}, | ||
}, | ||
|
@@ -265,7 +264,7 @@ func TestValidateWebhookConfiguration(t *testing.T) { | |
Service: &auditregistration.ServiceReference{ | ||
Namespace: "ns", | ||
Name: "n", | ||
Path: strPtr("/"), | ||
Path: utilpointer.StringPtr("/"), | ||
Port: 443, | ||
}, | ||
}, | ||
|
@@ -279,7 +278,7 @@ func TestValidateWebhookConfiguration(t *testing.T) { | |
Service: &auditregistration.ServiceReference{ | ||
Namespace: "ns", | ||
Name: "n", | ||
Path: strPtr("/foo"), | ||
Path: utilpointer.StringPtr("/foo"), | ||
Port: 443, | ||
}, | ||
}, | ||
|
@@ -293,7 +292,7 @@ func TestValidateWebhookConfiguration(t *testing.T) { | |
Service: &auditregistration.ServiceReference{ | ||
Namespace: "ns", | ||
Name: "n", | ||
Path: strPtr("//"), | ||
Path: utilpointer.StringPtr("//"), | ||
Port: 443, | ||
}, | ||
}, | ||
|
@@ -307,7 +306,7 @@ func TestValidateWebhookConfiguration(t *testing.T) { | |
Service: &auditregistration.ServiceReference{ | ||
Namespace: "ns", | ||
Name: "n", | ||
Path: strPtr("/foo//bar/"), | ||
Path: utilpointer.StringPtr("/foo//bar/"), | ||
Port: 443, | ||
}, | ||
}, | ||
|
@@ -320,7 +319,7 @@ func TestValidateWebhookConfiguration(t *testing.T) { | |
Service: &auditregistration.ServiceReference{ | ||
Namespace: "ns", | ||
Name: "n", | ||
Path: strPtr("/foo/bar//"), | ||
Path: utilpointer.StringPtr("/foo/bar//"), | ||
Port: 443, | ||
}, | ||
}, | ||
|
@@ -334,7 +333,7 @@ func TestValidateWebhookConfiguration(t *testing.T) { | |
Service: &auditregistration.ServiceReference{ | ||
Namespace: "ns", | ||
Name: "n", | ||
Path: strPtr("/apis/foo.bar/v1alpha1/--bad"), | ||
Path: utilpointer.StringPtr("/apis/foo.bar/v1alpha1/--bad"), | ||
Port: 443, | ||
}, | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.