-
Notifications
You must be signed in to change notification settings - Fork 513
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
Refactor gwctl: restructure codebase, add new commands, and enable extensions #3244
Refactor gwctl: restructure codebase, add new commands, and enable extensions #3244
Conversation
81ff183
to
bbe84d0
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: gauravkghildiyal The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/cc @robscott |
1e89830
to
8f0d1ca
Compare
8f0d1ca
to
6840dc0
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.
Thanks for all the work on this, @gauravkghildiyal!
This PR looks massive and I honestly find the review of such a big piece of code very hard. Since in the PR description you outlined what the PR is about (this is great description) I wonder if it is possible to split this PR into multiple smaller PRs, focused on a specific area of improvement/refactoring. Do you think it's feasible? It'd help a lot the review :)
…te the graphical modeling of resource relationships.
…ges. These will augment information into the Graph model.
…aml, describe, etc. formats
Thanks for taking the time to help with this @mlavacca. I totally feel the pain of reviewing a PR like this. I've started with splitting this into individual commits, ordered in a manner to make things easier to review. Given the number of issues this PR tackles, as I was developing the code, I realized that splitting it into completely independent, atomic PRs would have significantly impacted development time. Obviously, there are tradeoffs to that decision which appear in the form of not-so-easy reviews. I understand that a comprehensive review may be challenging within a reasonable timeframe. I propose we prioritize identifying any obvious "red flags" and rely on the integration tests to verify the overall behaviour. We can continue to improve the codebase iteratively in future PRs. |
6840dc0
to
41f8da8
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.
Thanks @gauravkghildiyal! Partial review from last week, will try to get back to this soon.
fmt.Fprintf(o.IOStreams.Out, "\n") | ||
|
||
// Step 1: Parse the files and extract the objects from the files. | ||
infos, err := o.factory.NewBuilder(). |
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.
Nit: "infos" feels like an overly vague name here, is there something a bit more specific that would work here?
graph, err := topology.NewBuilder(common.NewDefaultGroupKindFetcher(o.factory, common.WithAdditionalResources(sources))). | ||
StartFrom(sources). | ||
UseRelationships(topologygw.AllRelations). | ||
WithMaxDepth(4). |
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.
This seems like something that should be configurable?
} | ||
|
||
policyManager := policymanager.New(common.NewDefaultGroupKindFetcher(o.factory, common.WithAdditionalResources(sources))) | ||
if err := policyManager.Init(); err != nil { //nolint:govet |
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.
Why's the nolint
needed here?
topologygw "sigs.k8s.io/gateway-api/gwctl/pkg/topology/gateway" | ||
) | ||
|
||
func NewCmd(factory common.Factory, iostreams genericiooptions.IOStreams) *cobra.Command { |
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.
Somewhere in this file it would be useful to have a comment describing what the analyze command is trying to achieve.
return fmt.Errorf("%v: %v", info.Source, err) | ||
} | ||
|
||
obj, err := helper.Patch( |
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.
When I see Patch
, I assume this will only update existing options, where I'd expect apply
to do an upsert
case "gatewayclass", "gateawyclasses": | ||
objRef.Group = gatewayv1.GroupVersion.Group | ||
objRef.Kind = "GatewayClass" | ||
objRef.Namespace = "" | ||
case "gateway", "gateways": | ||
objRef.Group = gatewayv1.GroupVersion.Group | ||
objRef.Kind = "Gateway" | ||
case "httproute", "httproutes": | ||
objRef.Group = gatewayv1.GroupVersion.Group | ||
objRef.Kind = "HTTPRoute" | ||
case "service", "services": | ||
objRef.Kind = "Service" |
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.
A comment describing why these are the only supported input types would be useful.
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
@gauravkghildiyal: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
@gauravkghildiyal at this point should we close this and apply it to the new repository, since this is getting moved? |
good point, yeah, I think this got missed |
Thanks Shane, thanks Rob! I'll archive any other open PRs and issues too, or suggest people reopen them on kubernetes-sigs/gwctl |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Apologies for the large size of this PR, but it represents a significant step forward in making gwctl more usable and extensible. The updated README.md provides a comprehensive overview of all the latest capabilities.
Next steps:
Does this PR introduce a user-facing change?:
/area gwctl