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

feat: add types and mapping functions for IAPSettings #2785

Merged
merged 10 commits into from
Jan 22, 2025

Conversation

jingyih
Copy link
Collaborator

@jingyih jingyih commented Sep 25, 2024

Generate types and mapping functions for IAPSettings.

This PR also includes tooling enhancements for handling the protobuf wrapperspb types.

For the resource, the most controversial part is the “name” field, which has different formats depending on the resource type that the IAPSettings are associated with. The current implementation requires users to manually form the string for the name field. Alternatively, we could introduce virtual fields like organizationRef, folderRef, projectRef, computeBackendServiceRef, etc., to help construct the name string. However, my preference is to keep the resource simple and recommend that users leverage KCC composition.

@jingyih jingyih force-pushed the IAPSettings branch 5 times, most recently from c258e5e to 798ec69 Compare September 26, 2024 23:59
@jingyih jingyih changed the title WIP: add types and mapping functions for IAPSettings feat: add types and mapping functions for IAPSettings Sep 27, 2024
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
/hold

one comment about the deprecated google.golang.org/protobuf/types/known/wrapperspb, not a blocker. Feel free to unhold

// IAPSettingsSpec defines the desired state of IAPSettings
// +kcc:proto=google.cloud.iap.v1.IapSettings
type IAPSettingsSpec struct {
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ResourceID field is immutable"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggest not using immutable check for resourceID (maybe we can specifically call it out in the scifi guide, here)

Copy link
Collaborator Author

@jingyih jingyih Jan 14, 2025

Choose a reason for hiding this comment

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

I ended up regenerating the types and mappings from scratch using the updated templates, this immutable check is no longer present.

// +kcc:proto=google.cloud.iap.v1.AccessDeniedPageSettings
type AccessDeniedPageSettings struct {
// The URI to be redirected to when access is denied.
AccessDeniedPageUri *string `json:"accessDeniedPageUri,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: uri --> URI. Could you also add it to the TestCRDsAcronyms test

Copy link
Collaborator Author

@jingyih jingyih Jan 14, 2025

Choose a reason for hiding this comment

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

This is fixed by 19657bd

@@ -55,7 +55,7 @@ go run ./scripts/crd-tools reflow-descriptions --dir apis/config/crd/

# excluded_resources are resources that are under development for a direct conversion
# we don't modify the CRD just yet for those but will in the future
excluded_resources=("securesourcemanagerinstance")
excluded_resources=("securesourcemanagerinstance" "iapsettings")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason on adding this alpha resource here?

Copy link
Collaborator Author

@jingyih jingyih Jan 14, 2025

Choose a reason for hiding this comment

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

This ensures that we don't generate the CRD for IAPSettings before the direct controller is added.

@@ -26,6 +26,7 @@ import (
"google.golang.org/protobuf/reflect/protoreflect"
"google.golang.org/protobuf/types/known/durationpb"
"google.golang.org/protobuf/types/known/timestamppb"
"google.golang.org/protobuf/types/known/wrapperspb"
Copy link
Collaborator

Choose a reason for hiding this comment

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

So this library is already deprecated, I was not sure if we should support it or not. Now it is more obvious that we do want to support it. Could you add the other wrapperspb functions in this lib or improve the mapper generator to consider the types from wrapperspb (as a bonus)?

Copy link
Collaborator Author

@jingyih jingyih Jan 14, 2025

Choose a reason for hiding this comment

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

Sure, do you mean 427d4b1?


// IAPSettingsSpec defines the desired state of IAPSettings
// +kcc:proto=google.cloud.iap.v1.IapSettings
type IAPSettingsObservedState struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggest adding the configurable fields here as well (does IapSettings has any output-only field?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There is currently no output only field in the proto. So I commented out the ObservedState for now.

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

"sigs.k8s.io/controller-runtime/pkg/client"
)

// IAPSettingsIdentity defines the resource reference to IAPSettings.
Copy link
Collaborator

Choose a reason for hiding this comment

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

good to know....

@google-oss-prow google-oss-prow bot added the lgtm label Jan 22, 2025
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

@jingyih
Copy link
Collaborator Author

jingyih commented Jan 22, 2025

Rebased PR to resolve merge conflict.

@yuwenma
Copy link
Collaborator

yuwenma commented Jan 22, 2025

/lgtm

@google-oss-prow google-oss-prow bot added the lgtm label Jan 22, 2025
@jingyih
Copy link
Collaborator Author

jingyih commented Jan 22, 2025

/hold cancel

@google-oss-prow google-oss-prow bot merged commit 2baa6c5 into GoogleCloudPlatform:master Jan 22, 2025
18 of 19 checks passed
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.

2 participants