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

Allow overriding domain suffix in GCE cloud provider. #6284

Merged
merged 1 commit into from
Nov 21, 2023

Conversation

olagacek
Copy link
Contributor

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR allows overriding Domain Suffix in calls made to GCE cloud provider. If it's not specified the default domain suffix is used.

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 15, 2023
return fmt.Sprintf(migUrlTemplate, ref.Project, ref.Zone, ref.Name)
}

func prefix(domainSuffix string) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we allow to override the whole API endpoint? It allows slightly more flexibility while shortening the code slightly.

Also, I believe "API endpoint" wording is more obvious than "domain suffix" when reading the code :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed it to domain url

migUrlTemplate = gcePrefix + "%s/zones/%s/instanceGroups/%s"
gceUrlSchema = "https"
projectsSubstring = "/projects/"
defaultGceDomainSuffix = "googleapis.com/compute/v1/projects/"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it intended that "/projects/" is already a part of domain suffix?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed it from suffix

@olagacek olagacek force-pushed the master branch 2 times, most recently from f058edc to 75281ee Compare November 20, 2023 10:54
@kawych
Copy link
Contributor

kawych commented Nov 20, 2023

/lgtm

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

@BigDarkClown BigDarkClown left a comment

Choose a reason for hiding this comment

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

LGTM, but I think we can clean this a bit more without much additional work, just by using regexp.

gcePrefix = gceUrlSchema + "://www." + gceDomainSuffix
instanceUrlTemplate = gcePrefix + "%s/zones/%s/instances/%s"
migUrlTemplate = gcePrefix + "%s/zones/%s/instanceGroups/%s"
gceUrlSchema = "https"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remain this to something like urlPrefix or httpsPrefix? The current does not accurately describe the content.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed it alltogether

if domainUrl == "" {
domainUrl = defaultDomainUrl
}
migUrlTemplate := domainUrl + projectsSubstring + "%s/zones/%s/instanceGroups/%s"
return fmt.Sprintf(migUrlTemplate, ref.Project, ref.Zone, ref.Name)
}

func parseGceUrl(url, expectedResource string) (project string, zone string, name string, err error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I feel like this whole function could be just a single regexp check. What do you think about rewriting this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I replaced the checks with regexp, however I still left the split logic. Let me know if you think we should change it further

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is good enough for now - ideal would be replacing the split with regexp as well, but this is already much better.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 20, 2023
@kawych
Copy link
Contributor

kawych commented Nov 21, 2023

/lgtm

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

@BigDarkClown BigDarkClown left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: BigDarkClown, olagacek

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 approved Indicates a PR has been approved by an approver from all required OWNERS files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Nov 21, 2023
@k8s-ci-robot k8s-ci-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Nov 21, 2023
@BigDarkClown
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 Nov 21, 2023
@k8s-ci-robot k8s-ci-robot merged commit 0979221 into kubernetes:master Nov 21, 2023
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/cluster-autoscaler area/provider/gce cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants