mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-13 11:25:19 +00:00
Grow signature for predicate attributes to include init status
This commit is contained in:
@@ -90,12 +90,12 @@ func ControllerRevisionToSelectableFields(revision *apps.ControllerRevision) fie
|
||||
}
|
||||
|
||||
// GetAttrs returns labels and fields of a given object for filtering purposes.
|
||||
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) {
|
||||
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, bool, error) {
|
||||
history, ok := obj.(*apps.ControllerRevision)
|
||||
if !ok {
|
||||
return nil, nil, errors.New("supplied object is not an ControllerRevision")
|
||||
return nil, nil, false, errors.New("supplied object is not an ControllerRevision")
|
||||
}
|
||||
return labels.Set(history.ObjectMeta.Labels), ControllerRevisionToSelectableFields(history), nil
|
||||
return labels.Set(history.ObjectMeta.Labels), ControllerRevisionToSelectableFields(history), history.Initializers != nil, nil
|
||||
}
|
||||
|
||||
// MatchControllerRevision returns a generic matcher for a given label and field selector.
|
||||
|
||||
@@ -140,10 +140,13 @@ func TestControllerRevisionToSelectableFields(t *testing.T) {
|
||||
|
||||
func TestGetAttrs(t *testing.T) {
|
||||
rev := newControllerRevision("validname", "validns", newObject(), 0)
|
||||
labelSet, fieldSet, err := GetAttrs(rev)
|
||||
labelSet, fieldSet, uninitialized, err := GetAttrs(rev)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if uninitialized {
|
||||
t.Errorf("unexpected attrs")
|
||||
}
|
||||
if fieldSet.Get("metadata.name") != rev.Name {
|
||||
t.Errorf("expeted %s found %s", rev.Name, fieldSet.Get("metadata.name"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user