experimental. -> extensions.
This commit is contained in:
@@ -51,7 +51,7 @@ func ValidateHorizontalPodAutoscalerName(name string, prefix bool) (bool, string
|
||||
return apivalidation.ValidateReplicationControllerName(name, prefix)
|
||||
}
|
||||
|
||||
func validateHorizontalPodAutoscalerSpec(autoscaler experimental.HorizontalPodAutoscalerSpec) errs.ValidationErrorList {
|
||||
func validateHorizontalPodAutoscalerSpec(autoscaler extensions.HorizontalPodAutoscalerSpec) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
if autoscaler.MinReplicas < 0 {
|
||||
allErrs = append(allErrs, errs.NewFieldInvalid("minReplicas", autoscaler.MinReplicas, isNegativeErrorMsg))
|
||||
@@ -73,25 +73,25 @@ func validateHorizontalPodAutoscalerSpec(autoscaler experimental.HorizontalPodAu
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateHorizontalPodAutoscaler(autoscaler *experimental.HorizontalPodAutoscaler) errs.ValidationErrorList {
|
||||
func ValidateHorizontalPodAutoscaler(autoscaler *extensions.HorizontalPodAutoscaler) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
allErrs = append(allErrs, apivalidation.ValidateObjectMeta(&autoscaler.ObjectMeta, true, ValidateHorizontalPodAutoscalerName).Prefix("metadata")...)
|
||||
allErrs = append(allErrs, validateHorizontalPodAutoscalerSpec(autoscaler.Spec)...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateHorizontalPodAutoscalerUpdate(newAutoscler, oldAutoscaler *experimental.HorizontalPodAutoscaler) errs.ValidationErrorList {
|
||||
func ValidateHorizontalPodAutoscalerUpdate(newAutoscler, oldAutoscaler *extensions.HorizontalPodAutoscaler) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&newAutoscler.ObjectMeta, &oldAutoscaler.ObjectMeta).Prefix("metadata")...)
|
||||
allErrs = append(allErrs, validateHorizontalPodAutoscalerSpec(newAutoscler.Spec)...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateThirdPartyResourceUpdate(old, update *experimental.ThirdPartyResource) errs.ValidationErrorList {
|
||||
func ValidateThirdPartyResourceUpdate(old, update *extensions.ThirdPartyResource) errs.ValidationErrorList {
|
||||
return ValidateThirdPartyResource(update)
|
||||
}
|
||||
|
||||
func ValidateThirdPartyResource(obj *experimental.ThirdPartyResource) errs.ValidationErrorList {
|
||||
func ValidateThirdPartyResource(obj *extensions.ThirdPartyResource) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
if len(obj.Name) == 0 {
|
||||
allErrs = append(allErrs, errs.NewFieldInvalid("name", obj.Name, "name must be non-empty"))
|
||||
@@ -111,7 +111,7 @@ func ValidateThirdPartyResource(obj *experimental.ThirdPartyResource) errs.Valid
|
||||
}
|
||||
|
||||
// ValidateDaemonSet tests if required fields in the DaemonSet are set.
|
||||
func ValidateDaemonSet(controller *experimental.DaemonSet) errs.ValidationErrorList {
|
||||
func ValidateDaemonSet(controller *extensions.DaemonSet) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
allErrs = append(allErrs, apivalidation.ValidateObjectMeta(&controller.ObjectMeta, true, apivalidation.ValidateReplicationControllerName).Prefix("metadata")...)
|
||||
allErrs = append(allErrs, ValidateDaemonSetSpec(&controller.Spec).Prefix("spec")...)
|
||||
@@ -119,7 +119,7 @@ func ValidateDaemonSet(controller *experimental.DaemonSet) errs.ValidationErrorL
|
||||
}
|
||||
|
||||
// ValidateDaemonSetUpdate tests if required fields in the DaemonSet are set.
|
||||
func ValidateDaemonSetUpdate(oldController, controller *experimental.DaemonSet) errs.ValidationErrorList {
|
||||
func ValidateDaemonSetUpdate(oldController, controller *extensions.DaemonSet) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&controller.ObjectMeta, &oldController.ObjectMeta).Prefix("metadata")...)
|
||||
allErrs = append(allErrs, ValidateDaemonSetSpec(&controller.Spec).Prefix("spec")...)
|
||||
@@ -128,7 +128,7 @@ func ValidateDaemonSetUpdate(oldController, controller *experimental.DaemonSet)
|
||||
}
|
||||
|
||||
// validateDaemonSetStatus validates a DaemonSetStatus
|
||||
func validateDaemonSetStatus(status *experimental.DaemonSetStatus) errs.ValidationErrorList {
|
||||
func validateDaemonSetStatus(status *extensions.DaemonSetStatus) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
allErrs = append(allErrs, apivalidation.ValidatePositiveField(int64(status.CurrentNumberScheduled), "currentNumberScheduled")...)
|
||||
allErrs = append(allErrs, apivalidation.ValidatePositiveField(int64(status.NumberMisscheduled), "numberMisscheduled")...)
|
||||
@@ -137,7 +137,7 @@ func validateDaemonSetStatus(status *experimental.DaemonSetStatus) errs.Validati
|
||||
}
|
||||
|
||||
// ValidateDaemonSetStatus validates tests if required fields in the DaemonSet Status section
|
||||
func ValidateDaemonSetStatusUpdate(controller, oldController *experimental.DaemonSet) errs.ValidationErrorList {
|
||||
func ValidateDaemonSetStatusUpdate(controller, oldController *extensions.DaemonSet) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&controller.ObjectMeta, &oldController.ObjectMeta).Prefix("metadata")...)
|
||||
allErrs = append(allErrs, validateDaemonSetStatus(&controller.Status)...)
|
||||
@@ -160,7 +160,7 @@ func ValidateDaemonSetTemplateUpdate(oldPodTemplate, podTemplate *api.PodTemplat
|
||||
}
|
||||
|
||||
// ValidateDaemonSetSpec tests if required fields in the DaemonSetSpec are set.
|
||||
func ValidateDaemonSetSpec(spec *experimental.DaemonSetSpec) errs.ValidationErrorList {
|
||||
func ValidateDaemonSetSpec(spec *extensions.DaemonSetSpec) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
|
||||
selector := labels.Set(spec.Selector).AsSelector()
|
||||
@@ -237,7 +237,7 @@ func IsNotMoreThan100Percent(intOrStringValue util.IntOrString, fieldName string
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateRollingUpdateDeployment(rollingUpdate *experimental.RollingUpdateDeployment, fieldName string) errs.ValidationErrorList {
|
||||
func ValidateRollingUpdateDeployment(rollingUpdate *extensions.RollingUpdateDeployment, fieldName string) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
allErrs = append(allErrs, ValidatePositiveIntOrPercent(rollingUpdate.MaxUnavailable, fieldName+"maxUnavailable")...)
|
||||
allErrs = append(allErrs, ValidatePositiveIntOrPercent(rollingUpdate.MaxSurge, fieldName+".maxSurge")...)
|
||||
@@ -251,22 +251,22 @@ func ValidateRollingUpdateDeployment(rollingUpdate *experimental.RollingUpdateDe
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateDeploymentStrategy(strategy *experimental.DeploymentStrategy, fieldName string) errs.ValidationErrorList {
|
||||
func ValidateDeploymentStrategy(strategy *extensions.DeploymentStrategy, fieldName string) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
if strategy.RollingUpdate == nil {
|
||||
return allErrs
|
||||
}
|
||||
switch strategy.Type {
|
||||
case experimental.RecreateDeploymentStrategyType:
|
||||
allErrs = append(allErrs, errs.NewFieldForbidden("rollingUpdate", "rollingUpdate should be nil when strategy type is "+experimental.RecreateDeploymentStrategyType))
|
||||
case experimental.RollingUpdateDeploymentStrategyType:
|
||||
case extensions.RecreateDeploymentStrategyType:
|
||||
allErrs = append(allErrs, errs.NewFieldForbidden("rollingUpdate", "rollingUpdate should be nil when strategy type is "+extensions.RecreateDeploymentStrategyType))
|
||||
case extensions.RollingUpdateDeploymentStrategyType:
|
||||
allErrs = append(allErrs, ValidateRollingUpdateDeployment(strategy.RollingUpdate, "rollingUpdate")...)
|
||||
}
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// Validates given deployment spec.
|
||||
func ValidateDeploymentSpec(spec *experimental.DeploymentSpec) errs.ValidationErrorList {
|
||||
func ValidateDeploymentSpec(spec *extensions.DeploymentSpec) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
allErrs = append(allErrs, apivalidation.ValidateNonEmptySelector(spec.Selector, "selector")...)
|
||||
allErrs = append(allErrs, apivalidation.ValidatePositiveField(int64(spec.Replicas), "replicas")...)
|
||||
@@ -276,25 +276,25 @@ func ValidateDeploymentSpec(spec *experimental.DeploymentSpec) errs.ValidationEr
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateDeploymentUpdate(old, update *experimental.Deployment) errs.ValidationErrorList {
|
||||
func ValidateDeploymentUpdate(old, update *extensions.Deployment) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&update.ObjectMeta, &old.ObjectMeta).Prefix("metadata")...)
|
||||
allErrs = append(allErrs, ValidateDeploymentSpec(&update.Spec).Prefix("spec")...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateDeployment(obj *experimental.Deployment) errs.ValidationErrorList {
|
||||
func ValidateDeployment(obj *extensions.Deployment) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
allErrs = append(allErrs, apivalidation.ValidateObjectMeta(&obj.ObjectMeta, true, ValidateDeploymentName).Prefix("metadata")...)
|
||||
allErrs = append(allErrs, ValidateDeploymentSpec(&obj.Spec).Prefix("spec")...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateThirdPartyResourceDataUpdate(old, update *experimental.ThirdPartyResourceData) errs.ValidationErrorList {
|
||||
func ValidateThirdPartyResourceDataUpdate(old, update *extensions.ThirdPartyResourceData) errs.ValidationErrorList {
|
||||
return ValidateThirdPartyResourceData(update)
|
||||
}
|
||||
|
||||
func ValidateThirdPartyResourceData(obj *experimental.ThirdPartyResourceData) errs.ValidationErrorList {
|
||||
func ValidateThirdPartyResourceData(obj *extensions.ThirdPartyResourceData) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
if len(obj.Name) == 0 {
|
||||
allErrs = append(allErrs, errs.NewFieldInvalid("name", obj.Name, "name must be non-empty"))
|
||||
@@ -302,7 +302,7 @@ func ValidateThirdPartyResourceData(obj *experimental.ThirdPartyResourceData) er
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateJob(job *experimental.Job) errs.ValidationErrorList {
|
||||
func ValidateJob(job *extensions.Job) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
// Jobs and rcs have the same name validation
|
||||
allErrs = append(allErrs, apivalidation.ValidateObjectMeta(&job.ObjectMeta, true, apivalidation.ValidateReplicationControllerName).Prefix("metadata")...)
|
||||
@@ -310,7 +310,7 @@ func ValidateJob(job *experimental.Job) errs.ValidationErrorList {
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateJobSpec(spec *experimental.JobSpec) errs.ValidationErrorList {
|
||||
func ValidateJobSpec(spec *extensions.JobSpec) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
|
||||
if spec.Parallelism != nil && *spec.Parallelism < 0 {
|
||||
@@ -342,7 +342,7 @@ func ValidateJobSpec(spec *experimental.JobSpec) errs.ValidationErrorList {
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateJobStatus(status *experimental.JobStatus) errs.ValidationErrorList {
|
||||
func ValidateJobStatus(status *extensions.JobStatus) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
allErrs = append(allErrs, apivalidation.ValidatePositiveField(int64(status.Active), "active")...)
|
||||
allErrs = append(allErrs, apivalidation.ValidatePositiveField(int64(status.Succeeded), "succeeded")...)
|
||||
@@ -350,21 +350,21 @@ func ValidateJobStatus(status *experimental.JobStatus) errs.ValidationErrorList
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateJobUpdate(oldJob, job *experimental.Job) errs.ValidationErrorList {
|
||||
func ValidateJobUpdate(oldJob, job *extensions.Job) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&oldJob.ObjectMeta, &job.ObjectMeta).Prefix("metadata")...)
|
||||
allErrs = append(allErrs, ValidateJobSpecUpdate(oldJob.Spec, job.Spec).Prefix("spec")...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateJobUpdateStatus(oldJob, job *experimental.Job) errs.ValidationErrorList {
|
||||
func ValidateJobUpdateStatus(oldJob, job *extensions.Job) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&oldJob.ObjectMeta, &job.ObjectMeta).Prefix("metadata")...)
|
||||
allErrs = append(allErrs, ValidateJobStatusUpdate(oldJob.Status, job.Status).Prefix("status")...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateJobSpecUpdate(oldSpec, spec experimental.JobSpec) errs.ValidationErrorList {
|
||||
func ValidateJobSpecUpdate(oldSpec, spec extensions.JobSpec) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
allErrs = append(allErrs, ValidateJobSpec(&spec)...)
|
||||
if !api.Semantic.DeepEqual(oldSpec.Completions, spec.Completions) {
|
||||
@@ -379,14 +379,14 @@ func ValidateJobSpecUpdate(oldSpec, spec experimental.JobSpec) errs.ValidationEr
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateJobStatusUpdate(oldStatus, status experimental.JobStatus) errs.ValidationErrorList {
|
||||
func ValidateJobStatusUpdate(oldStatus, status extensions.JobStatus) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
allErrs = append(allErrs, ValidateJobStatus(&status)...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// ValidateIngress tests if required fields in the Ingress are set.
|
||||
func ValidateIngress(ingress *experimental.Ingress) errs.ValidationErrorList {
|
||||
func ValidateIngress(ingress *extensions.Ingress) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
allErrs = append(allErrs, apivalidation.ValidateObjectMeta(&ingress.ObjectMeta, true, ValidateIngressName).Prefix("metadata")...)
|
||||
allErrs = append(allErrs, ValidateIngressSpec(&ingress.Spec).Prefix("spec")...)
|
||||
@@ -399,7 +399,7 @@ func ValidateIngressName(name string, prefix bool) (bool, string) {
|
||||
}
|
||||
|
||||
// ValidateIngressSpec tests if required fields in the IngressSpec are set.
|
||||
func ValidateIngressSpec(spec *experimental.IngressSpec) errs.ValidationErrorList {
|
||||
func ValidateIngressSpec(spec *extensions.IngressSpec) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
// TODO: Is a default backend mandatory?
|
||||
if spec.Backend != nil {
|
||||
@@ -414,14 +414,14 @@ func ValidateIngressSpec(spec *experimental.IngressSpec) errs.ValidationErrorLis
|
||||
}
|
||||
|
||||
// ValidateIngressUpdate tests if required fields in the Ingress are set.
|
||||
func ValidateIngressUpdate(oldIngress, ingress *experimental.Ingress) errs.ValidationErrorList {
|
||||
func ValidateIngressUpdate(oldIngress, ingress *extensions.Ingress) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&ingress.ObjectMeta, &oldIngress.ObjectMeta).Prefix("metadata")...)
|
||||
allErrs = append(allErrs, ValidateIngressSpec(&ingress.Spec).Prefix("spec")...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func validateIngressRules(IngressRules []experimental.IngressRule) errs.ValidationErrorList {
|
||||
func validateIngressRules(IngressRules []extensions.IngressRule) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
if len(IngressRules) == 0 {
|
||||
return append(allErrs, errs.NewFieldRequired("IngressRules"))
|
||||
@@ -442,7 +442,7 @@ func validateIngressRules(IngressRules []experimental.IngressRule) errs.Validati
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func validateIngressRuleValue(ingressRule *experimental.IngressRuleValue) errs.ValidationErrorList {
|
||||
func validateIngressRuleValue(ingressRule *extensions.IngressRuleValue) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
if ingressRule.HTTP != nil {
|
||||
allErrs = append(allErrs, validateHTTPIngressRuleValue(ingressRule.HTTP).Prefix("http")...)
|
||||
@@ -450,7 +450,7 @@ func validateIngressRuleValue(ingressRule *experimental.IngressRuleValue) errs.V
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func validateHTTPIngressRuleValue(httpIngressRuleValue *experimental.HTTPIngressRuleValue) errs.ValidationErrorList {
|
||||
func validateHTTPIngressRuleValue(httpIngressRuleValue *extensions.HTTPIngressRuleValue) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
if len(httpIngressRuleValue.Paths) == 0 {
|
||||
allErrs = append(allErrs, errs.NewFieldRequired("paths"))
|
||||
@@ -480,7 +480,7 @@ func validateHTTPIngressRuleValue(httpIngressRuleValue *experimental.HTTPIngress
|
||||
}
|
||||
|
||||
// validateIngressBackend tests if a given backend is valid.
|
||||
func validateIngressBackend(backend *experimental.IngressBackend) errs.ValidationErrorList {
|
||||
func validateIngressBackend(backend *extensions.IngressBackend) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
|
||||
// All backends must reference a single local service by name, and a single service port by name or number.
|
||||
@@ -502,7 +502,7 @@ func validateIngressBackend(backend *experimental.IngressBackend) errs.Validatio
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func validateClusterAutoscalerSpec(spec experimental.ClusterAutoscalerSpec) errs.ValidationErrorList {
|
||||
func validateClusterAutoscalerSpec(spec extensions.ClusterAutoscalerSpec) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
if spec.MinNodes < 0 {
|
||||
allErrs = append(allErrs, errs.NewFieldInvalid("minNodes", spec.MinNodes, `must be non-negative`))
|
||||
@@ -527,7 +527,7 @@ func validateClusterAutoscalerSpec(spec experimental.ClusterAutoscalerSpec) errs
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func ValidateClusterAutoscaler(autoscaler *experimental.ClusterAutoscaler) errs.ValidationErrorList {
|
||||
func ValidateClusterAutoscaler(autoscaler *extensions.ClusterAutoscaler) errs.ValidationErrorList {
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
if autoscaler.Name != "ClusterAutoscaler" {
|
||||
allErrs = append(allErrs, errs.NewFieldInvalid("name", autoscaler.Name, `name must be ClusterAutoscaler`))
|
||||
|
@@ -29,19 +29,19 @@ import (
|
||||
)
|
||||
|
||||
func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
successCases := []experimental.HorizontalPodAutoscaler{
|
||||
successCases := []extensions.HorizontalPodAutoscaler{
|
||||
{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "myautoscaler",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: experimental.HorizontalPodAutoscalerSpec{
|
||||
ScaleRef: &experimental.SubresourceReference{
|
||||
Spec: extensions.HorizontalPodAutoscalerSpec{
|
||||
ScaleRef: &extensions.SubresourceReference{
|
||||
Subresource: "scale",
|
||||
},
|
||||
MinReplicas: 1,
|
||||
MaxReplicas: 5,
|
||||
Target: experimental.ResourceConsumption{Resource: api.ResourceCPU, Quantity: resource.MustParse("0.8")},
|
||||
Target: extensions.ResourceConsumption{Resource: api.ResourceCPU, Quantity: resource.MustParse("0.8")},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -51,19 +51,19 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
errorCases := map[string]experimental.HorizontalPodAutoscaler{
|
||||
errorCases := map[string]extensions.HorizontalPodAutoscaler{
|
||||
"must be non-negative": {
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "myautoscaler",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: experimental.HorizontalPodAutoscalerSpec{
|
||||
ScaleRef: &experimental.SubresourceReference{
|
||||
Spec: extensions.HorizontalPodAutoscalerSpec{
|
||||
ScaleRef: &extensions.SubresourceReference{
|
||||
Subresource: "scale",
|
||||
},
|
||||
MinReplicas: -1,
|
||||
MaxReplicas: 5,
|
||||
Target: experimental.ResourceConsumption{Resource: api.ResourceCPU, Quantity: resource.MustParse("0.8")},
|
||||
Target: extensions.ResourceConsumption{Resource: api.ResourceCPU, Quantity: resource.MustParse("0.8")},
|
||||
},
|
||||
},
|
||||
"must be bigger or equal to minReplicas": {
|
||||
@@ -71,13 +71,13 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
Name: "myautoscaler",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: experimental.HorizontalPodAutoscalerSpec{
|
||||
ScaleRef: &experimental.SubresourceReference{
|
||||
Spec: extensions.HorizontalPodAutoscalerSpec{
|
||||
ScaleRef: &extensions.SubresourceReference{
|
||||
Subresource: "scale",
|
||||
},
|
||||
MinReplicas: 7,
|
||||
MaxReplicas: 5,
|
||||
Target: experimental.ResourceConsumption{Resource: api.ResourceCPU, Quantity: resource.MustParse("0.8")},
|
||||
Target: extensions.ResourceConsumption{Resource: api.ResourceCPU, Quantity: resource.MustParse("0.8")},
|
||||
},
|
||||
},
|
||||
"invalid value": {
|
||||
@@ -85,13 +85,13 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
Name: "myautoscaler",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: experimental.HorizontalPodAutoscalerSpec{
|
||||
ScaleRef: &experimental.SubresourceReference{
|
||||
Spec: extensions.HorizontalPodAutoscalerSpec{
|
||||
ScaleRef: &extensions.SubresourceReference{
|
||||
Subresource: "scale",
|
||||
},
|
||||
MinReplicas: 1,
|
||||
MaxReplicas: 5,
|
||||
Target: experimental.ResourceConsumption{Resource: api.ResourceCPU, Quantity: resource.MustParse("-0.8")},
|
||||
Target: extensions.ResourceConsumption{Resource: api.ResourceCPU, Quantity: resource.MustParse("-0.8")},
|
||||
},
|
||||
},
|
||||
"resource not supported": {
|
||||
@@ -99,13 +99,13 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
Name: "myautoscaler",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: experimental.HorizontalPodAutoscalerSpec{
|
||||
ScaleRef: &experimental.SubresourceReference{
|
||||
Spec: extensions.HorizontalPodAutoscalerSpec{
|
||||
ScaleRef: &extensions.SubresourceReference{
|
||||
Subresource: "scale",
|
||||
},
|
||||
MinReplicas: 1,
|
||||
MaxReplicas: 5,
|
||||
Target: experimental.ResourceConsumption{Resource: api.ResourceName("NotSupportedResource"), Quantity: resource.MustParse("0.8")},
|
||||
Target: extensions.ResourceConsumption{Resource: api.ResourceName("NotSupportedResource"), Quantity: resource.MustParse("0.8")},
|
||||
},
|
||||
},
|
||||
"required value": {
|
||||
@@ -113,10 +113,10 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
Name: "myautoscaler",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: experimental.HorizontalPodAutoscalerSpec{
|
||||
Spec: extensions.HorizontalPodAutoscalerSpec{
|
||||
MinReplicas: 1,
|
||||
MaxReplicas: 5,
|
||||
Target: experimental.ResourceConsumption{Resource: api.ResourceCPU, Quantity: resource.MustParse("0.8")},
|
||||
Target: extensions.ResourceConsumption{Resource: api.ResourceCPU, Quantity: resource.MustParse("0.8")},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -133,23 +133,23 @@ func TestValidateHorizontalPodAutoscaler(t *testing.T) {
|
||||
|
||||
func TestValidateDaemonSetStatusUpdate(t *testing.T) {
|
||||
type dsUpdateTest struct {
|
||||
old experimental.DaemonSet
|
||||
update experimental.DaemonSet
|
||||
old extensions.DaemonSet
|
||||
update extensions.DaemonSet
|
||||
}
|
||||
|
||||
successCases := []dsUpdateTest{
|
||||
{
|
||||
old: experimental.DaemonSet{
|
||||
old: extensions.DaemonSet{
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
Status: experimental.DaemonSetStatus{
|
||||
Status: extensions.DaemonSetStatus{
|
||||
CurrentNumberScheduled: 1,
|
||||
NumberMisscheduled: 2,
|
||||
DesiredNumberScheduled: 3,
|
||||
},
|
||||
},
|
||||
update: experimental.DaemonSet{
|
||||
update: extensions.DaemonSet{
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
Status: experimental.DaemonSetStatus{
|
||||
Status: extensions.DaemonSetStatus{
|
||||
CurrentNumberScheduled: 1,
|
||||
NumberMisscheduled: 1,
|
||||
DesiredNumberScheduled: 3,
|
||||
@@ -168,17 +168,17 @@ func TestValidateDaemonSetStatusUpdate(t *testing.T) {
|
||||
|
||||
errorCases := map[string]dsUpdateTest{
|
||||
"negative values": {
|
||||
old: experimental.DaemonSet{
|
||||
old: extensions.DaemonSet{
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
Status: experimental.DaemonSetStatus{
|
||||
Status: extensions.DaemonSetStatus{
|
||||
CurrentNumberScheduled: 1,
|
||||
NumberMisscheduled: 2,
|
||||
DesiredNumberScheduled: 3,
|
||||
},
|
||||
},
|
||||
update: experimental.DaemonSet{
|
||||
update: extensions.DaemonSet{
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
Status: experimental.DaemonSetStatus{
|
||||
Status: extensions.DaemonSetStatus{
|
||||
CurrentNumberScheduled: -1,
|
||||
NumberMisscheduled: -1,
|
||||
DesiredNumberScheduled: -3,
|
||||
@@ -277,53 +277,53 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
|
||||
}
|
||||
|
||||
type dsUpdateTest struct {
|
||||
old experimental.DaemonSet
|
||||
update experimental.DaemonSet
|
||||
old extensions.DaemonSet
|
||||
update extensions.DaemonSet
|
||||
}
|
||||
successCases := []dsUpdateTest{
|
||||
{
|
||||
old: experimental.DaemonSet{
|
||||
old: extensions.DaemonSet{
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
Spec: experimental.DaemonSetSpec{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: validSelector,
|
||||
Template: &validPodTemplateAbc.Template,
|
||||
},
|
||||
},
|
||||
update: experimental.DaemonSet{
|
||||
update: extensions.DaemonSet{
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
Spec: experimental.DaemonSetSpec{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: validSelector,
|
||||
Template: &validPodTemplateAbc.Template,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
old: experimental.DaemonSet{
|
||||
old: extensions.DaemonSet{
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
Spec: experimental.DaemonSetSpec{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: validSelector,
|
||||
Template: &validPodTemplateAbc.Template,
|
||||
},
|
||||
},
|
||||
update: experimental.DaemonSet{
|
||||
update: extensions.DaemonSet{
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
Spec: experimental.DaemonSetSpec{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: validSelector2,
|
||||
Template: &validPodTemplateAbc2.Template,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
old: experimental.DaemonSet{
|
||||
old: extensions.DaemonSet{
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
Spec: experimental.DaemonSetSpec{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: validSelector,
|
||||
Template: &validPodTemplateAbc.Template,
|
||||
},
|
||||
},
|
||||
update: experimental.DaemonSet{
|
||||
update: extensions.DaemonSet{
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
Spec: experimental.DaemonSetSpec{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: validSelector,
|
||||
Template: &validPodTemplateNodeSelector.Template,
|
||||
},
|
||||
@@ -339,80 +339,80 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
|
||||
}
|
||||
errorCases := map[string]dsUpdateTest{
|
||||
"change daemon name": {
|
||||
old: experimental.DaemonSet{
|
||||
old: extensions.DaemonSet{
|
||||
ObjectMeta: api.ObjectMeta{Name: "", Namespace: api.NamespaceDefault},
|
||||
Spec: experimental.DaemonSetSpec{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: validSelector,
|
||||
Template: &validPodTemplateAbc.Template,
|
||||
},
|
||||
},
|
||||
update: experimental.DaemonSet{
|
||||
update: extensions.DaemonSet{
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
Spec: experimental.DaemonSetSpec{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: validSelector,
|
||||
Template: &validPodTemplateAbc.Template,
|
||||
},
|
||||
},
|
||||
},
|
||||
"invalid selector": {
|
||||
old: experimental.DaemonSet{
|
||||
old: extensions.DaemonSet{
|
||||
ObjectMeta: api.ObjectMeta{Name: "", Namespace: api.NamespaceDefault},
|
||||
Spec: experimental.DaemonSetSpec{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: validSelector,
|
||||
Template: &validPodTemplateAbc.Template,
|
||||
},
|
||||
},
|
||||
update: experimental.DaemonSet{
|
||||
update: extensions.DaemonSet{
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
Spec: experimental.DaemonSetSpec{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: invalidSelector,
|
||||
Template: &validPodTemplateAbc.Template,
|
||||
},
|
||||
},
|
||||
},
|
||||
"invalid pod": {
|
||||
old: experimental.DaemonSet{
|
||||
old: extensions.DaemonSet{
|
||||
ObjectMeta: api.ObjectMeta{Name: "", Namespace: api.NamespaceDefault},
|
||||
Spec: experimental.DaemonSetSpec{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: validSelector,
|
||||
Template: &validPodTemplateAbc.Template,
|
||||
},
|
||||
},
|
||||
update: experimental.DaemonSet{
|
||||
update: extensions.DaemonSet{
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
Spec: experimental.DaemonSetSpec{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: validSelector,
|
||||
Template: &invalidPodTemplate.Template,
|
||||
},
|
||||
},
|
||||
},
|
||||
"change container image": {
|
||||
old: experimental.DaemonSet{
|
||||
old: extensions.DaemonSet{
|
||||
ObjectMeta: api.ObjectMeta{Name: "", Namespace: api.NamespaceDefault},
|
||||
Spec: experimental.DaemonSetSpec{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: validSelector,
|
||||
Template: &validPodTemplateAbc.Template,
|
||||
},
|
||||
},
|
||||
update: experimental.DaemonSet{
|
||||
update: extensions.DaemonSet{
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
Spec: experimental.DaemonSetSpec{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: validSelector,
|
||||
Template: &validPodTemplateDef.Template,
|
||||
},
|
||||
},
|
||||
},
|
||||
"read-write volume": {
|
||||
old: experimental.DaemonSet{
|
||||
old: extensions.DaemonSet{
|
||||
ObjectMeta: api.ObjectMeta{Name: "", Namespace: api.NamespaceDefault},
|
||||
Spec: experimental.DaemonSetSpec{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: validSelector,
|
||||
Template: &validPodTemplateAbc.Template,
|
||||
},
|
||||
},
|
||||
update: experimental.DaemonSet{
|
||||
update: extensions.DaemonSet{
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
Spec: experimental.DaemonSetSpec{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: validSelector,
|
||||
Template: &readWriteVolumePodTemplate.Template,
|
||||
},
|
||||
@@ -452,17 +452,17 @@ func TestValidateDaemonSet(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
successCases := []experimental.DaemonSet{
|
||||
successCases := []extensions.DaemonSet{
|
||||
{
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
Spec: experimental.DaemonSetSpec{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: validSelector,
|
||||
Template: &validPodTemplate.Template,
|
||||
},
|
||||
},
|
||||
{
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc-123", Namespace: api.NamespaceDefault},
|
||||
Spec: experimental.DaemonSetSpec{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: validSelector,
|
||||
Template: &validPodTemplate.Template,
|
||||
},
|
||||
@@ -474,37 +474,37 @@ func TestValidateDaemonSet(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
errorCases := map[string]experimental.DaemonSet{
|
||||
errorCases := map[string]extensions.DaemonSet{
|
||||
"zero-length ID": {
|
||||
ObjectMeta: api.ObjectMeta{Name: "", Namespace: api.NamespaceDefault},
|
||||
Spec: experimental.DaemonSetSpec{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: validSelector,
|
||||
Template: &validPodTemplate.Template,
|
||||
},
|
||||
},
|
||||
"missing-namespace": {
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc-123"},
|
||||
Spec: experimental.DaemonSetSpec{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: validSelector,
|
||||
Template: &validPodTemplate.Template,
|
||||
},
|
||||
},
|
||||
"empty selector": {
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
Spec: experimental.DaemonSetSpec{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Template: &validPodTemplate.Template,
|
||||
},
|
||||
},
|
||||
"selector_doesnt_match": {
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
Spec: experimental.DaemonSetSpec{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
Template: &validPodTemplate.Template,
|
||||
},
|
||||
},
|
||||
"invalid manifest": {
|
||||
ObjectMeta: api.ObjectMeta{Name: "abc", Namespace: api.NamespaceDefault},
|
||||
Spec: experimental.DaemonSetSpec{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: validSelector,
|
||||
},
|
||||
},
|
||||
@@ -516,7 +516,7 @@ func TestValidateDaemonSet(t *testing.T) {
|
||||
"NoUppercaseOrSpecialCharsLike=Equals": "bar",
|
||||
},
|
||||
},
|
||||
Spec: experimental.DaemonSetSpec{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: validSelector,
|
||||
Template: &validPodTemplate.Template,
|
||||
},
|
||||
@@ -529,7 +529,7 @@ func TestValidateDaemonSet(t *testing.T) {
|
||||
"NoUppercaseOrSpecialCharsLike=Equals": "bar",
|
||||
},
|
||||
},
|
||||
Spec: experimental.DaemonSetSpec{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Template: &invalidPodTemplate.Template,
|
||||
},
|
||||
},
|
||||
@@ -541,7 +541,7 @@ func TestValidateDaemonSet(t *testing.T) {
|
||||
"NoUppercaseOrSpecialCharsLike=Equals": "bar",
|
||||
},
|
||||
},
|
||||
Spec: experimental.DaemonSetSpec{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: validSelector,
|
||||
Template: &validPodTemplate.Template,
|
||||
},
|
||||
@@ -551,7 +551,7 @@ func TestValidateDaemonSet(t *testing.T) {
|
||||
Name: "abc-123",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: experimental.DaemonSetSpec{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: validSelector,
|
||||
Template: &api.PodTemplateSpec{
|
||||
Spec: api.PodSpec{
|
||||
@@ -570,7 +570,7 @@ func TestValidateDaemonSet(t *testing.T) {
|
||||
Name: "abc-123",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: experimental.DaemonSetSpec{
|
||||
Spec: extensions.DaemonSetSpec{
|
||||
Selector: validSelector,
|
||||
Template: &api.PodTemplateSpec{
|
||||
Spec: api.PodSpec{
|
||||
@@ -607,13 +607,13 @@ func TestValidateDaemonSet(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func validDeployment() *experimental.Deployment {
|
||||
return &experimental.Deployment{
|
||||
func validDeployment() *extensions.Deployment {
|
||||
return &extensions.Deployment{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "abc",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: experimental.DeploymentSpec{
|
||||
Spec: extensions.DeploymentSpec{
|
||||
Selector: map[string]string{
|
||||
"name": "abc",
|
||||
},
|
||||
@@ -643,7 +643,7 @@ func validDeployment() *experimental.Deployment {
|
||||
}
|
||||
|
||||
func TestValidateDeployment(t *testing.T) {
|
||||
successCases := []*experimental.Deployment{
|
||||
successCases := []*extensions.Deployment{
|
||||
validDeployment(),
|
||||
}
|
||||
for _, successCase := range successCases {
|
||||
@@ -652,8 +652,8 @@ func TestValidateDeployment(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
errorCases := map[string]*experimental.Deployment{}
|
||||
errorCases["metadata.name: required value"] = &experimental.Deployment{
|
||||
errorCases := map[string]*extensions.Deployment{}
|
||||
errorCases["metadata.name: required value"] = &extensions.Deployment{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
@@ -677,17 +677,17 @@ func TestValidateDeployment(t *testing.T) {
|
||||
|
||||
// rollingUpdate should be nil for recreate.
|
||||
invalidRecreateDeployment := validDeployment()
|
||||
invalidRecreateDeployment.Spec.Strategy = experimental.DeploymentStrategy{
|
||||
Type: experimental.RecreateDeploymentStrategyType,
|
||||
RollingUpdate: &experimental.RollingUpdateDeployment{},
|
||||
invalidRecreateDeployment.Spec.Strategy = extensions.DeploymentStrategy{
|
||||
Type: extensions.RecreateDeploymentStrategyType,
|
||||
RollingUpdate: &extensions.RollingUpdateDeployment{},
|
||||
}
|
||||
errorCases["rollingUpdate should be nil when strategy type is Recreate"] = invalidRecreateDeployment
|
||||
|
||||
// MaxSurge should be in the form of 20%.
|
||||
invalidMaxSurgeDeployment := validDeployment()
|
||||
invalidMaxSurgeDeployment.Spec.Strategy = experimental.DeploymentStrategy{
|
||||
Type: experimental.RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: &experimental.RollingUpdateDeployment{
|
||||
invalidMaxSurgeDeployment.Spec.Strategy = extensions.DeploymentStrategy{
|
||||
Type: extensions.RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: &extensions.RollingUpdateDeployment{
|
||||
MaxSurge: util.NewIntOrStringFromString("20Percent"),
|
||||
},
|
||||
}
|
||||
@@ -695,9 +695,9 @@ func TestValidateDeployment(t *testing.T) {
|
||||
|
||||
// MaxSurge and MaxUnavailable cannot both be zero.
|
||||
invalidRollingUpdateDeployment := validDeployment()
|
||||
invalidRollingUpdateDeployment.Spec.Strategy = experimental.DeploymentStrategy{
|
||||
Type: experimental.RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: &experimental.RollingUpdateDeployment{
|
||||
invalidRollingUpdateDeployment.Spec.Strategy = extensions.DeploymentStrategy{
|
||||
Type: extensions.RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: &extensions.RollingUpdateDeployment{
|
||||
MaxSurge: util.NewIntOrStringFromString("0%"),
|
||||
MaxUnavailable: util.NewIntOrStringFromInt(0),
|
||||
},
|
||||
@@ -706,9 +706,9 @@ func TestValidateDeployment(t *testing.T) {
|
||||
|
||||
// MaxUnavailable should not be more than 100%.
|
||||
invalidMaxUnavailableDeployment := validDeployment()
|
||||
invalidMaxUnavailableDeployment.Spec.Strategy = experimental.DeploymentStrategy{
|
||||
Type: experimental.RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: &experimental.RollingUpdateDeployment{
|
||||
invalidMaxUnavailableDeployment.Spec.Strategy = extensions.DeploymentStrategy{
|
||||
Type: extensions.RollingUpdateDeploymentStrategyType,
|
||||
RollingUpdate: &extensions.RollingUpdateDeployment{
|
||||
MaxUnavailable: util.NewIntOrStringFromString("110%"),
|
||||
},
|
||||
}
|
||||
@@ -736,13 +736,13 @@ func TestValidateJob(t *testing.T) {
|
||||
Containers: []api.Container{{Name: "abc", Image: "image", ImagePullPolicy: "IfNotPresent"}},
|
||||
},
|
||||
}
|
||||
successCases := []experimental.Job{
|
||||
successCases := []extensions.Job{
|
||||
{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "myjob",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: experimental.JobSpec{
|
||||
Spec: extensions.JobSpec{
|
||||
Selector: validSelector,
|
||||
Template: &validPodTemplateSpec,
|
||||
},
|
||||
@@ -754,13 +754,13 @@ func TestValidateJob(t *testing.T) {
|
||||
}
|
||||
}
|
||||
negative := -1
|
||||
errorCases := map[string]experimental.Job{
|
||||
errorCases := map[string]extensions.Job{
|
||||
"spec.parallelism:must be non-negative": {
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "myjob",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: experimental.JobSpec{
|
||||
Spec: extensions.JobSpec{
|
||||
Parallelism: &negative,
|
||||
Selector: validSelector,
|
||||
Template: &validPodTemplateSpec,
|
||||
@@ -771,7 +771,7 @@ func TestValidateJob(t *testing.T) {
|
||||
Name: "myjob",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: experimental.JobSpec{
|
||||
Spec: extensions.JobSpec{
|
||||
Completions: &negative,
|
||||
Selector: validSelector,
|
||||
Template: &validPodTemplateSpec,
|
||||
@@ -782,7 +782,7 @@ func TestValidateJob(t *testing.T) {
|
||||
Name: "myjob",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: experimental.JobSpec{
|
||||
Spec: extensions.JobSpec{
|
||||
Selector: map[string]string{},
|
||||
Template: &validPodTemplateSpec,
|
||||
},
|
||||
@@ -792,7 +792,7 @@ func TestValidateJob(t *testing.T) {
|
||||
Name: "myjob",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: experimental.JobSpec{
|
||||
Spec: extensions.JobSpec{
|
||||
Selector: validSelector,
|
||||
},
|
||||
},
|
||||
@@ -801,7 +801,7 @@ func TestValidateJob(t *testing.T) {
|
||||
Name: "myjob",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: experimental.JobSpec{
|
||||
Spec: extensions.JobSpec{
|
||||
Selector: validSelector,
|
||||
Template: &api.PodTemplateSpec{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
@@ -820,7 +820,7 @@ func TestValidateJob(t *testing.T) {
|
||||
Name: "myjob",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: experimental.JobSpec{
|
||||
Spec: extensions.JobSpec{
|
||||
Selector: validSelector,
|
||||
Template: &api.PodTemplateSpec{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
@@ -853,28 +853,28 @@ func TestValidateJob(t *testing.T) {
|
||||
type ingressRules map[string]string
|
||||
|
||||
func TestValidateIngress(t *testing.T) {
|
||||
defaultBackend := experimental.IngressBackend{
|
||||
defaultBackend := extensions.IngressBackend{
|
||||
ServiceName: "default-backend",
|
||||
ServicePort: util.IntOrString{Kind: util.IntstrInt, IntVal: 80},
|
||||
}
|
||||
|
||||
newValid := func() experimental.Ingress {
|
||||
return experimental.Ingress{
|
||||
newValid := func() extensions.Ingress {
|
||||
return extensions.Ingress{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: experimental.IngressSpec{
|
||||
Backend: &experimental.IngressBackend{
|
||||
Spec: extensions.IngressSpec{
|
||||
Backend: &extensions.IngressBackend{
|
||||
ServiceName: "default-backend",
|
||||
ServicePort: util.IntOrString{Kind: util.IntstrInt, IntVal: 80},
|
||||
},
|
||||
Rules: []experimental.IngressRule{
|
||||
Rules: []extensions.IngressRule{
|
||||
{
|
||||
Host: "foo.bar.com",
|
||||
IngressRuleValue: experimental.IngressRuleValue{
|
||||
HTTP: &experimental.HTTPIngressRuleValue{
|
||||
Paths: []experimental.HTTPIngressPath{
|
||||
IngressRuleValue: extensions.IngressRuleValue{
|
||||
HTTP: &extensions.HTTPIngressRuleValue{
|
||||
Paths: []extensions.HTTPIngressPath{
|
||||
{
|
||||
Path: "/foo",
|
||||
Backend: defaultBackend,
|
||||
@@ -885,7 +885,7 @@ func TestValidateIngress(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
Status: experimental.IngressStatus{
|
||||
Status: extensions.IngressStatus{
|
||||
LoadBalancer: api.LoadBalancerStatus{
|
||||
Ingress: []api.LoadBalancerIngress{
|
||||
{IP: "127.0.0.1"},
|
||||
@@ -899,21 +899,21 @@ func TestValidateIngress(t *testing.T) {
|
||||
invalidNameBackend := newValid()
|
||||
invalidNameBackend.Spec.Backend.ServiceName = "defaultBackend"
|
||||
noPortBackend := newValid()
|
||||
noPortBackend.Spec.Backend = &experimental.IngressBackend{ServiceName: defaultBackend.ServiceName}
|
||||
noPortBackend.Spec.Backend = &extensions.IngressBackend{ServiceName: defaultBackend.ServiceName}
|
||||
noForwardSlashPath := newValid()
|
||||
noForwardSlashPath.Spec.Rules[0].IngressRuleValue.HTTP.Paths = []experimental.HTTPIngressPath{
|
||||
noForwardSlashPath.Spec.Rules[0].IngressRuleValue.HTTP.Paths = []extensions.HTTPIngressPath{
|
||||
{
|
||||
Path: "invalid",
|
||||
Backend: defaultBackend,
|
||||
},
|
||||
}
|
||||
noPaths := newValid()
|
||||
noPaths.Spec.Rules[0].IngressRuleValue.HTTP.Paths = []experimental.HTTPIngressPath{}
|
||||
noPaths.Spec.Rules[0].IngressRuleValue.HTTP.Paths = []extensions.HTTPIngressPath{}
|
||||
badHost := newValid()
|
||||
badHost.Spec.Rules[0].Host = "foobar:80"
|
||||
badRegexPath := newValid()
|
||||
badPathExpr := "/invalid["
|
||||
badRegexPath.Spec.Rules[0].IngressRuleValue.HTTP.Paths = []experimental.HTTPIngressPath{
|
||||
badRegexPath.Spec.Rules[0].IngressRuleValue.HTTP.Paths = []extensions.HTTPIngressPath{
|
||||
{
|
||||
Path: badPathExpr,
|
||||
Backend: defaultBackend,
|
||||
@@ -926,7 +926,7 @@ func TestValidateIngress(t *testing.T) {
|
||||
badHostIP.Spec.Rules[0].Host = hostIP
|
||||
badHostIPErr := fmt.Sprintf("spec.rules.host: invalid value '%v'", hostIP)
|
||||
|
||||
errorCases := map[string]experimental.Ingress{
|
||||
errorCases := map[string]extensions.Ingress{
|
||||
"spec.backend.serviceName: required value": servicelessBackend,
|
||||
"spec.backend.serviceName: invalid value": invalidNameBackend,
|
||||
"spec.backend.servicePort: invalid value": noPortBackend,
|
||||
@@ -952,18 +952,18 @@ func TestValidateIngress(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestValidateClusterAutoscaler(t *testing.T) {
|
||||
successCases := []experimental.ClusterAutoscaler{
|
||||
successCases := []extensions.ClusterAutoscaler{
|
||||
{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "ClusterAutoscaler",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: experimental.ClusterAutoscalerSpec{
|
||||
Spec: extensions.ClusterAutoscalerSpec{
|
||||
MinNodes: 1,
|
||||
MaxNodes: 5,
|
||||
TargetUtilization: []experimental.NodeUtilization{
|
||||
TargetUtilization: []extensions.NodeUtilization{
|
||||
{
|
||||
Resource: experimental.CpuRequest,
|
||||
Resource: extensions.CpuRequest,
|
||||
Value: 0.7,
|
||||
},
|
||||
},
|
||||
@@ -976,18 +976,18 @@ func TestValidateClusterAutoscaler(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
errorCases := map[string]experimental.ClusterAutoscaler{
|
||||
errorCases := map[string]extensions.ClusterAutoscaler{
|
||||
"name must be ClusterAutoscaler": {
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "TestClusterAutoscaler",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: experimental.ClusterAutoscalerSpec{
|
||||
Spec: extensions.ClusterAutoscalerSpec{
|
||||
MinNodes: 1,
|
||||
MaxNodes: 5,
|
||||
TargetUtilization: []experimental.NodeUtilization{
|
||||
TargetUtilization: []extensions.NodeUtilization{
|
||||
{
|
||||
Resource: experimental.CpuRequest,
|
||||
Resource: extensions.CpuRequest,
|
||||
Value: 0.7,
|
||||
},
|
||||
},
|
||||
@@ -998,12 +998,12 @@ func TestValidateClusterAutoscaler(t *testing.T) {
|
||||
Name: "ClusterAutoscaler",
|
||||
Namespace: "test",
|
||||
},
|
||||
Spec: experimental.ClusterAutoscalerSpec{
|
||||
Spec: extensions.ClusterAutoscalerSpec{
|
||||
MinNodes: 1,
|
||||
MaxNodes: 5,
|
||||
TargetUtilization: []experimental.NodeUtilization{
|
||||
TargetUtilization: []extensions.NodeUtilization{
|
||||
{
|
||||
Resource: experimental.CpuRequest,
|
||||
Resource: extensions.CpuRequest,
|
||||
Value: 0.7,
|
||||
},
|
||||
},
|
||||
@@ -1015,12 +1015,12 @@ func TestValidateClusterAutoscaler(t *testing.T) {
|
||||
Name: "ClusterAutoscaler",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: experimental.ClusterAutoscalerSpec{
|
||||
Spec: extensions.ClusterAutoscalerSpec{
|
||||
MinNodes: -1,
|
||||
MaxNodes: 5,
|
||||
TargetUtilization: []experimental.NodeUtilization{
|
||||
TargetUtilization: []extensions.NodeUtilization{
|
||||
{
|
||||
Resource: experimental.CpuRequest,
|
||||
Resource: extensions.CpuRequest,
|
||||
Value: 0.7,
|
||||
},
|
||||
},
|
||||
@@ -1031,12 +1031,12 @@ func TestValidateClusterAutoscaler(t *testing.T) {
|
||||
Name: "ClusterAutoscaler",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: experimental.ClusterAutoscalerSpec{
|
||||
Spec: extensions.ClusterAutoscalerSpec{
|
||||
MinNodes: 10,
|
||||
MaxNodes: 5,
|
||||
TargetUtilization: []experimental.NodeUtilization{
|
||||
TargetUtilization: []extensions.NodeUtilization{
|
||||
{
|
||||
Resource: experimental.CpuRequest,
|
||||
Resource: extensions.CpuRequest,
|
||||
Value: 0.7,
|
||||
},
|
||||
},
|
||||
@@ -1047,10 +1047,10 @@ func TestValidateClusterAutoscaler(t *testing.T) {
|
||||
Name: "ClusterAutoscaler",
|
||||
Namespace: api.NamespaceDefault,
|
||||
},
|
||||
Spec: experimental.ClusterAutoscalerSpec{
|
||||
Spec: extensions.ClusterAutoscalerSpec{
|
||||
MinNodes: 1,
|
||||
MaxNodes: 5,
|
||||
TargetUtilization: []experimental.NodeUtilization{},
|
||||
TargetUtilization: []extensions.NodeUtilization{},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user