...

Source file src/k8s.io/kubernetes/pkg/registry/certificates/clustertrustbundle/strategy.go

Documentation: k8s.io/kubernetes/pkg/registry/certificates/clustertrustbundle

     1  /*
     2  Copyright 2022 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  // Package clustertrustbundle provides Registry interface and its RESTStorage
    18  // implementation for storing ClusterTrustBundle objects.
    19  package clustertrustbundle // import "k8s.io/kubernetes/pkg/registry/certificates/clustertrustbundle"
    20  
    21  import (
    22  	"context"
    23  
    24  	"k8s.io/apimachinery/pkg/runtime"
    25  	"k8s.io/apimachinery/pkg/util/validation/field"
    26  	"k8s.io/apiserver/pkg/registry/rest"
    27  	"k8s.io/apiserver/pkg/storage/names"
    28  	"k8s.io/kubernetes/pkg/api/legacyscheme"
    29  	"k8s.io/kubernetes/pkg/apis/certificates"
    30  	certvalidation "k8s.io/kubernetes/pkg/apis/certificates/validation"
    31  )
    32  
    33  // strategy implements behavior for ClusterTrustBundles.
    34  type strategy struct {
    35  	runtime.ObjectTyper
    36  	names.NameGenerator
    37  }
    38  
    39  // Strategy is the create, update, and delete strategy for ClusterTrustBundles.
    40  var Strategy = strategy{legacyscheme.Scheme, names.SimpleNameGenerator}
    41  
    42  var _ rest.RESTCreateStrategy = Strategy
    43  var _ rest.RESTUpdateStrategy = Strategy
    44  var _ rest.RESTDeleteStrategy = Strategy
    45  
    46  func (strategy) NamespaceScoped() bool {
    47  	return false
    48  }
    49  
    50  func (strategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {}
    51  
    52  func (strategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
    53  	bundle := obj.(*certificates.ClusterTrustBundle)
    54  	return certvalidation.ValidateClusterTrustBundle(bundle, certvalidation.ValidateClusterTrustBundleOptions{})
    55  }
    56  
    57  func (strategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string {
    58  	return nil
    59  }
    60  
    61  func (strategy) Canonicalize(obj runtime.Object) {}
    62  
    63  func (strategy) AllowCreateOnUpdate() bool {
    64  	return false
    65  }
    66  
    67  func (s strategy) PrepareForUpdate(ctx context.Context, new, old runtime.Object) {}
    68  
    69  func (s strategy) ValidateUpdate(ctx context.Context, new, old runtime.Object) field.ErrorList {
    70  	newBundle := new.(*certificates.ClusterTrustBundle)
    71  	oldBundle := old.(*certificates.ClusterTrustBundle)
    72  	return certvalidation.ValidateClusterTrustBundleUpdate(newBundle, oldBundle)
    73  }
    74  
    75  func (strategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string {
    76  	return nil
    77  }
    78  
    79  func (strategy) AllowUnconditionalUpdate() bool {
    80  	return false
    81  }
    82  

View as plain text