Merge pull request #8285 from ashumkin/label-selector

discovery/kubernetes: Fix valid label selector causing config error
This commit is contained in:
Frederic Branczyk 2020-12-28 16:00:06 +01:00 committed by GitHub
commit 611fa967cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -6,3 +6,8 @@ scrape_configs:
- role: "pod"
label: "foo=bar"
field: "metadata.status=Running"
- role: pod
selectors:
- role: "pod"
label: "foo in (bar,baz)"
field: "metadata.status=Running"

View File

@ -33,6 +33,7 @@ import (
"k8s.io/api/networking/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/kubernetes"
@ -203,7 +204,7 @@ func (c *SDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
if err != nil {
return err
}
_, err = fields.ParseSelector(selector.Label)
_, err = labels.Parse(selector.Label)
if err != nil {
return err
}