-
Notifications
You must be signed in to change notification settings - Fork 66
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 pkg/subctl/cmd/gather -> internal/gather #2007
Conversation
🤖 Created branch: z_pr2007/Jaanki/refactor_gather |
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.
So it looks like you copied code to internal/gather but it's not being used.
Yes. e2e is failing for some reason so didn't push more commits. |
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.
To maintain git history, we should first move the files to internal/gather.
We have a pointer for this guidance at https://submariner.io/development/code-review/#rename-and-edit-in-separate-commits FYI. I think it was created because of very similar feedback on similar refactoring a few months ago. |
|
Why? Copying loses the git history.
The deceiving thing tho is that the diff in the GtHub UI shows that it was renamed w/o changes. |
internal/gather/gather.go
Outdated
ModuleFlags map[string]bool | ||
TypeFlags map[string]bool |
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.
These should be string slices, not maps; that would make it easier to use them as Cobra flags directly (and we don’t care about the bool
).
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.
Commit 0e5e8a4.
internal/gather/gather.go
Outdated
var ModuleFlags = map[string]bool{ | ||
component.Connectivity: false, | ||
component.ServiceDiscovery: false, | ||
component.Broker: false, | ||
component.Operator: false, | ||
} |
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 shouldn’t be necessary, the same information is effectively present in gatherFuncs
; perhaps a GetSupportedModules() []string
function could be used instead, or an IsModuleSupported(module string) bool
function.
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.
Made it a set with 0e5e8a4.
internal/gather/gather.go
Outdated
var TypeFlags = map[string]bool{ | ||
"logs": false, | ||
"resources": false, | ||
} |
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.
Likewise, this should be hidden behind a function, and maintained as a []string
.
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.
Made it a set with 0e5e8a4
and use new cluster.Info API and constants Signed-off-by: Janki Chhatbar <[email protected]>
Signed-off-by: Tom Pantelis <[email protected]>
.. and delete cobra stuff from internal/gather/gather.go Signed-off-by: Janki Chhatbar <[email protected]>
... instead of maps and use them directly as Cobra flags directly via StringSliceVar. Signed-off-by: Tom Pantelis <[email protected]>
@@ -210,7 +210,7 @@ func clusterInfoFromKubeConfig(kubeConfig string) *cluster.Info { | |||
clientProducer, err := client.NewProducerFromRestConfig(config.Config) | |||
exit.OnErrorWithMessage(err, fmt.Sprintf("Error creating client producer for kubeconfig %q", kubeConfig)) | |||
|
|||
clusterInfo, err := cluster.NewInfo("", clientProducer) | |||
clusterInfo, err := cluster.NewInfo("", clientProducer, nil) |
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 is unfortunate, but let’s not block the PR — see #2042.
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.
Agree.
🤖 Closed branches: [z_pr2007/Jaanki/refactor_gather] |
This PR does the following:
config
tocluster.Info
Related to #1329
Signed-off-by: Janki Chhatbar [email protected]