diff --git a/pkg/storage/unified/entitybridge/entitybridge.go b/pkg/storage/unified/entitybridge/entitybridge.go index 7a7288de81f..abc5fc16f9c 100644 --- a/pkg/storage/unified/entitybridge/entitybridge.go +++ b/pkg/storage/unified/entitybridge/entitybridge.go @@ -7,6 +7,7 @@ import ( "path/filepath" "gocloud.dev/blob/fileblob" + "k8s.io/apimachinery/pkg/selection" "k8s.io/klog/v2" grafanaregistry "github.com/grafana/grafana/pkg/apiserver/registry/generic" @@ -244,11 +245,15 @@ func (b *entityBridge) PrepareList(ctx context.Context, req *resource.ListReques WithBody: true, } - // Assumes everything is equals if len(req.Options.Labels) > 0 { query.Labels = make(map[string]string) for _, q := range req.Options.Labels { - query.Labels[q.Key] = q.Values[0] + // The entity structure only supports equals + // the rest will be processed handled by the upstream predicate + op := selection.Operator(q.Operator) + if op == selection.Equals || op == selection.DoubleEquals { + query.Labels[q.Key] = q.Values[0] + } } } diff --git a/pkg/storage/unified/resource/resource.proto b/pkg/storage/unified/resource/resource.proto index b7b741a8bdd..5471d2c8c1c 100644 --- a/pkg/storage/unified/resource/resource.proto +++ b/pkg/storage/unified/resource/resource.proto @@ -154,9 +154,9 @@ message ReadResponse { // The label filtering requirements: // https://github.com/kubernetes/kubernetes/blob/v1.30.1/staging/src/k8s.io/apimachinery/pkg/labels/selector.go#L141 message Requirement { - string key = 1; + string key = 1; string operator = 2; // See https://github.com/kubernetes/kubernetes/blob/v1.30.1/staging/src/k8s.io/apimachinery/pkg/selection/operator.go#L21 - repeated string values = 3; // typically one value, but depends on the operator + repeated string values = 3; // typically one value, but depends on the operator } message Sort { @@ -164,7 +164,7 @@ message Sort { ASC = 0; DESC = 1; } - string field = 1; + string field = 1; Order order = 2; } @@ -217,16 +217,16 @@ message ListResponse { int64 resource_version = 3; // remainingItemCount is the number of subsequent items in the list which are not included in this - // list response. If the list request contained label or field selectors, then the number of - // remaining items is unknown and the field will be left unset and omitted during serialization. - // If the list is complete (either because it is not chunking or because this is the last chunk), - // then there are no more remaining items and this field will be left unset and omitted during - // serialization. + // list response. If the list request contained label or field selectors, then the number of + // remaining items is unknown and the field will be left unset and omitted during serialization. + // If the list is complete (either because it is not chunking or because this is the last chunk), + // then there are no more remaining items and this field will be left unset and omitted during + // serialization. // - // The intended use of the remainingItemCount is *estimating* the size of a collection. Clients - // should not rely on the remainingItemCount to be set or to be exact. - // +optional - int64 remaining_item_count = 4; // 0 won't be set either (no next page token) + // The intended use of the remainingItemCount is *estimating* the size of a collection. Clients + // should not rely on the remainingItemCount to be set or to be exact. + // +optional + int64 remaining_item_count = 4; // 0 won't be set either (no next page token) } message WatchRequest {