Bumping k8s version to 1.13.0-beta.1
This commit is contained in:
52
vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/strategy.go
generated
vendored
52
vendor/k8s.io/apiextensions-apiserver/pkg/registry/customresourcedefinition/strategy.go
generated
vendored
@@ -57,9 +57,25 @@ func (strategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
|
||||
// if the feature gate is disabled, drop the feature.
|
||||
if !utilfeature.DefaultFeatureGate.Enabled(apiextensionsfeatures.CustomResourceValidation) {
|
||||
crd.Spec.Validation = nil
|
||||
for i := range crd.Spec.Versions {
|
||||
crd.Spec.Versions[i].Schema = nil
|
||||
}
|
||||
}
|
||||
if !utilfeature.DefaultFeatureGate.Enabled(apiextensionsfeatures.CustomResourceSubresources) {
|
||||
crd.Spec.Subresources = nil
|
||||
for i := range crd.Spec.Versions {
|
||||
crd.Spec.Versions[i].Subresources = nil
|
||||
}
|
||||
}
|
||||
// On CREATE, if the CustomResourceWebhookConversion feature gate is off, we auto-clear
|
||||
// the per-version fields. This is to be consistent with the other built-in types, as the
|
||||
// apiserver drops unknown fields.
|
||||
if !utilfeature.DefaultFeatureGate.Enabled(apiextensionsfeatures.CustomResourceWebhookConversion) {
|
||||
for i := range crd.Spec.Versions {
|
||||
crd.Spec.Versions[i].Schema = nil
|
||||
crd.Spec.Versions[i].Subresources = nil
|
||||
crd.Spec.Versions[i].AdditionalPrinterColumns = nil
|
||||
}
|
||||
}
|
||||
if !utilfeature.DefaultFeatureGate.Enabled(apiextensionsfeatures.CustomResourceWebhookConversion) && crd.Spec.Conversion != nil {
|
||||
crd.Spec.Conversion.WebhookClientConfig = nil
|
||||
@@ -96,10 +112,36 @@ func (strategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
|
||||
if !utilfeature.DefaultFeatureGate.Enabled(apiextensionsfeatures.CustomResourceValidation) {
|
||||
newCRD.Spec.Validation = nil
|
||||
oldCRD.Spec.Validation = nil
|
||||
for i := range newCRD.Spec.Versions {
|
||||
newCRD.Spec.Versions[i].Schema = nil
|
||||
}
|
||||
for i := range oldCRD.Spec.Versions {
|
||||
oldCRD.Spec.Versions[i].Schema = nil
|
||||
}
|
||||
}
|
||||
if !utilfeature.DefaultFeatureGate.Enabled(apiextensionsfeatures.CustomResourceSubresources) {
|
||||
newCRD.Spec.Subresources = nil
|
||||
oldCRD.Spec.Subresources = nil
|
||||
for i := range newCRD.Spec.Versions {
|
||||
newCRD.Spec.Versions[i].Subresources = nil
|
||||
}
|
||||
for i := range oldCRD.Spec.Versions {
|
||||
oldCRD.Spec.Versions[i].Subresources = nil
|
||||
}
|
||||
}
|
||||
|
||||
// On UPDATE, if the CustomResourceWebhookConversion feature gate is off, we auto-clear
|
||||
// the per-version fields if the old CRD doesn't use per-version fields already.
|
||||
// This is to be consistent with the other built-in types, as the apiserver drops unknown
|
||||
// fields. If the old CRD already uses per-version fields, the CRD is allowed to continue
|
||||
// use per-version fields.
|
||||
if !utilfeature.DefaultFeatureGate.Enabled(apiextensionsfeatures.CustomResourceWebhookConversion) &&
|
||||
!hasPerVersionField(oldCRD.Spec.Versions) {
|
||||
for i := range newCRD.Spec.Versions {
|
||||
newCRD.Spec.Versions[i].Schema = nil
|
||||
newCRD.Spec.Versions[i].Subresources = nil
|
||||
newCRD.Spec.Versions[i].AdditionalPrinterColumns = nil
|
||||
}
|
||||
}
|
||||
if !utilfeature.DefaultFeatureGate.Enabled(apiextensionsfeatures.CustomResourceWebhookConversion) && newCRD.Spec.Conversion != nil {
|
||||
if oldCRD.Spec.Conversion == nil || newCRD.Spec.Conversion.WebhookClientConfig == nil {
|
||||
@@ -117,6 +159,16 @@ func (strategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
|
||||
}
|
||||
}
|
||||
|
||||
// hasPerVersionField returns true if a CRD uses per-version schema/subresources/columns fields.
|
||||
func hasPerVersionField(versions []apiextensions.CustomResourceDefinitionVersion) bool {
|
||||
for _, v := range versions {
|
||||
if v.Schema != nil || v.Subresources != nil || len(v.AdditionalPrinterColumns) > 0 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Validate validates a new CustomResourceDefinition.
|
||||
func (strategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
|
||||
return validation.ValidateCustomResourceDefinition(obj.(*apiextensions.CustomResourceDefinition))
|
||||
|
Reference in New Issue
Block a user