New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
selector:MatchLabel #249
selector:MatchLabel #249
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
@manavellamnimble the If we can match the format of Kubernetes native objects for label selectors (https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/) it will be easier for people to implement because we won't be asking them to change the format and they can re-use existing YAML selectors. Is is possible to use the standard key=value types here, and use the |
@marccampbell In fact I used a map based on what you mentioned. K8s api uses mostly maps (I called it dictionary, my bad). In the docs there is an example for selectors, following the same structure: selector:
matchLabels:
component: redis
Regarding using the client, that was also my first approach, but the matchFilter() func uses the info stored in the file nodes.json (created earlier by the collector), thats why I use node.Labels (which is also a map). Nevertheless, I can adjust the labels as you prefer, it is really not lots of work. Let me know what you think! |
pkg/analyze/node_resources.go
Outdated
if filters.Selector != nil { | ||
for k, v := range filters.Selector.MatchLabel { | ||
if l, found := node.Labels[k]; !found || l != v { | ||
return false, errors.New(fmt.Sprintf("failed to match label %s", k)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
errors.Errorf
Thanks! This lgtm, 1 comment on cleaning up an error string before we can merge |
@marccampbell Great! Done! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
@marccampbell @divolgin @dexhorthy Morning! I am sending a PR to solve issue #159 . I desing the selector label to accept further expansions in the future. Under matchLabel, multiple labels can be used to filter the nodes. The final structure would be something like this: