forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
strategy.go
59 lines (44 loc) · 1.67 KB
/
strategy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package rangeallocations
import (
"context"
securityapi "github.com/openshift/origin/pkg/security/apis/security"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/apiserver/pkg/registry/rest"
"k8s.io/apiserver/pkg/storage/names"
"k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/apis/core/validation"
)
type strategy struct {
runtime.ObjectTyper
names.NameGenerator
}
var strategyInstance = strategy{legacyscheme.Scheme, names.SimpleNameGenerator}
var _ rest.RESTCreateStrategy = strategyInstance
var _ rest.RESTUpdateStrategy = strategyInstance
func (strategy) NamespaceScoped() bool {
return false
}
func (strategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
_ = obj.(*securityapi.RangeAllocation)
}
func (strategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
cfg := obj.(*securityapi.RangeAllocation)
return validation.ValidateObjectMeta(&cfg.ObjectMeta, false, validation.NameIsDNSSubdomain, field.NewPath("metadata"))
}
func (strategy) Canonicalize(obj runtime.Object) {
}
func (strategy) AllowCreateOnUpdate() bool {
return false
}
func (strategy) PrepareForUpdate(ctx context.Context, newObj, oldObj runtime.Object) {
_ = oldObj.(*securityapi.RangeAllocation)
_ = newObj.(*securityapi.RangeAllocation)
}
func (strategy) AllowUnconditionalUpdate() bool {
return false
}
func (strategy) ValidateUpdate(ctx context.Context, newObj, oldObj runtime.Object) field.ErrorList {
oldCfg, newCfg := oldObj.(*securityapi.RangeAllocation), newObj.(*securityapi.RangeAllocation)
return validation.ValidateObjectMetaUpdate(&newCfg.ObjectMeta, &oldCfg.ObjectMeta, field.NewPath("metadata"))
}