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

Refactor pkg/subctl/cmd/gather -> internal/gather #2007

Merged
merged 4 commits into from
May 3, 2022
Merged

Refactor pkg/subctl/cmd/gather -> internal/gather #2007

merged 4 commits into from
May 3, 2022

Conversation

Jaanki
Copy link
Contributor

@Jaanki Jaanki commented Apr 7, 2022

This PR does the following:

  1. Adds config to cluster.Info
  2. Uses execute.OnMultiCluster functionality
  3. Uses constants defined in internal/constants.go

Related to #1329

Signed-off-by: Janki Chhatbar [email protected]

@submariner-bot
Copy link
Contributor

🤖 Created branch: z_pr2007/Jaanki/refactor_gather
🚀 Full E2E won't run until the "ready-to-test" label is applied. I will add it automatically once the PR has 2 approvals, or you can add it manually.

@Jaanki Jaanki self-assigned this Apr 7, 2022
@Jaanki Jaanki linked an issue Apr 7, 2022 that may be closed by this pull request
48 tasks
Copy link
Contributor

@tpantelis tpantelis left a 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.

@Jaanki
Copy link
Contributor Author

Jaanki commented Apr 8, 2022

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.

@Jaanki Jaanki requested a review from tpantelis April 12, 2022 09:46
@Jaanki Jaanki requested a review from mkolesnik as a code owner April 22, 2022 08:47
@Jaanki Jaanki marked this pull request as draft April 22, 2022 11:55
@Jaanki Jaanki marked this pull request as ready for review April 25, 2022 10:08
Copy link
Contributor

@tpantelis tpantelis left a 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.

@dfarrell07
Copy link
Member

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.

@Jaanki
Copy link
Contributor Author

Jaanki commented Apr 27, 2022

To maintain git history, we should first move the files to internal/gather.

git mv moves the files from pkg/subctl/cmd/gather/. to internal/gather. I want the files to be copied and not moved.

@tpantelis
Copy link
Contributor

tpantelis commented Apr 27, 2022

git mv moves the files from pkg/subctl/cmd/gather/. to internal/gather. I want the files to be copied and not moved.

Why? Copying loses the git history.

git log -- internal/gather/cni.go

commit d11b28efd3454e88ec8a69826270366bb4f24133
Author: Janki Chhatbar <[email protected]>
Date:   Fri Apr 22 11:45:28 2022 +0530

    Copy pkg/subctl/cmd/gather -> internal/gather
    
    Signed-off-by: Janki Chhatbar <[email protected]>

The deceiving thing tho is that the diff in the GtHub UI shows that it was renamed w/o changes.

Comment on lines 47 to 48
ModuleFlags map[string]bool
TypeFlags map[string]bool
Copy link
Member

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).

Copy link
Contributor

Choose a reason for hiding this comment

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

Commit 0e5e8a4.

Comment on lines 56 to 61
var ModuleFlags = map[string]bool{
component.Connectivity: false,
component.ServiceDiscovery: false,
component.Broker: false,
component.Operator: false,
}
Copy link
Member

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.

Copy link
Contributor

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.

Comment on lines 63 to 66
var TypeFlags = map[string]bool{
"logs": false,
"resources": false,
}
Copy link
Member

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.

Copy link
Contributor

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

Jaanki and others added 4 commits May 3, 2022 11:44
and use new cluster.Info API and constants

Signed-off-by: Janki Chhatbar <[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)
Copy link
Member

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree.

@submariner-bot submariner-bot added the ready-to-test When a PR is ready for full E2E testing label May 3, 2022
@skitt skitt enabled auto-merge (rebase) May 3, 2022 15:59
@skitt skitt merged commit 734ece2 into submariner-io:devel May 3, 2022
@submariner-bot
Copy link
Contributor

🤖 Closed branches: [z_pr2007/Jaanki/refactor_gather]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-test When a PR is ready for full E2E testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants