-
Notifications
You must be signed in to change notification settings - Fork 157
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
Cleaned up some of the logic in main #16
Conversation
b127d1e
to
9d0de37
Compare
Additionally, I wanted to know what action to take when inputs are empty? @stepanstipl Should we throw or...? |
9d0de37
to
8b5dced
Compare
@david-doit-intl yes, multiple collectors at once should be allowed, ie. typical scenario is that workloads in the cluster are deployed both directly (Cluster collector) and via Helm, and we want to scan all of those.
Empty inputs are fine too, we print how many resources we have retrieved from individual collectors if there is none - no issue. TL;DR: The ides of default use case is: Just run kubent, without any additional config, and it tries to detect as many problematic resources as we can. |
I think that moving the logic to individual functions, away from the main "spaghetti" is a nice improvement. 👍 But I would prefer to keep the actual retrieval of the resources Perhaps moving just the collection logic/loop to a separate function, smth. like |
Yes, we can do a defer as well, but ok will change! |
@stepanstipl maybe also the collection.Get(), should be async then, if that is the case? https://gobyexample.com/goroutines So we can run the get or the resource retrival all at once if they exist. |
defer -> https://tour.golang.org/flowcontrol/12, something like this so the Get collection can happen after! |
Not sure how that would look like -
Hm, that is a good point and would say yes, but :)... because most of the collectors talk to the cluster, I'm not sure if hitting it with 3 connections, all at once, wouldn't degrade the resulting performance/cause issues with the network. But definitely a good point to think about... maybe worth running some tests.... |
let me show you the defer first and then we can have a look at async stuff if needed |
7f48239
to
2b422d4
Compare
Signed-off-by: david-doit-intl <david@doit-intl.com>
2b422d4
to
f3f7ca6
Compare
@stepanstipl have updated this code :) |
79c4dbe
to
855a115
Compare
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.
@david-doit-intl I think it looks good 🚀 Do you plan to add tests for the new funcs? (I'm happy to merge as it is)
@stepanstipl adding tests now :) |
By introducing a function which gets the collectors interface, I wanted to know if there would ever be a case when there would be more than one collector?
IE:
NewClusterCollector
NewHelmV2Collector
NewHelmV3Collector
or is it always just one of these?