Skip to content
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

Filter namespaces by labels #46

Closed
wants to merge 5 commits into from
Closed

Conversation

swestcott
Copy link

PR for #44 to add a new --namespace-labels option.

I'm still fairly new to Go, so all feedback is welcome :)

@swestcott
Copy link
Author

Any feedback on this?

@swestcott
Copy link
Author

@linki Let me know if there's anything I can do to help this progress.

pods []map[string]string
}{
{"", []map[string]string{foo, bar}},
{"doesnotexist", []map[string]string{foo, bar}},
Copy link
Owner

@linki linki Nov 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect this to not find any pods as there's no namespace that satisfies this label selector.

@@ -7,6 +7,8 @@ import (

log "github.com/sirupsen/logrus"

"strings"
Copy link
Owner

@linki linki Nov 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stdlib imports live in the very first section, i.e. next to errors, fmt, etc.

// Append additional namespaces filters
reqs, _ := namespaceLabel.Requirements()
for _, req := range reqs {
c.Namespaces = c.Namespaces.Add(req)
Copy link
Owner

@linki linki Nov 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to think about this. I was thinking we could do this in the initializer (resolving the namespace label selector and then adding the matched namespaces to the name-based namespace selector).

But then, having it here makes much more sense as the label selector is re-evaluated at every loop (namespaces could have been created, labels on namespaces can change to opt-in/out them etc.).

However, modifying the chaoskube-instance global variable here might not have the desired effect in this case.

@linki
Copy link
Owner

linki commented Nov 18, 2017

Looks awesome, thanks @swestcott!

I have a remark regarding how the final namespace list is calculated, let me know if you have thoughts about it.

Of the top of my head, I think we need to add the namespaces found by label selectors to the final namespace selector list via a local variable, so that we don't ever grow this list.

@linki
Copy link
Owner

linki commented Feb 11, 2018

Follow up: swestcott#1

@linki
Copy link
Owner

linki commented Aug 6, 2019

Rebased on the latest master and merged in #134.

Thanks @swestcott

@linki linki closed this Aug 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants