forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
defaults.go
29 lines (24 loc) · 795 Bytes
/
defaults.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
package v1beta3
import (
kapi "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/runtime"
internal "github.com/openshift/origin/pkg/authorization/api"
)
var oldAllowAllPolicyRule = PolicyRule{APIGroups: nil, Verbs: []string{internal.VerbAll}, Resources: []string{internal.ResourceAll}}
func addDefaultingFuncs(scheme *runtime.Scheme) {
err := scheme.AddDefaultingFuncs(
func(obj *PolicyRule) {
if obj == nil {
return
}
// this seems really strange, but semantic equality checks most of what we want, but nil == {}
// this is ok for the restof the fields, but not APIGroups
if kapi.Semantic.Equalities.DeepEqual(oldAllowAllPolicyRule, *obj) && obj.APIGroups == nil {
obj.APIGroups = []string{internal.APIGroupAll}
}
},
)
if err != nil {
panic(err)
}
}