Fix registry flunder and fisher strategy method names to a standard

pull/6/head
Daniel Morinigo 2018-02-23 09:53:06 +08:00
parent 52b7aab09a
commit 7e855f6861
2 changed files with 14 additions and 8 deletions

View File

@ -31,16 +31,19 @@ import (
"k8s.io/sample-apiserver/pkg/apis/wardle"
)
// NewStrategy creates and returns a fischerStrategy instance
func NewStrategy(typer runtime.ObjectTyper) fischerStrategy {
return fischerStrategy{typer, names.SimpleNameGenerator}
}
// GetAttrs returns labels.Set, fields.Set, the presence of Initializers if any
// and error in case the given runtime.Object is not a Fischer
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, bool, error) {
apiserver, ok := obj.(*wardle.Fischer)
if !ok {
return nil, nil, false, fmt.Errorf("given object is not a Fischer.")
return nil, nil, false, fmt.Errorf("given object is not a Fischer")
}
return labels.Set(apiserver.ObjectMeta.Labels), fischerToSelectableFields(apiserver), apiserver.Initializers != nil, nil
return labels.Set(apiserver.ObjectMeta.Labels), SelectableFields(apiserver), apiserver.Initializers != nil, nil
}
// MatchFischer is the filter used by the generic etcd backend to watch events
@ -53,8 +56,8 @@ func MatchFischer(label labels.Selector, field fields.Selector) storage.Selectio
}
}
// fischerToSelectableFields returns a field set that represents the object.
func fischerToSelectableFields(obj *wardle.Fischer) fields.Set {
// SelectableFields returns a field set that represents the object.
func SelectableFields(obj *wardle.Fischer) fields.Set {
return generic.ObjectMetaFieldsSet(&obj.ObjectMeta, true)
}

View File

@ -31,16 +31,19 @@ import (
"k8s.io/sample-apiserver/pkg/apis/wardle"
)
// NewStrategy creates and returns a flunderStrategy instance
func NewStrategy(typer runtime.ObjectTyper) flunderStrategy {
return flunderStrategy{typer, names.SimpleNameGenerator}
}
// GetAttrs returns labels.Set, fields.Set, the presence of Initializers if any
// and error in case the given runtime.Object is not a Flunder
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, bool, error) {
apiserver, ok := obj.(*wardle.Flunder)
if !ok {
return nil, nil, false, fmt.Errorf("given object is not a Flunder.")
return nil, nil, false, fmt.Errorf("given object is not a Flunder")
}
return labels.Set(apiserver.ObjectMeta.Labels), FlunderToSelectableFields(apiserver), apiserver.Initializers != nil, nil
return labels.Set(apiserver.ObjectMeta.Labels), SelectableFields(apiserver), apiserver.Initializers != nil, nil
}
// MatchFlunder is the filter used by the generic etcd backend to watch events
@ -53,8 +56,8 @@ func MatchFlunder(label labels.Selector, field fields.Selector) storage.Selectio
}
}
// FlunderToSelectableFields returns a field set that represents the object.
func FlunderToSelectableFields(obj *wardle.Flunder) fields.Set {
// SelectableFields returns a field set that represents the object.
func SelectableFields(obj *wardle.Flunder) fields.Set {
return generic.ObjectMetaFieldsSet(&obj.ObjectMeta, true)
}