-
Notifications
You must be signed in to change notification settings - Fork 235
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
chore: Add backend service reference and refactor reference code #3316
base: master
Are you sure you want to change the base?
Conversation
30c60b8
to
4903616
Compare
4903616
to
7bfa8ad
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
7bfa8ad
to
478dd82
Compare
external = strings.TrimPrefix(external, "/") | ||
tokens := strings.Split(external, "/") | ||
if len(tokens) == 5 && tokens[0] == "projects" && tokens[3] == "backendServices" { | ||
return &BackendServiceIdentity{ |
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.
One thought: maybe we could rename ResourceIdentity
to ResourceExternal
? I feel "Identity" is just the same thing as "ExternalRef", so that we don't introduce many new terms to people.
23913f8
to
1d5cc2b
Compare
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.
This PR contains several things where we do not have full test coverage yet. Suggest spliting it into smaller PRs and focus on one change a time.
1d5cc2b
to
b447fc9
Compare
Change description
b/379722657
Use ComputeBackendService as an example, explore how we normalize and resolve referenced resources.
My idea in this PR is to add a
ReferenceContext
struct, developer need to provide info when they try to resolve a referenced resource. Depends on differentReferenceContext
, we can handle new referenced resources and ensure backward compatibility at the same time. I plan to add some questions regarding resource reference in the questionnaire.For example, ComputeTargetTCPProxy has reference to ComputeBackendService(BackendServiceRef):
First, developer need to figure out whether ComputeBackendService is a pure direct resource(No); Then they need to know the required value(format) of the field, for ComputeTargetTCPProxy, the value(format) of BackendServiceRef is selfLink(https://www.googleapis.com/compute/v1/projects/${projectId}/global/backendServices/backendService). So their
ReferenceContext
looks likeReferenceContext{IsDirectOnly: false, TargetField: "status.selfLink"}
.When they resolve the referenced BackendService in the direct controller, they need to provide the
ReferenceContext
, based on their own API requirements. And resolve/convert the value to API required value.In the future, we can add more functions inside
ReferenceContext
.I refactored BackendService ref in this PR, and there was no log change.
Tests you have done
make ready-pr
to ensure this PR is ready for review.