Repository navigation
Closed
Labels
kind/featureNew feature or request
Description
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:
client/pkg/serving/v1/client.go
Lines 110 to 142 in b13cd70
| 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
Metadata
Metadata
Assignees
Labels
kind/featureNew feature or request
Activity
zroubalik commentedon Oct 8, 2020
/assign