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

Add field mapper for attached clusters direct controller migration. #2966

Merged

Conversation

hankfreund
Copy link
Member

Followed step 3 of the Direct Controller migration guide.
Manually implemented functions which the generator was unable to handle on its own.
Since this is a migration for an existing resource, some NOTYETs are in the code for new, unimplemented fields.

Fix the change that made the required ProjectRef optional in the previous PR.

@hankfreund
Copy link
Member Author

/assign @yuwenma

return out
}

func slice_FromProto_two[T, U any](mapCtx *direct.MapContext, in []T, mapper func(mapCtx *direct.MapContext, in T) *U) []U {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this because the current Slice_FromProto has a pointer in the mapping function? If so, I think it would be worth adding this in the direct package to be reused. That can happen as a follow on PR. Let's rename this to something like slice_FromProto for now if so.

Copy link
Member Author

Choose a reason for hiding this comment

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

That is correct.
And I did intend to rename it because this name is silly, I just forgot. My mistake!

@@ -26,8 +26,7 @@ var ContainerAttachedClusterGVK = GroupVersion.WithKind("ContainerAttachedCluste
// +kcc:proto=google.cloud.gkemulticloud.v1.AttachedCluster
type ContainerAttachedClusterSpec struct {
/* The ID of the project in which the resource belongs. If it is not provided, the provider project is used. */
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think by making this a required field now we should update the docs:

Suggested change
/* The ID of the project in which the resource belongs. If it is not provided, the provider project is used. */
/* The ID of the project in which the resource belongs. */

Copy link
Member Author

Choose a reason for hiding this comment

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

It was always a required field and the docs were misleading. I have updated them.

@@ -26,8 +26,7 @@ var ContainerAttachedClusterGVK = GroupVersion.WithKind("ContainerAttachedCluste
// +kcc:proto=google.cloud.gkemulticloud.v1.AttachedCluster
type ContainerAttachedClusterSpec struct {
/* The ID of the project in which the resource belongs. If it is not provided, the provider project is used. */
// +optional
ProjectRef *refs.ProjectRef `json:"projectRef,omitempty"`
ProjectRef *refs.ProjectRef `json:"projectRef"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Mind elaborating this change?

Copy link
Member Author

Choose a reason for hiding this comment

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

In the existing tf-based resource, this field is required even though the comment implies it is optional.
In my previous PR I made this optional to match the comment, but you called this out as a change in behavior, so I said I'd fix it. This is just putting everything back the way it was.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry I didn't make it clear. I mean the removal of the omitempty. I'm wondering why you make this change (because this could be an interesting topic!)

Copy link
Collaborator

@yuwenma yuwenma 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

@google-oss-prow google-oss-prow bot added the lgtm label Oct 23, 2024
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: yuwenma

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

@google-oss-prow google-oss-prow bot merged commit 7575dea into GoogleCloudPlatform:master Oct 23, 2024
18 checks passed
@yuwenma yuwenma added this to the 1.124 milestone Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants