mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-12-01 13:53:55 +00:00
pkg/api(s): drop pointer wrapper functions
The new k8s.io/utils/ptr package provides generic wrapper functions, which can be used instead of type-specific pointer wrapper functions. This replaces the latter with the former, and migrates other uses of the deprecated pointer package to ptr in affacted files. Signed-off-by: Stephen Kitt <skitt@redhat.com>
This commit is contained in:
@@ -32,14 +32,9 @@ import (
|
||||
"k8s.io/apiserver/pkg/features"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
"k8s.io/kubernetes/pkg/apis/admissionregistration"
|
||||
"k8s.io/utils/ptr"
|
||||
)
|
||||
|
||||
func ptr[T any](v T) *T { return &v }
|
||||
|
||||
func strPtr(s string) *string { return &s }
|
||||
|
||||
func int32Ptr(i int32) *int32 { return &i }
|
||||
|
||||
func newValidatingWebhookConfiguration(hooks []admissionregistration.ValidatingWebhook, defaultAdmissionReviewVersions bool) *admissionregistration.ValidatingWebhookConfiguration {
|
||||
// If the test case did not specify an AdmissionReviewVersions, default it so the test passes as
|
||||
// this field will be defaulted in production code.
|
||||
@@ -60,7 +55,7 @@ func TestValidateValidatingWebhookConfiguration(t *testing.T) {
|
||||
noSideEffect := admissionregistration.SideEffectClassNone
|
||||
unknownSideEffect := admissionregistration.SideEffectClassUnknown
|
||||
validClientConfig := admissionregistration.WebhookClientConfig{
|
||||
URL: strPtr("https://example.com"),
|
||||
URL: ptr.To("https://example.com"),
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -380,7 +375,7 @@ func TestValidateValidatingWebhookConfiguration(t *testing.T) {
|
||||
Name: "n",
|
||||
Port: 443,
|
||||
},
|
||||
URL: strPtr("example.com/k8s/webhook"),
|
||||
URL: ptr.To("example.com/k8s/webhook"),
|
||||
},
|
||||
},
|
||||
}, true),
|
||||
@@ -390,7 +385,7 @@ func TestValidateValidatingWebhookConfiguration(t *testing.T) {
|
||||
config: newValidatingWebhookConfiguration([]admissionregistration.ValidatingWebhook{{
|
||||
Name: "webhook.k8s.io",
|
||||
ClientConfig: admissionregistration.WebhookClientConfig{
|
||||
URL: strPtr(""),
|
||||
URL: ptr.To(""),
|
||||
},
|
||||
},
|
||||
}, true),
|
||||
@@ -400,7 +395,7 @@ func TestValidateValidatingWebhookConfiguration(t *testing.T) {
|
||||
config: newValidatingWebhookConfiguration([]admissionregistration.ValidatingWebhook{{
|
||||
Name: "webhook.k8s.io",
|
||||
ClientConfig: admissionregistration.WebhookClientConfig{
|
||||
URL: strPtr("http://example.com"),
|
||||
URL: ptr.To("http://example.com"),
|
||||
},
|
||||
},
|
||||
}, true),
|
||||
@@ -410,7 +405,7 @@ func TestValidateValidatingWebhookConfiguration(t *testing.T) {
|
||||
config: newValidatingWebhookConfiguration([]admissionregistration.ValidatingWebhook{{
|
||||
Name: "webhook.k8s.io",
|
||||
ClientConfig: admissionregistration.WebhookClientConfig{
|
||||
URL: strPtr("https:///fancy/webhook"),
|
||||
URL: ptr.To("https:///fancy/webhook"),
|
||||
},
|
||||
},
|
||||
}, true),
|
||||
@@ -420,7 +415,7 @@ func TestValidateValidatingWebhookConfiguration(t *testing.T) {
|
||||
config: newValidatingWebhookConfiguration([]admissionregistration.ValidatingWebhook{{
|
||||
Name: "webhook.k8s.io",
|
||||
ClientConfig: admissionregistration.WebhookClientConfig{
|
||||
URL: strPtr("https://example.com/#bookmark"),
|
||||
URL: ptr.To("https://example.com/#bookmark"),
|
||||
},
|
||||
},
|
||||
}, true),
|
||||
@@ -430,7 +425,7 @@ func TestValidateValidatingWebhookConfiguration(t *testing.T) {
|
||||
config: newValidatingWebhookConfiguration([]admissionregistration.ValidatingWebhook{{
|
||||
Name: "webhook.k8s.io",
|
||||
ClientConfig: admissionregistration.WebhookClientConfig{
|
||||
URL: strPtr("https://example.com?arg=value"),
|
||||
URL: ptr.To("https://example.com?arg=value"),
|
||||
},
|
||||
},
|
||||
}, true),
|
||||
@@ -440,7 +435,7 @@ func TestValidateValidatingWebhookConfiguration(t *testing.T) {
|
||||
config: newValidatingWebhookConfiguration([]admissionregistration.ValidatingWebhook{{
|
||||
Name: "webhook.k8s.io",
|
||||
ClientConfig: admissionregistration.WebhookClientConfig{
|
||||
URL: strPtr("https://harry.potter@example.com/"),
|
||||
URL: ptr.To("https://harry.potter@example.com/"),
|
||||
},
|
||||
},
|
||||
}, true),
|
||||
@@ -450,7 +445,7 @@ func TestValidateValidatingWebhookConfiguration(t *testing.T) {
|
||||
config: newValidatingWebhookConfiguration([]admissionregistration.ValidatingWebhook{{
|
||||
Name: "webhook.k8s.io",
|
||||
ClientConfig: admissionregistration.WebhookClientConfig{
|
||||
URL: strPtr("arg#backwards=thisis?html.index/port:host//:https"),
|
||||
URL: ptr.To("arg#backwards=thisis?html.index/port:host//:https"),
|
||||
},
|
||||
},
|
||||
}, true),
|
||||
@@ -463,7 +458,7 @@ func TestValidateValidatingWebhookConfiguration(t *testing.T) {
|
||||
Service: &admissionregistration.ServiceReference{
|
||||
Namespace: "ns",
|
||||
Name: "n",
|
||||
Path: strPtr("foo/"),
|
||||
Path: ptr.To("foo/"),
|
||||
Port: 443,
|
||||
},
|
||||
},
|
||||
@@ -478,7 +473,7 @@ func TestValidateValidatingWebhookConfiguration(t *testing.T) {
|
||||
Service: &admissionregistration.ServiceReference{
|
||||
Namespace: "ns",
|
||||
Name: "n",
|
||||
Path: strPtr("/"),
|
||||
Path: ptr.To("/"),
|
||||
Port: 443,
|
||||
},
|
||||
},
|
||||
@@ -494,7 +489,7 @@ func TestValidateValidatingWebhookConfiguration(t *testing.T) {
|
||||
Service: &admissionregistration.ServiceReference{
|
||||
Namespace: "ns",
|
||||
Name: "n",
|
||||
Path: strPtr("/foo"),
|
||||
Path: ptr.To("/foo"),
|
||||
Port: 443,
|
||||
},
|
||||
},
|
||||
@@ -510,7 +505,7 @@ func TestValidateValidatingWebhookConfiguration(t *testing.T) {
|
||||
Service: &admissionregistration.ServiceReference{
|
||||
Namespace: "ns",
|
||||
Name: "n",
|
||||
Path: strPtr("//"),
|
||||
Path: ptr.To("//"),
|
||||
Port: 443,
|
||||
},
|
||||
},
|
||||
@@ -526,7 +521,7 @@ func TestValidateValidatingWebhookConfiguration(t *testing.T) {
|
||||
Service: &admissionregistration.ServiceReference{
|
||||
Namespace: "ns",
|
||||
Name: "n",
|
||||
Path: strPtr("/foo//bar/"),
|
||||
Path: ptr.To("/foo//bar/"),
|
||||
Port: 443,
|
||||
},
|
||||
},
|
||||
@@ -542,7 +537,7 @@ func TestValidateValidatingWebhookConfiguration(t *testing.T) {
|
||||
Service: &admissionregistration.ServiceReference{
|
||||
Namespace: "ns",
|
||||
Name: "n",
|
||||
Path: strPtr("/foo/bar//"),
|
||||
Path: ptr.To("/foo/bar//"),
|
||||
Port: 443,
|
||||
},
|
||||
},
|
||||
@@ -558,7 +553,7 @@ func TestValidateValidatingWebhookConfiguration(t *testing.T) {
|
||||
Service: &admissionregistration.ServiceReference{
|
||||
Namespace: "ns",
|
||||
Name: "n",
|
||||
Path: strPtr("/apis/foo.bar/v1alpha1/--bad"),
|
||||
Path: ptr.To("/apis/foo.bar/v1alpha1/--bad"),
|
||||
Port: 443,
|
||||
},
|
||||
},
|
||||
@@ -575,7 +570,7 @@ func TestValidateValidatingWebhookConfiguration(t *testing.T) {
|
||||
Service: &admissionregistration.ServiceReference{
|
||||
Namespace: "ns",
|
||||
Name: "n",
|
||||
Path: strPtr("https://apis/foo.bar"),
|
||||
Path: ptr.To("https://apis/foo.bar"),
|
||||
Port: 0,
|
||||
},
|
||||
},
|
||||
@@ -592,7 +587,7 @@ func TestValidateValidatingWebhookConfiguration(t *testing.T) {
|
||||
Service: &admissionregistration.ServiceReference{
|
||||
Namespace: "ns",
|
||||
Name: "n",
|
||||
Path: strPtr("https://apis/foo.bar"),
|
||||
Path: ptr.To("https://apis/foo.bar"),
|
||||
Port: 65536,
|
||||
},
|
||||
},
|
||||
@@ -606,7 +601,7 @@ func TestValidateValidatingWebhookConfiguration(t *testing.T) {
|
||||
Name: "webhook.k8s.io",
|
||||
ClientConfig: validClientConfig,
|
||||
SideEffects: &unknownSideEffect,
|
||||
TimeoutSeconds: int32Ptr(31),
|
||||
TimeoutSeconds: ptr.To[int32](31),
|
||||
},
|
||||
}, true),
|
||||
expectedError: `webhooks[0].timeoutSeconds: Invalid value: 31: the timeout value must be between 1 and 30 seconds`,
|
||||
@@ -616,7 +611,7 @@ func TestValidateValidatingWebhookConfiguration(t *testing.T) {
|
||||
Name: "webhook.k8s.io",
|
||||
ClientConfig: validClientConfig,
|
||||
SideEffects: &unknownSideEffect,
|
||||
TimeoutSeconds: int32Ptr(0),
|
||||
TimeoutSeconds: ptr.To[int32](0),
|
||||
},
|
||||
}, true),
|
||||
expectedError: `webhooks[0].timeoutSeconds: Invalid value: 0: the timeout value must be between 1 and 30 seconds`,
|
||||
@@ -626,7 +621,7 @@ func TestValidateValidatingWebhookConfiguration(t *testing.T) {
|
||||
Name: "webhook.k8s.io",
|
||||
ClientConfig: validClientConfig,
|
||||
SideEffects: &unknownSideEffect,
|
||||
TimeoutSeconds: int32Ptr(-1),
|
||||
TimeoutSeconds: ptr.To[int32](-1),
|
||||
},
|
||||
}, true),
|
||||
expectedError: `webhooks[0].timeoutSeconds: Invalid value: -1: the timeout value must be between 1 and 30 seconds`,
|
||||
@@ -636,17 +631,17 @@ func TestValidateValidatingWebhookConfiguration(t *testing.T) {
|
||||
Name: "webhook.k8s.io",
|
||||
ClientConfig: validClientConfig,
|
||||
SideEffects: &noSideEffect,
|
||||
TimeoutSeconds: int32Ptr(1),
|
||||
TimeoutSeconds: ptr.To[int32](1),
|
||||
}, {
|
||||
Name: "webhook2.k8s.io",
|
||||
ClientConfig: validClientConfig,
|
||||
SideEffects: &noSideEffect,
|
||||
TimeoutSeconds: int32Ptr(15),
|
||||
TimeoutSeconds: ptr.To[int32](15),
|
||||
}, {
|
||||
Name: "webhook3.k8s.io",
|
||||
ClientConfig: validClientConfig,
|
||||
SideEffects: &noSideEffect,
|
||||
TimeoutSeconds: int32Ptr(30),
|
||||
TimeoutSeconds: ptr.To[int32](30),
|
||||
},
|
||||
}, true),
|
||||
}, {
|
||||
@@ -841,7 +836,7 @@ func TestValidateValidatingWebhookConfigurationUpdate(t *testing.T) {
|
||||
noSideEffect := admissionregistration.SideEffectClassNone
|
||||
unknownSideEffect := admissionregistration.SideEffectClassUnknown
|
||||
validClientConfig := admissionregistration.WebhookClientConfig{
|
||||
URL: strPtr("https://example.com"),
|
||||
URL: ptr.To("https://example.com"),
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -1037,7 +1032,7 @@ func TestValidateMutatingWebhookConfiguration(t *testing.T) {
|
||||
noSideEffect := admissionregistration.SideEffectClassNone
|
||||
unknownSideEffect := admissionregistration.SideEffectClassUnknown
|
||||
validClientConfig := admissionregistration.WebhookClientConfig{
|
||||
URL: strPtr("https://example.com"),
|
||||
URL: ptr.To("https://example.com"),
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -1357,7 +1352,7 @@ func TestValidateMutatingWebhookConfiguration(t *testing.T) {
|
||||
Name: "n",
|
||||
Port: 443,
|
||||
},
|
||||
URL: strPtr("example.com/k8s/webhook"),
|
||||
URL: ptr.To("example.com/k8s/webhook"),
|
||||
},
|
||||
},
|
||||
}, true),
|
||||
@@ -1367,7 +1362,7 @@ func TestValidateMutatingWebhookConfiguration(t *testing.T) {
|
||||
config: newMutatingWebhookConfiguration([]admissionregistration.MutatingWebhook{{
|
||||
Name: "webhook.k8s.io",
|
||||
ClientConfig: admissionregistration.WebhookClientConfig{
|
||||
URL: strPtr(""),
|
||||
URL: ptr.To(""),
|
||||
},
|
||||
},
|
||||
}, true),
|
||||
@@ -1377,7 +1372,7 @@ func TestValidateMutatingWebhookConfiguration(t *testing.T) {
|
||||
config: newMutatingWebhookConfiguration([]admissionregistration.MutatingWebhook{{
|
||||
Name: "webhook.k8s.io",
|
||||
ClientConfig: admissionregistration.WebhookClientConfig{
|
||||
URL: strPtr("http://example.com"),
|
||||
URL: ptr.To("http://example.com"),
|
||||
},
|
||||
},
|
||||
}, true),
|
||||
@@ -1387,7 +1382,7 @@ func TestValidateMutatingWebhookConfiguration(t *testing.T) {
|
||||
config: newMutatingWebhookConfiguration([]admissionregistration.MutatingWebhook{{
|
||||
Name: "webhook.k8s.io",
|
||||
ClientConfig: admissionregistration.WebhookClientConfig{
|
||||
URL: strPtr("https:///fancy/webhook"),
|
||||
URL: ptr.To("https:///fancy/webhook"),
|
||||
},
|
||||
},
|
||||
}, true),
|
||||
@@ -1397,7 +1392,7 @@ func TestValidateMutatingWebhookConfiguration(t *testing.T) {
|
||||
config: newMutatingWebhookConfiguration([]admissionregistration.MutatingWebhook{{
|
||||
Name: "webhook.k8s.io",
|
||||
ClientConfig: admissionregistration.WebhookClientConfig{
|
||||
URL: strPtr("https://example.com/#bookmark"),
|
||||
URL: ptr.To("https://example.com/#bookmark"),
|
||||
},
|
||||
},
|
||||
}, true),
|
||||
@@ -1407,7 +1402,7 @@ func TestValidateMutatingWebhookConfiguration(t *testing.T) {
|
||||
config: newMutatingWebhookConfiguration([]admissionregistration.MutatingWebhook{{
|
||||
Name: "webhook.k8s.io",
|
||||
ClientConfig: admissionregistration.WebhookClientConfig{
|
||||
URL: strPtr("https://example.com?arg=value"),
|
||||
URL: ptr.To("https://example.com?arg=value"),
|
||||
},
|
||||
},
|
||||
}, true),
|
||||
@@ -1417,7 +1412,7 @@ func TestValidateMutatingWebhookConfiguration(t *testing.T) {
|
||||
config: newMutatingWebhookConfiguration([]admissionregistration.MutatingWebhook{{
|
||||
Name: "webhook.k8s.io",
|
||||
ClientConfig: admissionregistration.WebhookClientConfig{
|
||||
URL: strPtr("https://harry.potter@example.com/"),
|
||||
URL: ptr.To("https://harry.potter@example.com/"),
|
||||
},
|
||||
},
|
||||
}, true),
|
||||
@@ -1427,7 +1422,7 @@ func TestValidateMutatingWebhookConfiguration(t *testing.T) {
|
||||
config: newMutatingWebhookConfiguration([]admissionregistration.MutatingWebhook{{
|
||||
Name: "webhook.k8s.io",
|
||||
ClientConfig: admissionregistration.WebhookClientConfig{
|
||||
URL: strPtr("arg#backwards=thisis?html.index/port:host//:https"),
|
||||
URL: ptr.To("arg#backwards=thisis?html.index/port:host//:https"),
|
||||
},
|
||||
},
|
||||
}, true),
|
||||
@@ -1440,7 +1435,7 @@ func TestValidateMutatingWebhookConfiguration(t *testing.T) {
|
||||
Service: &admissionregistration.ServiceReference{
|
||||
Namespace: "ns",
|
||||
Name: "n",
|
||||
Path: strPtr("foo/"),
|
||||
Path: ptr.To("foo/"),
|
||||
Port: 443,
|
||||
},
|
||||
},
|
||||
@@ -1455,7 +1450,7 @@ func TestValidateMutatingWebhookConfiguration(t *testing.T) {
|
||||
Service: &admissionregistration.ServiceReference{
|
||||
Namespace: "ns",
|
||||
Name: "n",
|
||||
Path: strPtr("/"),
|
||||
Path: ptr.To("/"),
|
||||
Port: 443,
|
||||
},
|
||||
},
|
||||
@@ -1471,7 +1466,7 @@ func TestValidateMutatingWebhookConfiguration(t *testing.T) {
|
||||
Service: &admissionregistration.ServiceReference{
|
||||
Namespace: "ns",
|
||||
Name: "n",
|
||||
Path: strPtr("/foo"),
|
||||
Path: ptr.To("/foo"),
|
||||
Port: 443,
|
||||
},
|
||||
},
|
||||
@@ -1487,7 +1482,7 @@ func TestValidateMutatingWebhookConfiguration(t *testing.T) {
|
||||
Service: &admissionregistration.ServiceReference{
|
||||
Namespace: "ns",
|
||||
Name: "n",
|
||||
Path: strPtr("//"),
|
||||
Path: ptr.To("//"),
|
||||
Port: 443,
|
||||
},
|
||||
},
|
||||
@@ -1503,7 +1498,7 @@ func TestValidateMutatingWebhookConfiguration(t *testing.T) {
|
||||
Service: &admissionregistration.ServiceReference{
|
||||
Namespace: "ns",
|
||||
Name: "n",
|
||||
Path: strPtr("/foo//bar/"),
|
||||
Path: ptr.To("/foo//bar/"),
|
||||
Port: 443,
|
||||
},
|
||||
},
|
||||
@@ -1519,7 +1514,7 @@ func TestValidateMutatingWebhookConfiguration(t *testing.T) {
|
||||
Service: &admissionregistration.ServiceReference{
|
||||
Namespace: "ns",
|
||||
Name: "n",
|
||||
Path: strPtr("/foo/bar//"),
|
||||
Path: ptr.To("/foo/bar//"),
|
||||
Port: 443,
|
||||
},
|
||||
},
|
||||
@@ -1535,7 +1530,7 @@ func TestValidateMutatingWebhookConfiguration(t *testing.T) {
|
||||
Service: &admissionregistration.ServiceReference{
|
||||
Namespace: "ns",
|
||||
Name: "n",
|
||||
Path: strPtr("/apis/foo.bar/v1alpha1/--bad"),
|
||||
Path: ptr.To("/apis/foo.bar/v1alpha1/--bad"),
|
||||
Port: 443,
|
||||
},
|
||||
},
|
||||
@@ -1552,7 +1547,7 @@ func TestValidateMutatingWebhookConfiguration(t *testing.T) {
|
||||
Service: &admissionregistration.ServiceReference{
|
||||
Namespace: "ns",
|
||||
Name: "n",
|
||||
Path: strPtr("https://apis/foo.bar"),
|
||||
Path: ptr.To("https://apis/foo.bar"),
|
||||
Port: 0,
|
||||
},
|
||||
},
|
||||
@@ -1569,7 +1564,7 @@ func TestValidateMutatingWebhookConfiguration(t *testing.T) {
|
||||
Service: &admissionregistration.ServiceReference{
|
||||
Namespace: "ns",
|
||||
Name: "n",
|
||||
Path: strPtr("https://apis/foo.bar"),
|
||||
Path: ptr.To("https://apis/foo.bar"),
|
||||
Port: 65536,
|
||||
},
|
||||
},
|
||||
@@ -1583,7 +1578,7 @@ func TestValidateMutatingWebhookConfiguration(t *testing.T) {
|
||||
Name: "webhook.k8s.io",
|
||||
ClientConfig: validClientConfig,
|
||||
SideEffects: &unknownSideEffect,
|
||||
TimeoutSeconds: int32Ptr(31),
|
||||
TimeoutSeconds: ptr.To[int32](31),
|
||||
},
|
||||
}, true),
|
||||
expectedError: `webhooks[0].timeoutSeconds: Invalid value: 31: the timeout value must be between 1 and 30 seconds`,
|
||||
@@ -1593,7 +1588,7 @@ func TestValidateMutatingWebhookConfiguration(t *testing.T) {
|
||||
Name: "webhook.k8s.io",
|
||||
ClientConfig: validClientConfig,
|
||||
SideEffects: &unknownSideEffect,
|
||||
TimeoutSeconds: int32Ptr(0),
|
||||
TimeoutSeconds: ptr.To[int32](0),
|
||||
},
|
||||
}, true),
|
||||
expectedError: `webhooks[0].timeoutSeconds: Invalid value: 0: the timeout value must be between 1 and 30 seconds`,
|
||||
@@ -1603,7 +1598,7 @@ func TestValidateMutatingWebhookConfiguration(t *testing.T) {
|
||||
Name: "webhook.k8s.io",
|
||||
ClientConfig: validClientConfig,
|
||||
SideEffects: &unknownSideEffect,
|
||||
TimeoutSeconds: int32Ptr(-1),
|
||||
TimeoutSeconds: ptr.To[int32](-1),
|
||||
},
|
||||
}, true),
|
||||
expectedError: `webhooks[0].timeoutSeconds: Invalid value: -1: the timeout value must be between 1 and 30 seconds`,
|
||||
@@ -1613,17 +1608,17 @@ func TestValidateMutatingWebhookConfiguration(t *testing.T) {
|
||||
Name: "webhook.k8s.io",
|
||||
ClientConfig: validClientConfig,
|
||||
SideEffects: &noSideEffect,
|
||||
TimeoutSeconds: int32Ptr(1),
|
||||
TimeoutSeconds: ptr.To[int32](1),
|
||||
}, {
|
||||
Name: "webhook2.k8s.io",
|
||||
ClientConfig: validClientConfig,
|
||||
SideEffects: &noSideEffect,
|
||||
TimeoutSeconds: int32Ptr(15),
|
||||
TimeoutSeconds: ptr.To[int32](15),
|
||||
}, {
|
||||
Name: "webhook3.k8s.io",
|
||||
ClientConfig: validClientConfig,
|
||||
SideEffects: &noSideEffect,
|
||||
TimeoutSeconds: int32Ptr(30),
|
||||
TimeoutSeconds: ptr.To[int32](30),
|
||||
},
|
||||
}, true),
|
||||
}, {
|
||||
@@ -1818,7 +1813,7 @@ func TestValidateMutatingWebhookConfigurationUpdate(t *testing.T) {
|
||||
unknownSideEffect := admissionregistration.SideEffectClassUnknown
|
||||
noSideEffect := admissionregistration.SideEffectClassNone
|
||||
validClientConfig := admissionregistration.WebhookClientConfig{
|
||||
URL: strPtr("https://example.com"),
|
||||
URL: ptr.To("https://example.com"),
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -3532,7 +3527,7 @@ func TestValidateValidatingAdmissionPolicyBinding(t *testing.T) {
|
||||
PolicyName: "xyzlimit-scale.example.com",
|
||||
ParamRef: &admissionregistration.ParamRef{
|
||||
Name: "xyzlimit-scale-setting.example.com",
|
||||
ParameterNotFoundAction: ptr(admissionregistration.DenyAction),
|
||||
ParameterNotFoundAction: ptr.To(admissionregistration.DenyAction),
|
||||
},
|
||||
MatchResources: &admissionregistration.MatchResources{
|
||||
MatchPolicy: func() *admissionregistration.MatchPolicyType {
|
||||
@@ -3553,7 +3548,7 @@ func TestValidateValidatingAdmissionPolicyBinding(t *testing.T) {
|
||||
PolicyName: "xyzlimit-scale.example.com",
|
||||
ParamRef: &admissionregistration.ParamRef{
|
||||
Name: "xyzlimit-scale-setting.example.com",
|
||||
ParameterNotFoundAction: ptr(admissionregistration.DenyAction),
|
||||
ParameterNotFoundAction: ptr.To(admissionregistration.DenyAction),
|
||||
},
|
||||
MatchResources: &admissionregistration.MatchResources{
|
||||
ResourceRules: []admissionregistration.NamedRuleWithOperations{{
|
||||
@@ -3608,7 +3603,7 @@ func TestValidateValidatingAdmissionPolicyBinding(t *testing.T) {
|
||||
PolicyName: "xyzlimit-scale.example.com",
|
||||
ParamRef: &admissionregistration.ParamRef{
|
||||
Name: "xyzlimit-scale-setting.example.com",
|
||||
ParameterNotFoundAction: ptr(admissionregistration.DenyAction),
|
||||
ParameterNotFoundAction: ptr.To(admissionregistration.DenyAction),
|
||||
}, MatchResources: &admissionregistration.MatchResources{
|
||||
ResourceRules: []admissionregistration.NamedRuleWithOperations{{
|
||||
RuleWithOperations: admissionregistration.RuleWithOperations{
|
||||
@@ -3634,7 +3629,7 @@ func TestValidateValidatingAdmissionPolicyBinding(t *testing.T) {
|
||||
PolicyName: "xyzlimit-scale.example.com",
|
||||
ParamRef: &admissionregistration.ParamRef{
|
||||
Name: "xyzlimit-scale-setting.example.com",
|
||||
ParameterNotFoundAction: ptr(admissionregistration.DenyAction),
|
||||
ParameterNotFoundAction: ptr.To(admissionregistration.DenyAction),
|
||||
}, MatchResources: &admissionregistration.MatchResources{
|
||||
ResourceRules: []admissionregistration.NamedRuleWithOperations{{
|
||||
RuleWithOperations: admissionregistration.RuleWithOperations{
|
||||
@@ -3660,7 +3655,7 @@ func TestValidateValidatingAdmissionPolicyBinding(t *testing.T) {
|
||||
PolicyName: "xyzlimit-scale.example.com",
|
||||
ParamRef: &admissionregistration.ParamRef{
|
||||
Name: "xyzlimit-scale-setting.example.com",
|
||||
ParameterNotFoundAction: ptr(admissionregistration.DenyAction),
|
||||
ParameterNotFoundAction: ptr.To(admissionregistration.DenyAction),
|
||||
},
|
||||
ValidationActions: []admissionregistration.ValidationAction{admissionregistration.Deny},
|
||||
MatchResources: &admissionregistration.MatchResources{
|
||||
@@ -3688,7 +3683,7 @@ func TestValidateValidatingAdmissionPolicyBinding(t *testing.T) {
|
||||
PolicyName: "xyzlimit-scale.example.com",
|
||||
ParamRef: &admissionregistration.ParamRef{
|
||||
Name: "xyzlimit-scale-setting.example.com",
|
||||
ParameterNotFoundAction: ptr(admissionregistration.DenyAction),
|
||||
ParameterNotFoundAction: ptr.To(admissionregistration.DenyAction),
|
||||
},
|
||||
ValidationActions: []admissionregistration.ValidationAction{admissionregistration.Deny},
|
||||
MatchResources: &admissionregistration.MatchResources{
|
||||
@@ -3725,7 +3720,7 @@ func TestValidateValidatingAdmissionPolicyBinding(t *testing.T) {
|
||||
PolicyName: "xyzlimit-scale.example.com",
|
||||
ParamRef: &admissionregistration.ParamRef{
|
||||
Name: "xyzlimit-scale-setting.example.com",
|
||||
ParameterNotFoundAction: ptr(admissionregistration.DenyAction),
|
||||
ParameterNotFoundAction: ptr.To(admissionregistration.DenyAction),
|
||||
},
|
||||
ValidationActions: []admissionregistration.ValidationAction{admissionregistration.Deny},
|
||||
MatchResources: &admissionregistration.MatchResources{
|
||||
@@ -3753,7 +3748,7 @@ func TestValidateValidatingAdmissionPolicyBinding(t *testing.T) {
|
||||
PolicyName: "xyzlimit-scale.example.com",
|
||||
ParamRef: &admissionregistration.ParamRef{
|
||||
Name: "xyzlimit-scale-setting.example.com",
|
||||
ParameterNotFoundAction: ptr(admissionregistration.DenyAction),
|
||||
ParameterNotFoundAction: ptr.To(admissionregistration.DenyAction),
|
||||
},
|
||||
ValidationActions: []admissionregistration.ValidationAction{admissionregistration.Deny},
|
||||
MatchResources: &admissionregistration.MatchResources{
|
||||
@@ -3781,7 +3776,7 @@ func TestValidateValidatingAdmissionPolicyBinding(t *testing.T) {
|
||||
PolicyName: "xyzlimit-scale.example.com",
|
||||
ParamRef: &admissionregistration.ParamRef{
|
||||
Name: "xyzlimit-scale-setting.example.com",
|
||||
ParameterNotFoundAction: ptr(admissionregistration.DenyAction),
|
||||
ParameterNotFoundAction: ptr.To(admissionregistration.DenyAction),
|
||||
},
|
||||
ValidationActions: []admissionregistration.ValidationAction{admissionregistration.Deny},
|
||||
MatchResources: &admissionregistration.MatchResources{
|
||||
@@ -3818,7 +3813,7 @@ func TestValidateValidatingAdmissionPolicyBinding(t *testing.T) {
|
||||
PolicyName: "xyzlimit-scale.example.com",
|
||||
ParamRef: &admissionregistration.ParamRef{
|
||||
Name: "xyzlimit-scale-setting.example.com",
|
||||
ParameterNotFoundAction: ptr(admissionregistration.DenyAction),
|
||||
ParameterNotFoundAction: ptr.To(admissionregistration.DenyAction),
|
||||
},
|
||||
ValidationActions: []admissionregistration.ValidationAction{admissionregistration.Deny},
|
||||
MatchResources: &admissionregistration.MatchResources{
|
||||
@@ -3846,7 +3841,7 @@ func TestValidateValidatingAdmissionPolicyBinding(t *testing.T) {
|
||||
PolicyName: "xyzlimit-scale.example.com",
|
||||
ParamRef: &admissionregistration.ParamRef{
|
||||
Name: "xyzlimit-scale-setting.example.com",
|
||||
ParameterNotFoundAction: ptr(admissionregistration.DenyAction),
|
||||
ParameterNotFoundAction: ptr.To(admissionregistration.DenyAction),
|
||||
},
|
||||
ValidationActions: []admissionregistration.ValidationAction{admissionregistration.Deny},
|
||||
MatchResources: &admissionregistration.MatchResources{
|
||||
@@ -3874,7 +3869,7 @@ func TestValidateValidatingAdmissionPolicyBinding(t *testing.T) {
|
||||
PolicyName: "xyzlimit-scale.example.com",
|
||||
ParamRef: &admissionregistration.ParamRef{
|
||||
Name: "xyzlimit-scale-setting.example.com",
|
||||
ParameterNotFoundAction: ptr(admissionregistration.DenyAction),
|
||||
ParameterNotFoundAction: ptr.To(admissionregistration.DenyAction),
|
||||
},
|
||||
ValidationActions: []admissionregistration.ValidationAction{admissionregistration.Deny, admissionregistration.Deny},
|
||||
},
|
||||
@@ -3890,7 +3885,7 @@ func TestValidateValidatingAdmissionPolicyBinding(t *testing.T) {
|
||||
PolicyName: "xyzlimit-scale.example.com",
|
||||
ParamRef: &admissionregistration.ParamRef{
|
||||
Name: "xyzlimit-scale-setting.example.com",
|
||||
ParameterNotFoundAction: ptr(admissionregistration.DenyAction),
|
||||
ParameterNotFoundAction: ptr.To(admissionregistration.DenyAction),
|
||||
},
|
||||
ValidationActions: []admissionregistration.ValidationAction{admissionregistration.ValidationAction("illegal")},
|
||||
},
|
||||
@@ -3912,7 +3907,7 @@ func TestValidateValidatingAdmissionPolicyBinding(t *testing.T) {
|
||||
"label": "value",
|
||||
},
|
||||
},
|
||||
ParameterNotFoundAction: ptr(admissionregistration.DenyAction),
|
||||
ParameterNotFoundAction: ptr.To(admissionregistration.DenyAction),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -3943,7 +3938,7 @@ func TestValidateValidatingAdmissionPolicyBinding(t *testing.T) {
|
||||
ValidationActions: []admissionregistration.ValidationAction{admissionregistration.Deny},
|
||||
ParamRef: &admissionregistration.ParamRef{
|
||||
Name: "xyzlimit-scale-setting.example.com",
|
||||
ParameterNotFoundAction: ptr(admissionregistration.ParameterNotFoundActionType("invalid")),
|
||||
ParameterNotFoundAction: ptr.To(admissionregistration.ParameterNotFoundActionType("invalid")),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -3958,7 +3953,7 @@ func TestValidateValidatingAdmissionPolicyBinding(t *testing.T) {
|
||||
PolicyName: "xyzlimit-scale.example.com",
|
||||
ValidationActions: []admissionregistration.ValidationAction{admissionregistration.Deny},
|
||||
ParamRef: &admissionregistration.ParamRef{
|
||||
ParameterNotFoundAction: ptr(admissionregistration.DenyAction),
|
||||
ParameterNotFoundAction: ptr.To(admissionregistration.DenyAction),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -3998,7 +3993,7 @@ func TestValidateValidatingAdmissionPolicyBindingUpdate(t *testing.T) {
|
||||
PolicyName: "xyzlimit-scale.example.com",
|
||||
ParamRef: &admissionregistration.ParamRef{
|
||||
Name: "xyzlimit-scale-setting.example.com",
|
||||
ParameterNotFoundAction: ptr(admissionregistration.DenyAction),
|
||||
ParameterNotFoundAction: ptr.To(admissionregistration.DenyAction),
|
||||
},
|
||||
ValidationActions: []admissionregistration.ValidationAction{admissionregistration.Deny},
|
||||
MatchResources: &admissionregistration.MatchResources{
|
||||
@@ -4033,7 +4028,7 @@ func TestValidateValidatingAdmissionPolicyBindingUpdate(t *testing.T) {
|
||||
PolicyName: "xyzlimit-scale.example.com",
|
||||
ParamRef: &admissionregistration.ParamRef{
|
||||
Name: "xyzlimit-scale-setting.example.com",
|
||||
ParameterNotFoundAction: ptr(admissionregistration.DenyAction),
|
||||
ParameterNotFoundAction: ptr.To(admissionregistration.DenyAction),
|
||||
},
|
||||
ValidationActions: []admissionregistration.ValidationAction{admissionregistration.Deny},
|
||||
MatchResources: &admissionregistration.MatchResources{
|
||||
@@ -4070,7 +4065,7 @@ func TestValidateValidatingAdmissionPolicyBindingUpdate(t *testing.T) {
|
||||
PolicyName: "xyzlimit-scale.example.com",
|
||||
ParamRef: &admissionregistration.ParamRef{
|
||||
Name: "xyzlimit-scale-setting.example.com",
|
||||
ParameterNotFoundAction: ptr(admissionregistration.DenyAction),
|
||||
ParameterNotFoundAction: ptr.To(admissionregistration.DenyAction),
|
||||
},
|
||||
ValidationActions: []admissionregistration.ValidationAction{admissionregistration.Deny},
|
||||
MatchResources: &admissionregistration.MatchResources{
|
||||
|
||||
Reference in New Issue
Block a user