-
Notifications
You must be signed in to change notification settings - Fork 20
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
add targeting system and target command #5
Conversation
@xrstf Thank you for your contribution. |
@xrstf there are some lint errors that need to be fixed, otherwise lgtm |
I just tested it locally and ran into an error because the home folder was not resolved for the garden kubeconfig.
|
@petersutter linted and handled ~ in configuration now. |
pkg/cmd/root/command.go
Outdated
// prefer -session, then an explicit GCTL_HOME env, | ||
// but fallback to the system-defined home directory |
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.
prefer -session
do not understand
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.
Yeah I've removed the notion of "sessions" again now. The comment was .. inspired, yet misleading. I am not actually sure how we want to allow users to switch between targets (we probably want to offer that, but how exactly?), so it's probably best if we do it in another PR.
…are preconfigured for a certain namespace
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, let's get this basic target handling in and improve as we go
What this PR does / why we need it:
This PR introduces the "targeting" system from gardenctl v1, just slighly refactored. Targeting is used to free the user from having to specify the garden, seed and/or shoot name for most commands (e.g. free them from doing something like
gardenctl ssh -g garden1 -s seed1 --ss shoot1 nodeNameXY
). To achieve this, the user can use thetarget
command and incrementally refine the goal for the upcoming commands, e.g.The previous implementation chose to work with "stack"-like approach, however the new implementation uses a dedicated map instead. The code is also less generic, which seems like a downside, but if you look carefully at the v1 code, the generic parts were drowned in super specific hacks and exceptions and lots and lots of assumptions. That made the old code hard to read and understand:
The new v2 code makes no assumptions like that and simply has dedicated functions and fields for garden, seed, project and shoot.
Likewise, the new code separates the data and logic, with the
Target
interface only providing read access to target information, and the more complex logic being wrapped up in theManager
(so it'smanager.GardenClient(target)
instead oftarget.K8sClientForTarget(TargetKindGarden)
). This is because we surely will rework the targeting in the future and this separation makes it easier to exchange the implementation.I chose to provide controller-runtime clients, because I like their interface much better than the Kuberntes clientsets. One downside so far is that namespace targeting doesn't work yet, so targeting a project is currently pointless and returns a client to the garden cluster.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Release note: