-
Notifications
You must be signed in to change notification settings - Fork 304
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 translator.ToURLMap to not re-fetch backend services #207
Conversation
/cc @MrHohn |
8b9fc52
to
d99b42f
Compare
pkg/utils/namer.go
Outdated
@@ -84,6 +84,9 @@ const ( | |||
|
|||
// schemaVersionV1 is the version 1 naming scheme for NEG | |||
schemaVersionV1 = "1" | |||
|
|||
// linkPrefix is the prefix for the link of GCE resources. | |||
linkPrefix = "https://www.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.
Should we have different prefixes for alpha/beta/ga?
5de9f60
to
3fa5161
Compare
pkg/utils/utils.go
Outdated
|
||
// BackendRelativeResourcePath returns a relative path of the link for a | ||
// BackendService given its name. | ||
func BackendRelativeResourcePath(name 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.
Let's use BackendService to not get confused with BackendService.Backend
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.
Done
pkg/utils/utils.go
Outdated
// BackendComparableGroupPath trims project and compute version from the SelfLink | ||
// for a global BackendService. | ||
// /global/backendServices/[BACKEND_SERVICE_NAME] | ||
func BackendComparableGroupPath(url 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.
Group was referring to InstanceGroup, which isn't applicable for the BackendService.
Maybe "BackendServiceComparablePath"
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.
Done
pkg/utils/utils.go
Outdated
// /global/backendServices/[BACKEND_SERVICE_NAME] | ||
func BackendComparableGroupPath(url string) string { | ||
path_parts := strings.Split(url, "/global/") | ||
return fmt.Sprintf("/global/%s", path_parts[1]) |
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.
We should handle the error case of len(url) != 2... Guessing we return empty.
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.
Done
3fa5161
to
ca7c1c9
Compare
Adding tests now. |
501fbb9
to
8b15093
Compare
if a.Service != b.Service { | ||
// Trim down the url's for a.Service and b.Service to a comparable structure | ||
// We do this because we update the UrlMap with relative links (not full) to backends. | ||
if utils.BackendServiceComparablePath(a.Service) != utils.BackendServiceComparablePath(b.Service) { |
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.
There are two more lines with Service equality checks. 775 and 805.
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.
Done
pkg/utils/utils.go
Outdated
|
||
// BackendServiceComparablePath trims project and compute version from the SelfLink | ||
// for a global BackendService. | ||
// /global/backendServices/[BACKEND_SERVICE_NAME] |
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: leading slash
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.
Done
8b15093
to
a3c7bc7
Compare
/lgtm |
/assign @nicksardo @MrHohn
Will update tests once approach is LGTM'd.