Unverified Commit 3eec501b authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #60262 from danielfbm/master

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Fix registry flunder and fisher strategy method names to a standard **What this PR does / why we need it**: Fixes function names for sample-apiserver registry strategy methods that were named not matching golang specifications/recommendations. Adds a few missing comments on public methods **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes # **Special notes for your reviewer**: no functional changes **Release note**: ```release-note NONE ```
parents 49b0daeb 7e855f68
......@@ -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)
}
......
......@@ -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)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment