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

🌱 Use url.JoinPath instead of fmt to concat endpoint #10917

Merged
merged 3 commits into from
Sep 16, 2024

Conversation

sivchari
Copy link
Member

What this PR does / why we need it:

Currently, kubeadmconfg's endpoint is liked using fmt.Sprintf. But if the endpoint is /host:port, the result is https:///host:port. So I use url.JoinPath to concat safely.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Signed-off-by: sivchari <shibuuuu5@gmail.com>
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 20, 2024
@sivchari
Copy link
Member Author

/asssign

@k8s-ci-robot k8s-ci-robot added do-not-merge/needs-area PR is missing an area label size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 20, 2024
sivchari added 2 commits July 20, 2024 22:18
Signed-off-by: sivchari <shibuuuu5@gmail.com>
Signed-off-by: sivchari <shibuuuu5@gmail.com>
@sivchari
Copy link
Member Author

/assign

@chrischdi
Copy link
Member

Change looks okay so far, but I have a question:

Currently, kubeadmconfg's endpoint is liked using fmt.Sprintf. But if the endpoint is /host:port, the result is https:///host:port. So I use url.JoinPath to concat safely.

Why should the endpoint be in format /host:port? We pass in the output of clusterv1.APIEndpoint's String() method which if I see it right should not have a leading /. So I'm curious if you have been able to hit this as an issue or this is just a cleanup/improvement.

@sivchari
Copy link
Member Author

@chrischdi

Why should the endpoint be in format /host:port? We pass in the output of clusterv1.APIEndpoint's String() method which if I see it right should not have a leading /. So I'm curious if you have been able to hit this as an issue or this is just a cleanup/improvement.

https://go.dev/play/p/pNz485g0Igc

This CL is for improvement to make the endpoint safely. Since APIEndpoint is the field of CRD, the value that has prefix of / might be set. And if so, the endpoint url is invalid value because the output is https:///host. So to prevent it, I want to use the url.JoinPath to concat server endpoint.

@sivchari sivchari changed the title 🐛 Use url.JoinPath instead of fmt to concat endpoint 🌱 : Use url.JoinPath instead of fmt to concat endpoint Jul 23, 2024
@sivchari sivchari changed the title 🌱 : Use url.JoinPath instead of fmt to concat endpoint 🌱 Use url.JoinPath instead of fmt to concat endpoint Jul 23, 2024
@sbueringer sbueringer added tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. area/util Issues or PRs related to utils labels Sep 16, 2024
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/needs-area PR is missing an area label label Sep 16, 2024
@sbueringer
Copy link
Member

/test pull-cluster-api-e2e-main

@sbueringer
Copy link
Member

Especially as this is an exported util, fine to make it more robust

@sbueringer
Copy link
Member

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 16, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 1ef26e897b53e3d664361e9c4146367d7da4344f

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbueringer

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 Sep 16, 2024
Copy link
Member

@chrischdi chrischdi left a comment

Choose a reason for hiding this comment

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

/retest

@k8s-ci-robot k8s-ci-robot merged commit d6268ff into kubernetes-sigs:main Sep 16, 2024
33 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.9 milestone Sep 16, 2024
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. area/util Issues or PRs related to utils 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. 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.

4 participants