diff --git a/apis/tags/v1beta1/doc.go b/apis/tags/v1beta1/doc.go new file mode 100644 index 00000000000..94b97ec8b21 --- /dev/null +++ b/apis/tags/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=google.cloud.resourcemanager.v3 +package v1beta1 diff --git a/apis/tags/v1beta1/generate.sh b/apis/tags/v1beta1/generate.sh new file mode 100755 index 00000000000..60d3d5d1b3b --- /dev/null +++ b/apis/tags/v1beta1/generate.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# 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. + + +set -o errexit +set -o nounset +set -o pipefail + +REPO_ROOT="$(git rev-parse --show-toplevel)" +cd ${REPO_ROOT}/dev/tools/controllerbuilder + +go run . generate-types \ + --service google.cloud.resourcemanager.v3 \ + --api-version tags.cnrm.cloud.google.com/v1beta1 \ + --resource TagsTagBinding:TagBinding + +go run . generate-mapper --service google.cloud.resourcemanager.v3 --api-version tags.cnrm.cloud.google.com/v1beta1 + +cd ${REPO_ROOT} +dev/tasks/generate-crds + +go run -mod=readonly golang.org/x/tools/cmd/goimports@latest -w pkg/controller/direct/tags/ \ No newline at end of file diff --git a/apis/tags/v1beta1/groupversion_info.go b/apis/tags/v1beta1/groupversion_info.go new file mode 100644 index 00000000000..c1769bf4c36 --- /dev/null +++ b/apis/tags/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=tags.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: "tags.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/tags/v1beta1/tagbinding_identity.go b/apis/tags/v1beta1/tagbinding_identity.go new file mode 100644 index 00000000000..ab282e302b9 --- /dev/null +++ b/apis/tags/v1beta1/tagbinding_identity.go @@ -0,0 +1,15 @@ +// 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 diff --git a/apis/tags/v1beta1/tagbinding_reference.go b/apis/tags/v1beta1/tagbinding_reference.go new file mode 100644 index 00000000000..ab282e302b9 --- /dev/null +++ b/apis/tags/v1beta1/tagbinding_reference.go @@ -0,0 +1,15 @@ +// 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 diff --git a/apis/tags/v1beta1/tagbinding_types.go b/apis/tags/v1beta1/tagbinding_types.go new file mode 100644 index 00000000000..f77e034d342 --- /dev/null +++ b/apis/tags/v1beta1/tagbinding_types.go @@ -0,0 +1,111 @@ +// 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/apis/k8s/v1alpha1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +var TagsTagBindingGVK = GroupVersion.WithKind("TagsTagBinding") + +// TagsTagBindingSpec defines the desired state of TagsTagBinding +// +kcc:spec:proto=google.cloud.resourcemanager.v3.TagBinding +type TagsTagBindingSpec struct { + // +kcc:ref=Project + ParentRef *ParentRef `json:"parentRef"` + + // +kcc:ref=TagsTagValue + TagValueRef *TagsTagValueRef `json:"tagValueRef"` + + // The service-generated name of the resource. Used for acquisition only. Leave unset to create a new + // resource. + ResourceID *string `json:"resourceID,omitempty"` +} + +// ParentRef is a reference to a parent resource. +// +kcc:ref=Project +type ParentRef struct { + // Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + Name string `json:"name,omitempty"` + + // Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ + Namespace string `json:"namespace,omitempty"` + + // Allowed value: string of the format `//cloudresourcemanager.googleapis.com/projects/{{value}}`, + // where {{value}} is the `number` field of a `Project` resource. + External string `json:"external,omitempty"` +} + +// TagsTagBindingStatus defines the config connector machine state of TagsTagBinding +type TagsTagBindingStatus struct { + /* Conditions represent the latest available observations of the + object's current state. */ + Conditions []v1alpha1.Condition `json:"conditions,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 generated id for the TagBinding. This is a string of the form: tagBindings/{full-resource-name}/{tag-value-name}. + Name *string `json:"name,omitempty"` + + // A unique specifier for the TagsTagBinding resource in GCP. + ExternalRef *string `json:"externalRef,omitempty"` + + // ObservedState is the state of the resource as most recently observed in GCP. + // ObservedState *TagsTagBindingObservedState `json:"observedState,omitempty"` +} + +// TagsTagBindingObservedState is the state of the TagsTagBinding resource as most recently observed in GCP. +// +kcc:observedstate:proto=google.cloud.resourcemanager.v3.TagBinding +type TagsTagBindingObservedState struct { + // Output only. The name of the TagBinding. This is a String of the form: + // `tagBindings/{full-resource-name}/{tag-value-name}` + // (e.g. `tagBindings/%2F%2Fcloudresourcemanager.googleapis.com%2Fprojects%2F123/tagValues/456`). + Name *string `json:"name,omitempty"` +} + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:categories=gcp,shortName=gcptagstagbinding;gcptagstagbindings +// +kubebuilder:subresource:status +// +kubebuilder:metadata:labels="cnrm.cloud.google.com/managed-by-kcc=true";"cnrm.cloud.google.com/stability-level=alpha";"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'" + +// TagsTagBinding is the Schema for the TagsTagBinding API +// +k8s:openapi-gen=true +type TagsTagBinding struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // +required + Spec TagsTagBindingSpec `json:"spec,omitempty"` + Status TagsTagBindingStatus `json:"status,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// TagsTagBindingList contains a list of TagsTagBinding +type TagsTagBindingList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []TagsTagBinding `json:"items"` +} + +func init() { + SchemeBuilder.Register(&TagsTagBinding{}, &TagsTagBindingList{}) +} diff --git a/apis/tags/v1beta1/tagvalue_reference.go b/apis/tags/v1beta1/tagvalue_reference.go new file mode 100644 index 00000000000..61a9d2dd45e --- /dev/null +++ b/apis/tags/v1beta1/tagvalue_reference.go @@ -0,0 +1,29 @@ +// 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 + +// TagsTagValueRef is a reference to a TagsTagValue resource. +// +kcc:ref=TagsTagValue +type TagsTagValueRef struct { + // Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names + Name string `json:"name,omitempty"` + + // Namespace of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ + Namespace string `json:"namespace,omitempty"` + + // Allowed value: string of the format `tagValues/{{value}}`, + // where {{value}} is the `name` field of a `TagsTagValue` resource. + External string `json:"external,omitempty"` +} diff --git a/apis/tags/v1beta1/types.generated.go b/apis/tags/v1beta1/types.generated.go new file mode 100644 index 00000000000..b822ecee103 --- /dev/null +++ b/apis/tags/v1beta1/types.generated.go @@ -0,0 +1,21 @@ +// 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. + +// +generated:types +// krm.group: tags.cnrm.cloud.google.com +// krm.version: v1beta1 +// proto.service: google.cloud.resourcemanager.v3 +// resource: TagsTagBinding:TagBinding + +package v1beta1 diff --git a/apis/tags/v1beta1/zz_generated.deepcopy.go b/apis/tags/v1beta1/zz_generated.deepcopy.go new file mode 100644 index 00000000000..74dc8daf097 --- /dev/null +++ b/apis/tags/v1beta1/zz_generated.deepcopy.go @@ -0,0 +1,198 @@ +//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/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 *ParentRef) DeepCopyInto(out *ParentRef) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ParentRef. +func (in *ParentRef) DeepCopy() *ParentRef { + if in == nil { + return nil + } + out := new(ParentRef) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TagsTagBinding) DeepCopyInto(out *TagsTagBinding) { + *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 TagsTagBinding. +func (in *TagsTagBinding) DeepCopy() *TagsTagBinding { + if in == nil { + return nil + } + out := new(TagsTagBinding) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TagsTagBinding) 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 *TagsTagBindingList) DeepCopyInto(out *TagsTagBindingList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]TagsTagBinding, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TagsTagBindingList. +func (in *TagsTagBindingList) DeepCopy() *TagsTagBindingList { + if in == nil { + return nil + } + out := new(TagsTagBindingList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TagsTagBindingList) 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 *TagsTagBindingObservedState) DeepCopyInto(out *TagsTagBindingObservedState) { + *out = *in + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TagsTagBindingObservedState. +func (in *TagsTagBindingObservedState) DeepCopy() *TagsTagBindingObservedState { + if in == nil { + return nil + } + out := new(TagsTagBindingObservedState) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TagsTagBindingSpec) DeepCopyInto(out *TagsTagBindingSpec) { + *out = *in + if in.ParentRef != nil { + in, out := &in.ParentRef, &out.ParentRef + *out = new(ParentRef) + **out = **in + } + if in.TagValueRef != nil { + in, out := &in.TagValueRef, &out.TagValueRef + *out = new(TagsTagValueRef) + **out = **in + } + 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 TagsTagBindingSpec. +func (in *TagsTagBindingSpec) DeepCopy() *TagsTagBindingSpec { + if in == nil { + return nil + } + out := new(TagsTagBindingSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TagsTagBindingStatus) DeepCopyInto(out *TagsTagBindingStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]v1alpha1.Condition, len(*in)) + copy(*out, *in) + } + if in.ObservedGeneration != nil { + in, out := &in.ObservedGeneration, &out.ObservedGeneration + *out = new(int64) + **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 + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TagsTagBindingStatus. +func (in *TagsTagBindingStatus) DeepCopy() *TagsTagBindingStatus { + if in == nil { + return nil + } + out := new(TagsTagBindingStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TagsTagValueRef) DeepCopyInto(out *TagsTagValueRef) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TagsTagValueRef. +func (in *TagsTagValueRef) DeepCopy() *TagsTagValueRef { + if in == nil { + return nil + } + out := new(TagsTagValueRef) + in.DeepCopyInto(out) + return out +} diff --git a/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_tagstagbindings.tags.cnrm.cloud.google.com.yaml b/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_tagstagbindings.tags.cnrm.cloud.google.com.yaml index 0c1af338b4f..2fc4bc8795e 100644 --- a/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_tagstagbindings.tags.cnrm.cloud.google.com.yaml +++ b/config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_tagstagbindings.tags.cnrm.cloud.google.com.yaml @@ -16,6 +16,7 @@ spec: categories: - gcp kind: TagsTagBinding + listKind: TagsTagBindingList plural: tagstagbindings shortNames: - gcptagstagbinding @@ -43,22 +44,25 @@ spec: name: v1beta1 schema: openAPIV3Schema: + description: TagsTagBinding is the Schema for the TagsTagBinding 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: + description: TagsTagBindingSpec defines the desired state of TagsTagBinding properties: parentRef: + description: ParentRef is a reference to a parent resource. oneOf: - not: required: @@ -86,11 +90,11 @@ spec: type: string type: object resourceID: - description: Immutable. Optional. The service-generated name of the - resource. Used for acquisition only. Leave unset to create a new - resource. + description: The service-generated name of the resource. Used for + acquisition only. Leave unset to create a new resource. type: string tagValueRef: + description: TagsTagValueRef is a reference to a TagsTagValue resource. oneOf: - not: required: @@ -122,10 +126,12 @@ spec: - tagValueRef type: object status: + description: TagsTagBindingStatus defines the config connector machine + state of TagsTagBinding properties: conditions: - description: Conditions represent the latest available observation - of the resource's current state. + description: Conditions represent the latest available observations + of the object's current state. items: properties: lastTransitionTime: @@ -149,9 +155,13 @@ spec: type: string type: object type: array + externalRef: + description: A unique specifier for the TagsTagBinding resource in + GCP. + type: string name: description: 'The generated id for the TagBinding. This is a string - of the form: ''tagBindings/{full-resource-name}/{tag-value-name}''.' + of the form: tagBindings/{full-resource-name}/{tag-value-name}.' type: string observedGeneration: description: ObservedGeneration is the generation of the resource @@ -159,6 +169,7 @@ 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 type: object required: @@ -168,9 +179,3 @@ spec: storage: true subresources: status: {} -status: - acceptedNames: - kind: "" - plural: "" - conditions: [] - storedVersions: [] diff --git a/pkg/controller/direct/register/register.go b/pkg/controller/direct/register/register.go index fc0ff3d9f70..baa0532867f 100644 --- a/pkg/controller/direct/register/register.go +++ b/pkg/controller/direct/register/register.go @@ -88,6 +88,7 @@ import ( _ "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct/speech" _ "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct/sql" _ "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct/storage/control" + _ "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct/tags" _ "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct/tpu" _ "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct/vertexai" _ "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct/vmwareengine" diff --git a/pkg/controller/direct/tags/mapper.generated.go b/pkg/controller/direct/tags/mapper.generated.go new file mode 100644 index 00000000000..ba88043cd88 --- /dev/null +++ b/pkg/controller/direct/tags/mapper.generated.go @@ -0,0 +1,73 @@ +// 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. + +// +generated:mapper +// krm.group: tags.cnrm.cloud.google.com +// krm.version: v1beta1 +// proto.service: google.cloud.resourcemanager.v3 + +package tags + +import ( + pb "cloud.google.com/go/resourcemanager/apiv3/resourcemanagerpb" + krm "github.com/GoogleCloudPlatform/k8s-config-connector/apis/tags/v1beta1" + "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/controller/direct" +) + +func TagsTagBindingObservedState_FromProto(mapCtx *direct.MapContext, in *pb.TagBinding) *krm.TagsTagBindingObservedState { + if in == nil { + return nil + } + out := &krm.TagsTagBindingObservedState{} + out.Name = direct.LazyPtr(in.GetName()) + // MISSING: TagValueNamespacedName + return out +} +func TagsTagBindingObservedState_ToProto(mapCtx *direct.MapContext, in *krm.TagsTagBindingObservedState) *pb.TagBinding { + if in == nil { + return nil + } + out := &pb.TagBinding{} + out.Name = direct.ValueOf(in.Name) + // MISSING: TagValueNamespacedName + return out +} +func TagsTagBindingSpec_FromProto(mapCtx *direct.MapContext, in *pb.TagBinding) *krm.TagsTagBindingSpec { + if in == nil { + return nil + } + out := &krm.TagsTagBindingSpec{} + if in.GetParent() != "" { + out.ParentRef = &krm.ParentRef{External: in.GetParent()} + } + if in.GetTagValue() != "" { + out.TagValueRef = &krm.TagsTagValueRef{External: in.GetTagValue()} + } + // MISSING: TagValueNamespacedName + return out +} +func TagsTagBindingSpec_ToProto(mapCtx *direct.MapContext, in *krm.TagsTagBindingSpec) *pb.TagBinding { + if in == nil { + return nil + } + out := &pb.TagBinding{} + if in.ParentRef != nil { + out.Parent = in.ParentRef.External + } + if in.TagValueRef != nil { + out.TagValue = in.TagValueRef.External + } + // MISSING: TagValueNamespacedName + return out +} diff --git a/pkg/controller/direct/tags/tagbinding_fuzzer.go b/pkg/controller/direct/tags/tagbinding_fuzzer.go new file mode 100644 index 00000000000..8175aa320ce --- /dev/null +++ b/pkg/controller/direct/tags/tagbinding_fuzzer.go @@ -0,0 +1,46 @@ +// 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. + +//go:generate go run github.com/GoogleCloudPlatform/k8s-config-connector/dev/tools/controllerbuilder/fuzz-gen + +// +tool:fuzz-gen +// proto.message: google.cloud.resourcemanager.v3.TagBinding +// api.group: tags.cnrm.cloud.google.com + +package tags + +import ( + "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/fuzztesting" + pb "google.golang.org/genproto/googleapis/cloud/resourcemanager/v3" +) + +func init() { + fuzztesting.RegisterKRMFuzzer(tagsTagBindingFuzzer()) +} + +func tagsTagBindingFuzzer() fuzztesting.KRMFuzzer { + f := fuzztesting.NewKRMTypedFuzzer(&pb.TagBinding{}, + TagsTagBindingSpec_FromProto, TagsTagBindingSpec_ToProto, + TagsTagBindingObservedState_FromProto, TagsTagBindingObservedState_ToProto, + ) + + f.SpecFields.Insert(".parent") + f.SpecFields.Insert(".tag_value") + + f.StatusFields.Insert(".name") + + f.UnimplementedFields.Insert(".tag_value_namespaced_name") + + return f +}