-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Conversation
return fmt.Sprintf(migUrlTemplate, ref.Project, ref.Zone, ref.Name) | ||
} | ||
|
||
func prefix(domainSuffix string) 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.
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 :)
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.
changed it to domain url
migUrlTemplate = gcePrefix + "%s/zones/%s/instanceGroups/%s" | ||
gceUrlSchema = "https" | ||
projectsSubstring = "/projects/" | ||
defaultGceDomainSuffix = "googleapis.com/compute/v1/projects/" |
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.
Is it intended that "/projects/" is already a part of domain suffix?
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.
Removed it from suffix
f058edc
to
75281ee
Compare
/lgtm |
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.
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" |
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.
Can we remain this to something like urlPrefix
or httpsPrefix
? The current does not accurately describe the content.
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.
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) { |
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.
nit: I feel like this whole function could be just a single regexp check. What do you think about rewriting this?
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.
I replaced the checks with regexp, however I still left the split logic. Let me know if you think we should change it further
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.
I think this is good enough for now - ideal would be replacing the split with regexp as well, but this is already much better.
/lgtm |
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.
/lgtm
/approve
[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 |
/lgtm |
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.