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 7 return values in parseGitUrl to RepoSpec(issue 4866, Task1) #4900

Merged
merged 2 commits into from Dec 2, 2022
Merged

Refactor 7 return values in parseGitUrl to RepoSpec(issue 4866, Task1) #4900

merged 2 commits into from Dec 2, 2022

Conversation

kishorerj
Copy link
Contributor

@kishorerj kishorerj commented Dec 1, 2022

This PR has been created to fix Task1 in Issue #4866.
The parseGitURL returns 7 values. It has been refactored to return a single RepoSpec value..

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 1, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @kishorerj. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 1, 2022
@kishorerj kishorerj changed the title initial commit to refactor 7 return values in parseGitUrl to RepoSpec Refactor 7 return values in parseGitUrl to RepoSpec(issue 4866, Task1) Dec 1, 2022
@kishorerj
Copy link
Contributor Author

/assign @annasong20

@natasha41575
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 1, 2022
func parseGitURL(n string) (
host string, orgRepo string, path string, gitRef string, gitSubmodules bool, gitSuff string, gitTimeout time.Duration) {
func parseGitURL(n string) *RepoSpec {
repoSpec := &RepoSpec{raw: n, Dir: notCloned, Timeout: defaultTimeout, Submodules: defaultSubmodules}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason we initialize Timeout and Submodules here?

We should set raw and Dir because they remain constant. Their initialized values are the final return values.

On the other hand, Timeout and Submodules are always initialized on line 121 below. If they aren't present in n, parseQuery returns their default values. We are doing unnecessary work by initializing them here. Would recommend removing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason I am initialising the default values is because I think its good practice to initialize with user defined default values where possible during object creation itself.. If we create any new logic between 114 and 121 in future which will return RepoSpec we can always ensure that RepoSpect has timeout set to the default values that we want (27secs) instead of the type defaults.. That was the reasoning.. please let me know what you think

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I see. That makes sense. Thanks for the explanation!

Copy link
Contributor

@annasong20 annasong20 left a comment

Choose a reason for hiding this comment

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

Looks very clean! Left minor comments.

@k8s-ci-robot
Copy link
Contributor

@kishorerj: This PR has multiple commits, and the default merge method is: merge.
You can request commits to be squashed using the label: tide/merge-method-squash

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/test-infra repository.

@kishorerj
Copy link
Contributor Author

Looks very clean! Left minor comments.
Thanks for reviewing and leaving those comments.. I have resolved one and provided my reasoning for the second

@annasong20
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 2, 2022
@annasong20
Copy link
Contributor

annasong20 commented Dec 2, 2022

/label tide/merge-method-squash

Feel free to add this label yourself next time! If you have multiple commits in your PR, this label will squash them into 1 when merged to keep the master branch clean.

@k8s-ci-robot k8s-ci-robot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Dec 2, 2022
@annasong20
Copy link
Contributor

/ok-to-test

@KnVerey
Copy link
Contributor

KnVerey commented Dec 2, 2022

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kishorerj, KnVerey

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 2, 2022
@k8s-ci-robot k8s-ci-robot merged commit 1e2e7bb into kubernetes-sigs:master Dec 2, 2022
elisshafer pushed a commit to elisshafer/kustomize that referenced this pull request Dec 8, 2022
kubernetes-sigs#4900)

* initial commit to refactor 7 return values in parseGitUrl to RepoSpec

* fix review comments
cailynse pushed a commit to cailynse/kustomize that referenced this pull request Jan 12, 2023
kubernetes-sigs#4900)

* initial commit to refactor 7 return values in parseGitUrl to RepoSpec

* fix review comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants