Simplify List() signature in clients.

This commit is contained in:
Wojciech Tyczynski
2015-12-02 12:12:57 +01:00
parent 800012dfb8
commit 6dcb689d4e
141 changed files with 532 additions and 650 deletions

View File

@@ -44,21 +44,37 @@ func NewGetAction(resource, namespace, name string) GetActionImpl {
return action
}
func NewRootListAction(resource string, label labels.Selector, field fields.Selector) ListActionImpl {
func NewRootListAction(resource string, opts unversioned.ListOptions) ListActionImpl {
action := ListActionImpl{}
action.Verb = "list"
action.Resource = resource
action.ListRestrictions = ListRestrictions{label, field}
labelSelector := opts.LabelSelector.Selector
if labelSelector == nil {
labelSelector = labels.Everything()
}
fieldSelector := opts.FieldSelector.Selector
if fieldSelector == nil {
fieldSelector = fields.Everything()
}
action.ListRestrictions = ListRestrictions{labelSelector, fieldSelector}
return action
}
func NewListAction(resource, namespace string, label labels.Selector, field fields.Selector) ListActionImpl {
func NewListAction(resource, namespace string, opts unversioned.ListOptions) ListActionImpl {
action := ListActionImpl{}
action.Verb = "list"
action.Resource = resource
action.Namespace = namespace
action.ListRestrictions = ListRestrictions{label, field}
labelSelector := opts.LabelSelector.Selector
if labelSelector == nil {
labelSelector = labels.Everything()
}
fieldSelector := opts.FieldSelector.Selector
if fieldSelector == nil {
fieldSelector = fields.Everything()
}
action.ListRestrictions = ListRestrictions{labelSelector, fieldSelector}
return action
}