...
1
16
17
18
19 package 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
34 type strategy struct {
35 runtime.ObjectTyper
36 names.NameGenerator
37 }
38
39
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