From c5057a3c2006b4fb6d178ce4dafec834be4dbdd7 Mon Sep 17 00:00:00 2001 From: Gemma Hou Date: Mon, 3 Feb 2025 20:58:02 +0000 Subject: [PATCH] Add CloudIdentityGroup types --- apis/cloudidentity/v1beta1/doc.go | 16 ++ apis/cloudidentity/v1beta1/group_identity.go | 76 ++++++ apis/cloudidentity/v1beta1/group_reference.go | 83 +++++++ apis/cloudidentity/v1beta1/group_types.go | 147 ++++++++++++ .../v1beta1/groupversion_info.go | 33 +++ .../v1beta1/zz_generated.deepcopy.go | 221 ++++++++++++++++++ ...s.cloudidentity.cnrm.cloud.google.com.yaml | 51 ++-- dev/tools/proto-to-mapper/Makefile | 1 + mockgcp/Makefile | 8 +- .../groups/v1beta1/service.proto | 2 +- .../cloudidentity/cloudidentitygroup.md | 28 ++- 11 files changed, 628 insertions(+), 38 deletions(-) create mode 100644 apis/cloudidentity/v1beta1/doc.go create mode 100644 apis/cloudidentity/v1beta1/group_identity.go create mode 100644 apis/cloudidentity/v1beta1/group_reference.go create mode 100644 apis/cloudidentity/v1beta1/group_types.go create mode 100644 apis/cloudidentity/v1beta1/groupversion_info.go create mode 100644 apis/cloudidentity/v1beta1/zz_generated.deepcopy.go rename mockgcp/apis/{google/apps => mockgcp/cloud}/cloudidentity/groups/v1beta1/service.proto (99%) diff --git a/apis/cloudidentity/v1beta1/doc.go b/apis/cloudidentity/v1beta1/doc.go new file mode 100644 index 00000000000..2223c4f0bc2 --- /dev/null +++ b/apis/cloudidentity/v1beta1/doc.go @@ -0,0 +1,16 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +kcc:proto=mockgcp.cloud.cloudidentity.groups.v1beta1 +package v1beta1 diff --git a/apis/cloudidentity/v1beta1/group_identity.go b/apis/cloudidentity/v1beta1/group_identity.go new file mode 100644 index 00000000000..4556ffe079c --- /dev/null +++ b/apis/cloudidentity/v1beta1/group_identity.go @@ -0,0 +1,76 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package v1beta1 + +import ( + "context" + "fmt" + "strings" + + "github.com/GoogleCloudPlatform/k8s-config-connector/apis/common" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +// GroupIdentity defines the resource reference to CloudIdentityGroup, which "External" field +// holds the GCP identifier for the KRM object. +type GroupIdentity struct { + id string +} + +func (i *GroupIdentity) String() string { + return "/groups/" + i.id +} + +func (i *GroupIdentity) ID() string { + return i.id +} + +// NewGroupIdentity New builds a GroupIdentity from the Config Connector Group object. +func NewGroupIdentity(ctx context.Context, reader client.Reader, obj *CloudIdentityGroup) (*GroupIdentity, error) { + // Get desired ID + resourceID := common.ValueOf(obj.Spec.ResourceID) + if resourceID == "" { + resourceID = obj.GetName() + } + if resourceID == "" { + return nil, fmt.Errorf("cannot resolve resource ID") + } + + // Use approved External + externalRef := common.ValueOf(obj.Status.ExternalRef) + if externalRef != "" { + // Validate desired with actual + actualResourceID, err := ParseGroupExternal(externalRef) + if err != nil { + return nil, err + } + if actualResourceID != resourceID { + return nil, fmt.Errorf("cannot reset `metadata.name` or `spec.resourceID` to %s, since it has already assigned to %s", + resourceID, actualResourceID) + } + } + return &GroupIdentity{ + id: resourceID, + }, nil +} + +func ParseGroupExternal(external string) (resourceID string, err error) { + tokens := strings.Split(external, "/") + if len(tokens) != 2 || tokens[0] != "groups" { + return "", fmt.Errorf("format of CloudIdentityGroup external=%q was not known (use groups/{{groupID}})", external) + } + resourceID = tokens[1] + return resourceID, nil +} diff --git a/apis/cloudidentity/v1beta1/group_reference.go b/apis/cloudidentity/v1beta1/group_reference.go new file mode 100644 index 00000000000..2ad01c156be --- /dev/null +++ b/apis/cloudidentity/v1beta1/group_reference.go @@ -0,0 +1,83 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package v1beta1 + +import ( + "context" + "fmt" + + refsv1beta1 "github.com/GoogleCloudPlatform/k8s-config-connector/apis/refs/v1beta1" + "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/k8s" + apierrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/types" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +var _ refsv1beta1.ExternalNormalizer = &GroupRef{} + +// GroupRef defines the resource reference to CloudIdentityGroup, which "External" field +// holds the GCP identifier for the KRM object. +type GroupRef struct { + // A reference to an externally managed CloudIdentityGroup resource. + // Should be in the format "groups/{{groupID}}". + External string `json:"external,omitempty"` + + // The name of a CloudIdentityGroup resource. + Name string `json:"name,omitempty"` + + // The namespace of a CloudIdentityGroup resource. + Namespace string `json:"namespace,omitempty"` +} + +// NormalizedExternal provision the "External" value for other resource that depends on CloudIdentityGroup. +// If the "External" is given in the other resource's spec.CloudIdentityGroupRef, the given value will be used. +// Otherwise, the "Name" and "Namespace" will be used to query the actual CloudIdentityGroup object from the cluster. +func (r *GroupRef) NormalizedExternal(ctx context.Context, reader client.Reader, otherNamespace string) (string, error) { + if r.External != "" && r.Name != "" { + return "", fmt.Errorf("cannot specify both name and external on %s reference", CloudIdentityGroupGVK.Kind) + } + // From given External + if r.External != "" { + if _, err := ParseGroupExternal(r.External); err != nil { + return "", err + } + return r.External, nil + } + + // From the Config Connector object + if r.Namespace == "" { + r.Namespace = otherNamespace + } + key := types.NamespacedName{Name: r.Name, Namespace: r.Namespace} + u := &unstructured.Unstructured{} + u.SetGroupVersionKind(CloudIdentityGroupGVK) + if err := reader.Get(ctx, key, u); err != nil { + if apierrors.IsNotFound(err) { + return "", k8s.NewReferenceNotFoundError(u.GroupVersionKind(), key) + } + return "", fmt.Errorf("reading referenced %s %s: %w", CloudIdentityGroupGVK, key, err) + } + // Get external from status.externalRef. This is the most trustworthy place. + actualExternalRef, _, err := unstructured.NestedString(u.Object, "status", "externalRef") + if err != nil { + return "", fmt.Errorf("reading status.externalRef: %w", err) + } + if actualExternalRef == "" { + return "", k8s.NewReferenceNotReadyError(u.GroupVersionKind(), key) + } + r.External = actualExternalRef + return r.External, nil +} diff --git a/apis/cloudidentity/v1beta1/group_types.go b/apis/cloudidentity/v1beta1/group_types.go new file mode 100644 index 00000000000..93f8d9d6e38 --- /dev/null +++ b/apis/cloudidentity/v1beta1/group_types.go @@ -0,0 +1,147 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package v1beta1 + +import ( + "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/k8s/v1alpha1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +var CloudIdentityGroupGVK = GroupVersion.WithKind("CloudIdentityGroup") + +type GroupGroupKey struct { + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Id field is immutable" + /* Immutable. The ID of the entity. + + For Google-managed entities, the id must be the email address of an existing + group or user. + + For external-identity-mapped entities, the id must be a string conforming + to the Identity Source's requirements. + + Must be unique within a namespace. */ + // +required + Id string `json:"id"` + + /* Immutable. The namespace in which the entity exists. + + If not specified, the EntityKey represents a Google-managed entity + such as a Google user or a Google Group. + + If specified, the EntityKey represents an external-identity-mapped group. + The namespace must correspond to an identity source created in Admin Console + and must be in the form of 'identitysources/{identity_source_id}'. */ + Namespace *string `json:"namespace,omitempty"` +} + +type CloudIdentityGroupSpec struct { + /* An extended description to help users determine the purpose of a Group. + Must not be longer than 4,096 characters. */ + Description *string `json:"description,omitempty"` + + /* The display name of the Group. */ + DisplayName *string `json:"displayName,omitempty"` + + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="GroupKey field is immutable" + /* Immutable. EntityKey of the Group. */ + // +required + GroupKey GroupGroupKey `json:"groupKey"` + + /* Immutable. The initial configuration options for creating a Group. + + See the + [API reference](https://cloud.google.com/identity/docs/reference/rest/v1beta1/groups/create#initialgroupconfig) + for possible values. Default value: "EMPTY" Possible values: ["INITIAL_GROUP_CONFIG_UNSPECIFIED", "WITH_INITIAL_OWNER", "EMPTY"]. */ + InitialGroupConfig *string `json:"initialGroupConfig,omitempty"` + + /* One or more label entries that apply to the Group. Currently supported labels contain a key with an empty value. + + Google Groups are the default type of group and have a label with a key of cloudidentity.googleapis.com/groups.discussion_forum and an empty value. + + Existing Google Groups can have an additional label with a key of cloudidentity.googleapis.com/groups.security and an empty value added to them. This is an immutable change and the security label cannot be removed once added. + + Dynamic groups have a label with a key of cloudidentity.googleapis.com/groups.dynamic. + + Identity-mapped groups for Cloud Search have a label with a key of system/groups/external and an empty value. */ + // +required + Labels map[string]string `json:"labels"` + + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Parent field is immutable" + /* Immutable. The resource name of the entity under which this Group resides in the + Cloud Identity resource hierarchy. + + Must be of the form identitysources/{identity_source_id} for external-identity-mapped + groups or customers/{customer_id} for Google Groups. */ + // +required + Parent string `json:"parent"` + + /* Immutable. The service-generated name of the resource. Used for acquisition only. Leave unset to create a new resource. */ + ResourceID *string `json:"resourceID,omitempty"` +} + +type CloudIdentityGroupStatus struct { + /* Conditions represent the latest available observations of the + CloudIdentityGroup's current state. */ + Conditions []v1alpha1.Condition `json:"conditions,omitempty"` + + /* The time when the Group was created. */ + CreateTime *string `json:"createTime,omitempty"` + + /* Resource name of the Group in the format: groups/{group_id}, where group_id + is the unique ID assigned to the Group. */ + Name *string `json:"name,omitempty"` + + // A unique specifier for the CloudIdentityGroup resource in GCP. + ExternalRef *string `json:"externalRef,omitempty"` + + /* ObservedGeneration is the generation of the resource that was most recently observed by the Config Connector controller. If this is equal to metadata.generation, then that means that the current reported status reflects the most recent desired state of the resource. */ + ObservedGeneration *int64 `json:"observedGeneration,omitempty"` + + /* The time when the Group was last updated. */ + UpdateTime *string `json:"updateTime,omitempty"` +} + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:categories=gcp,shortName=gcpcloudidentitygroup;gcpcloudidentitygroups +// +kubebuilder:subresource:status +// +kubebuilder:metadata:labels="cnrm.cloud.google.com/managed-by-kcc=true";"cnrm.cloud.google.com/stability-level=stable";"cnrm.cloud.google.com/system=true";"cnrm.cloud.google.com/tf2crd=true" +// +kubebuilder:printcolumn:name="Age",JSONPath=".metadata.creationTimestamp",type="date" +// +kubebuilder:printcolumn:name="Ready",JSONPath=".status.conditions[?(@.type=='Ready')].status",type="string",description="When 'True', the most recent reconcile of the resource succeeded" +// +kubebuilder:printcolumn:name="Status",JSONPath=".status.conditions[?(@.type=='Ready')].reason",type="string",description="The reason for the value in 'Ready'" +// +kubebuilder:printcolumn:name="Status Age",JSONPath=".status.conditions[?(@.type=='Ready')].lastTransitionTime",type="date",description="The last transition time for the value in 'Status'" + +// CloudIdentityGroup is the Schema for the cloudidentity API +// +k8s:openapi-gen=true +type CloudIdentityGroup struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec CloudIdentityGroupSpec `json:"spec,omitempty"` + Status CloudIdentityGroupStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// CloudIdentityGroupList contains a list of CloudIdentityGroup +type CloudIdentityGroupList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []CloudIdentityGroup `json:"items"` +} + +func init() { + SchemeBuilder.Register(&CloudIdentityGroup{}, &CloudIdentityGroupList{}) +} diff --git a/apis/cloudidentity/v1beta1/groupversion_info.go b/apis/cloudidentity/v1beta1/groupversion_info.go new file mode 100644 index 00000000000..4d7d18dec05 --- /dev/null +++ b/apis/cloudidentity/v1beta1/groupversion_info.go @@ -0,0 +1,33 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +kubebuilder:object:generate=true +// +groupName=cloudidentity.cnrm.cloud.google.com +package v1beta1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +var ( + // GroupVersion is group version used to register these objects + GroupVersion = schema.GroupVersion{Group: "cloudidentity.cnrm.cloud.google.com", Version: "v1beta1"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) diff --git a/apis/cloudidentity/v1beta1/zz_generated.deepcopy.go b/apis/cloudidentity/v1beta1/zz_generated.deepcopy.go new file mode 100644 index 00000000000..0d8641b8d1f --- /dev/null +++ b/apis/cloudidentity/v1beta1/zz_generated.deepcopy.go @@ -0,0 +1,221 @@ +//go:build !ignore_autogenerated + +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by controller-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/k8s/v1alpha1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CloudIdentityGroup) DeepCopyInto(out *CloudIdentityGroup) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CloudIdentityGroup. +func (in *CloudIdentityGroup) DeepCopy() *CloudIdentityGroup { + if in == nil { + return nil + } + out := new(CloudIdentityGroup) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *CloudIdentityGroup) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CloudIdentityGroupList) DeepCopyInto(out *CloudIdentityGroupList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]CloudIdentityGroup, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CloudIdentityGroupList. +func (in *CloudIdentityGroupList) DeepCopy() *CloudIdentityGroupList { + if in == nil { + return nil + } + out := new(CloudIdentityGroupList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *CloudIdentityGroupList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CloudIdentityGroupSpec) DeepCopyInto(out *CloudIdentityGroupSpec) { + *out = *in + if in.Description != nil { + in, out := &in.Description, &out.Description + *out = new(string) + **out = **in + } + if in.DisplayName != nil { + in, out := &in.DisplayName, &out.DisplayName + *out = new(string) + **out = **in + } + in.GroupKey.DeepCopyInto(&out.GroupKey) + if in.InitialGroupConfig != nil { + in, out := &in.InitialGroupConfig, &out.InitialGroupConfig + *out = new(string) + **out = **in + } + if in.Labels != nil { + in, out := &in.Labels, &out.Labels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.ResourceID != nil { + in, out := &in.ResourceID, &out.ResourceID + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CloudIdentityGroupSpec. +func (in *CloudIdentityGroupSpec) DeepCopy() *CloudIdentityGroupSpec { + if in == nil { + return nil + } + out := new(CloudIdentityGroupSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CloudIdentityGroupStatus) DeepCopyInto(out *CloudIdentityGroupStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1alpha1.Condition, len(*in)) + copy(*out, *in) + } + if in.CreateTime != nil { + in, out := &in.CreateTime, &out.CreateTime + *out = new(string) + **out = **in + } + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(string) + **out = **in + } + if in.ExternalRef != nil { + in, out := &in.ExternalRef, &out.ExternalRef + *out = new(string) + **out = **in + } + if in.ObservedGeneration != nil { + in, out := &in.ObservedGeneration, &out.ObservedGeneration + *out = new(int64) + **out = **in + } + if in.UpdateTime != nil { + in, out := &in.UpdateTime, &out.UpdateTime + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CloudIdentityGroupStatus. +func (in *CloudIdentityGroupStatus) DeepCopy() *CloudIdentityGroupStatus { + if in == nil { + return nil + } + out := new(CloudIdentityGroupStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GroupGroupKey) DeepCopyInto(out *GroupGroupKey) { + *out = *in + if in.Namespace != nil { + in, out := &in.Namespace, &out.Namespace + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GroupGroupKey. +func (in *GroupGroupKey) DeepCopy() *GroupGroupKey { + if in == nil { + return nil + } + out := new(GroupGroupKey) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GroupIdentity) DeepCopyInto(out *GroupIdentity) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GroupIdentity. +func (in *GroupIdentity) DeepCopy() *GroupIdentity { + if in == nil { + return nil + } + out := new(GroupIdentity) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GroupRef) DeepCopyInto(out *GroupRef) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GroupRef. +func (in *GroupRef) DeepCopy() *GroupRef { + if in == nil { + return nil + } + out := new(GroupRef) + in.DeepCopyInto(out) + return out +} diff --git a/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_cloudidentitygroups.cloudidentity.cnrm.cloud.google.com.yaml b/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_cloudidentitygroups.cloudidentity.cnrm.cloud.google.com.yaml index 8d93d95f84b..866e8efc414 100644 --- a/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_cloudidentitygroups.cloudidentity.cnrm.cloud.google.com.yaml +++ b/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_cloudidentitygroups.cloudidentity.cnrm.cloud.google.com.yaml @@ -16,6 +16,7 @@ spec: categories: - gcp kind: CloudIdentityGroup + listKind: CloudIdentityGroupList plural: cloudidentitygroups shortNames: - gcpcloudidentitygroup @@ -43,25 +44,25 @@ spec: name: v1beta1 schema: openAPIV3Schema: + description: CloudIdentityGroup is the Schema for the cloudidentity API properties: apiVersion: - description: 'apiVersion defines the versioned schema of this representation + description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources' + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' type: string kind: - description: 'kind is a string value representing the REST resource this + description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds' + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' type: string metadata: type: object spec: properties: description: - description: |- - An extended description to help users determine the purpose of a Group. - Must not be longer than 4,096 characters. + description: An extended description to help users determine the purpose + of a Group. Must not be longer than 4,096 characters. type: string displayName: description: The display name of the Group. @@ -81,6 +82,9 @@ spec: Must be unique within a namespace. type: string + x-kubernetes-validations: + - message: Id field is immutable + rule: self == oldSelf namespace: description: |- Immutable. The namespace in which the entity exists. @@ -95,6 +99,9 @@ spec: required: - id type: object + x-kubernetes-validations: + - message: GroupKey field is immutable + rule: self == oldSelf initialGroupConfig: description: |- Immutable. The initial configuration options for creating a Group. @@ -125,10 +132,12 @@ spec: Must be of the form identitysources/{identity_source_id} for external-identity-mapped groups or customers/{customer_id} for Google Groups. type: string + x-kubernetes-validations: + - message: Parent field is immutable + rule: self == oldSelf resourceID: - description: Immutable. Optional. The service-generated name of the - resource. Used for acquisition only. Leave unset to create a new - resource. + description: Immutable. The service-generated name of the resource. + Used for acquisition only. Leave unset to create a new resource. type: string required: - groupKey @@ -138,8 +147,8 @@ spec: status: properties: conditions: - description: Conditions represent the latest available observation - of the resource's current state. + description: Conditions represent the latest available observations + of the CloudIdentityGroup's current state. items: properties: lastTransitionTime: @@ -166,10 +175,13 @@ spec: createTime: description: The time when the Group was created. type: string + externalRef: + description: A unique specifier for the CloudIdentityGroup resource + in GCP. + type: string name: - description: |- - Resource name of the Group in the format: groups/{group_id}, where group_id - is the unique ID assigned to the Group. + description: 'Resource name of the Group in the format: groups/{group_id}, + where group_id is the unique ID assigned to the Group.' type: string observedGeneration: description: ObservedGeneration is the generation of the resource @@ -177,21 +189,14 @@ spec: If this is equal to metadata.generation, then that means that the current reported status reflects the most recent desired state of the resource. + format: int64 type: integer updateTime: description: The time when the Group was last updated. type: string type: object - required: - - spec type: object served: true storage: true subresources: status: {} -status: - acceptedNames: - kind: "" - plural: "" - conditions: [] - storedVersions: [] diff --git a/dev/tools/proto-to-mapper/Makefile b/dev/tools/proto-to-mapper/Makefile index a15a01815cd..dc1385092ee 100644 --- a/dev/tools/proto-to-mapper/Makefile +++ b/dev/tools/proto-to-mapper/Makefile @@ -11,6 +11,7 @@ generate-pb: install-protoc-linux -I ./third_party/googleapis/ \ -I ../../../mockgcp/apis \ ../../../mockgcp/apis/mockgcp/cloud/networkconnectivity/*/*.proto \ + ../../../mockgcp/apis/mockgcp/cloud/cloudidentity/groups/*/*.proto \ ./third_party/googleapis/google/api/*.proto \ ./third_party/googleapis/google/api/*/*/*.proto \ ./third_party/googleapis/google/bigtable/*/*/*.proto \ diff --git a/mockgcp/Makefile b/mockgcp/Makefile index 60c2bd87e9b..5e1bcb9113e 100644 --- a/mockgcp/Makefile +++ b/mockgcp/Makefile @@ -45,14 +45,14 @@ gen-proto-no-fixup: --grpc-gateway_opt logtostderr=true \ --grpc-gateway_opt paths=source_relative \ --experimental_allow_proto3_optional \ + ./apis/mockgcp/cloud/apigee/v1/*.proto \ ./apis/mockgcp/cloud/bigquery/v2/*.proto \ + ./apis/mockgcp/cloud/cloudidentity/groups/v1beta1/*.proto \ ./apis/mockgcp/cloud/ids/v1/*.proto \ ./apis/mockgcp/cloud/networkconnectivity/v1/*.proto \ ./apis/mockgcp/cloud/servicenetworking/v1/*.proto \ ./apis/mockgcp/cloud/resourcemanager/v1/*.proto \ - ./apis/google/apps/cloudidentity/groups/v1beta1/*.proto \ ./apis/mockgcp/storage/v1/*.proto \ - ./apis/mockgcp/cloud/apigee/v1/*.proto \ ./third_party/googleapis/mockgcp/api/apikeys/v2/*.proto \ ./third_party/googleapis/mockgcp/api/serviceusage/v1/*.proto \ ./third_party/googleapis/mockgcp/api/serviceusage/v1beta1/*.proto \ @@ -167,7 +167,7 @@ generate-protos-from-openapi: cd tools/gapic; go run . --proto-package mockgcp.cloud.apigee.v1 ../../temp/apigee-v1.json > ../../apis/mockgcp/cloud/apigee/v1/service.proto wget -O temp/cloudidentity-api.json https://raw.githubusercontent.com/googleapis/google-api-go-client/refs/heads/main/cloudidentity/v1beta1/cloudidentity-api.json - mkdir -p apis/google/apps/cloudidentity/groups/v1beta1/ - cd tools/gapic; go run . --proto-version=2 --proto-package google.apps.cloudidentity.groups.v1beta1 ../../temp/cloudidentity-api.json > ../../apis/google/apps/cloudidentity/groups/v1beta1//service.proto + mkdir -p apis/mockgcp/cloud/cloudidentity/groups/v1beta1/ + cd tools/gapic; go run . --proto-version=2 --proto-package mockgcp.cloud.cloudidentity.groups.v1beta1 ../../temp/cloudidentity-api.json > ../../apis/mockgcp/cloud/cloudidentity/groups/v1beta1//service.proto rm -r temp diff --git a/mockgcp/apis/google/apps/cloudidentity/groups/v1beta1/service.proto b/mockgcp/apis/mockgcp/cloud/cloudidentity/groups/v1beta1/service.proto similarity index 99% rename from mockgcp/apis/google/apps/cloudidentity/groups/v1beta1/service.proto rename to mockgcp/apis/mockgcp/cloud/cloudidentity/groups/v1beta1/service.proto index 7ef865467f0..5beba49cf13 100644 --- a/mockgcp/apis/google/apps/cloudidentity/groups/v1beta1/service.proto +++ b/mockgcp/apis/mockgcp/cloud/cloudidentity/groups/v1beta1/service.proto @@ -13,7 +13,7 @@ // limitations under the License. syntax = "proto2"; -package google.apps.cloudidentity.groups.v1beta1; +package mockgcp.cloud.cloudidentity.groups.v1beta1; import "google/api/annotations.proto"; import "google/longrunning/operations.proto"; import "google/protobuf/any.proto"; diff --git a/scripts/generate-google3-docs/resource-reference/generated/resource-docs/cloudidentity/cloudidentitygroup.md b/scripts/generate-google3-docs/resource-reference/generated/resource-docs/cloudidentity/cloudidentitygroup.md index 56b05f16667..425e0548e5f 100644 --- a/scripts/generate-google3-docs/resource-reference/generated/resource-docs/cloudidentity/cloudidentitygroup.md +++ b/scripts/generate-google3-docs/resource-reference/generated/resource-docs/cloudidentity/cloudidentitygroup.md @@ -89,8 +89,7 @@ resourceID: string

string

-

{% verbatim %}An extended description to help users determine the purpose of a Group. -Must not be longer than 4,096 characters.{% endverbatim %}

+

{% verbatim %}An extended description to help users determine the purpose of a Group. Must not be longer than 4,096 characters.{% endverbatim %}

@@ -106,7 +105,7 @@ Must not be longer than 4,096 characters.{% endverbatim %}

groupKey

-

Required

+

Required*

object

@@ -116,7 +115,7 @@ Must not be longer than 4,096 characters.{% endverbatim %}

groupKey.id

-

Required

+

Required*

string

@@ -165,7 +164,7 @@ for possible values. Default value: "EMPTY" Possible values: ["INITIAL_GROUP_CON

labels

-

Required

+

Required*

map (key: string, value: string)

@@ -183,7 +182,7 @@ Identity-mapped groups for Cloud Search have a label with a key of system/groups

parent

-

Required

+

Required*

string

@@ -201,13 +200,15 @@ groups or customers/{customer_id} for Google Groups.{% endverbatim %}

string

-

{% verbatim %}Immutable. Optional. The service-generated name of the resource. Used for acquisition only. Leave unset to create a new resource.{% endverbatim %}

+

{% verbatim %}Immutable. The service-generated name of the resource. Used for acquisition only. Leave unset to create a new resource.{% endverbatim %}

+

* Field is required when parent field is specified

+ ### Status #### Schema @@ -219,6 +220,7 @@ conditions: status: string type: string createTime: string +externalRef: string name: string observedGeneration: integer updateTime: string @@ -235,7 +237,7 @@ updateTime: string conditions

list (object)

-

{% verbatim %}Conditions represent the latest available observation of the resource's current state.{% endverbatim %}

+

{% verbatim %}Conditions represent the latest available observations of the CloudIdentityGroup's current state.{% endverbatim %}

@@ -287,12 +289,18 @@ updateTime: string

{% verbatim %}The time when the Group was created.{% endverbatim %}

+ + externalRef + +

string

+

{% verbatim %}A unique specifier for the CloudIdentityGroup resource in GCP.{% endverbatim %}

+ + name

string

-

{% verbatim %}Resource name of the Group in the format: groups/{group_id}, where group_id -is the unique ID assigned to the Group.{% endverbatim %}

+

{% verbatim %}Resource name of the Group in the format: groups/{group_id}, where group_id is the unique ID assigned to the Group.{% endverbatim %}