fix tabs to spaces

This commit is contained in:
Ryan McKinley 2024-07-03 13:38:16 -07:00
parent 2a4fedb6ee
commit ddcbc753d3
2 changed files with 19 additions and 14 deletions

View File

@ -7,6 +7,7 @@ import (
"path/filepath" "path/filepath"
"gocloud.dev/blob/fileblob" "gocloud.dev/blob/fileblob"
"k8s.io/apimachinery/pkg/selection"
"k8s.io/klog/v2" "k8s.io/klog/v2"
grafanaregistry "github.com/grafana/grafana/pkg/apiserver/registry/generic" 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, WithBody: true,
} }
// Assumes everything is equals
if len(req.Options.Labels) > 0 { if len(req.Options.Labels) > 0 {
query.Labels = make(map[string]string) query.Labels = make(map[string]string)
for _, q := range req.Options.Labels { 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]
}
} }
} }

View File

@ -154,9 +154,9 @@ message ReadResponse {
// The label filtering requirements: // The label filtering requirements:
// https://github.com/kubernetes/kubernetes/blob/v1.30.1/staging/src/k8s.io/apimachinery/pkg/labels/selector.go#L141 // https://github.com/kubernetes/kubernetes/blob/v1.30.1/staging/src/k8s.io/apimachinery/pkg/labels/selector.go#L141
message Requirement { 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 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 { message Sort {
@ -164,7 +164,7 @@ message Sort {
ASC = 0; ASC = 0;
DESC = 1; DESC = 1;
} }
string field = 1; string field = 1;
Order order = 2; Order order = 2;
} }
@ -217,16 +217,16 @@ message ListResponse {
int64 resource_version = 3; int64 resource_version = 3;
// remainingItemCount is the number of subsequent items in the list which are not included in this // 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 // 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. // 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), // 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 // then there are no more remaining items and this field will be left unset and omitted during
// serialization. // serialization.
// //
// The intended use of the remainingItemCount is *estimating* the size of a collection. Clients // 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. // should not rely on the remainingItemCount to be set or to be exact.
// +optional // +optional
int64 remaining_item_count = 4; // 0 won't be set either (no next page token) int64 remaining_item_count = 4; // 0 won't be set either (no next page token)
} }
message WatchRequest { message WatchRequest {