Skip to content

Add WithLabel list filter to serving client lib #1053

Closed

Description

@zroubalik

Feature request

The list filters in serving client lib are missing an option to filter by specified label, eg. something similar that could be achieved by this call:

servingClient.Services(l.namespace).List(metav1.ListOptions{LabelSelector: labelSelector})

Serving Client lib:

type ListConfig func(config *listConfigCollector)
type ListConfigs []ListConfig
// add selectors to a list options
func (opts ListConfigs) toListOptions() v1.ListOptions {
listConfig := listConfigCollector{labels.Set{}, fields.Set{}}
for _, f := range opts {
f(&listConfig)
}
options := v1.ListOptions{}
if len(listConfig.Fields) > 0 {
options.FieldSelector = listConfig.Fields.String()
}
if len(listConfig.Labels) > 0 {
options.LabelSelector = listConfig.Labels.String()
}
return options
}
// Filter list on the provided name
func WithName(name string) ListConfig {
return func(lo *listConfigCollector) {
lo.Fields["metadata.name"] = name
}
}
// Filter on the service name
func WithService(service string) ListConfig {
return func(lo *listConfigCollector) {
lo.Labels[apiserving.ServiceLabelKey] = service
}
}

Would be nice to add func WithLabel(labelKey, labelValue string) ListConfig

Activity

  1. added
    kind/feature
    on Oct 8, 2020
  2. zroubalik commented on Oct 8, 2020

    @zroubalik
    ContributorAuthor

    /assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/feature

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions