From fc1c648769729af691b63e258565e9f29a9ae543 Mon Sep 17 00:00:00 2001 From: Brad Wadsworth Date: Fri, 16 Dec 2022 10:43:43 -0600 Subject: [PATCH 1/5] gcp: add folder iam Signed-off-by: Brad Wadsworth --- apis/bigquery/v1beta1/zz_job_types.go | 4 +- .../v1beta1/zz_folderiammember_types.go | 111 ++++++ .../v1beta1/zz_generated.deepcopy.go | 202 ++++++++++- .../v1beta1/zz_generated.managed.go | 66 ++++ .../v1beta1/zz_generated.managedlist.go | 9 + .../v1beta1/zz_generated_terraformed.go | 74 ++++ .../v1beta1/zz_organizationiammember_types.go | 6 +- config/external_name.go | 2 + examples/cloudplatform/folderiammember.yaml | 13 + .../folderiammember/zz_controller.go | 63 ++++ internal/controller/zz_setup.go | 2 + .../crds/bigquery.gcp.upbound.io_jobs.yaml | 8 +- ...tform.gcp.upbound.io_folderiammembers.yaml | 319 ++++++++++++++++++ 13 files changed, 869 insertions(+), 10 deletions(-) create mode 100755 apis/cloudplatform/v1beta1/zz_folderiammember_types.go create mode 100644 examples/cloudplatform/folderiammember.yaml create mode 100755 internal/controller/cloudplatform/folderiammember/zz_controller.go create mode 100644 package/crds/cloudplatform.gcp.upbound.io_folderiammembers.yaml diff --git a/apis/bigquery/v1beta1/zz_job_types.go b/apis/bigquery/v1beta1/zz_job_types.go index 30e6fb761..c74bd724e 100755 --- a/apis/bigquery/v1beta1/zz_job_types.go +++ b/apis/bigquery/v1beta1/zz_job_types.go @@ -478,11 +478,11 @@ type LoadParameters struct { SourceFormat *string `json:"sourceFormat,omitempty" tf:"source_format,omitempty"` // The fully-qualified URIs that point to your data in Google Cloud. - // For Google Cloud Storage URIs: Each URI can contain one ” wildcard character + // For Google Cloud Storage URIs: Each URI can contain one '' wildcard character // and it must come after the 'bucket' name. Size limits related to load jobs apply // to external data sources. For Google Cloud Bigtable URIs: Exactly one URI can be // specified and it has be a fully specified and valid HTTPS URL for a Google Cloud Bigtable table. - // For Google Cloud Datastore backups: Exactly one URI can be specified. Also, the ” wildcard character is not allowed. + // For Google Cloud Datastore backups: Exactly one URI can be specified. Also, the '' wildcard character is not allowed. // +kubebuilder:validation:Required SourceUris []*string `json:"sourceUris" tf:"source_uris,omitempty"` diff --git a/apis/cloudplatform/v1beta1/zz_folderiammember_types.go b/apis/cloudplatform/v1beta1/zz_folderiammember_types.go new file mode 100755 index 000000000..e6ae18f0c --- /dev/null +++ b/apis/cloudplatform/v1beta1/zz_folderiammember_types.go @@ -0,0 +1,111 @@ +/* +Copyright 2021 The Crossplane Authors. + +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 upjet. DO NOT EDIT. + +package v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + + v1 "github.com/crossplane/crossplane-runtime/apis/common/v1" +) + +type ConditionObservation struct { +} + +type ConditionParameters struct { + + // +kubebuilder:validation:Optional + Description *string `json:"description,omitempty" tf:"description,omitempty"` + + // +kubebuilder:validation:Required + Expression *string `json:"expression" tf:"expression,omitempty"` + + // +kubebuilder:validation:Required + Title *string `json:"title" tf:"title,omitempty"` +} + +type FolderIAMMemberObservation struct { + Etag *string `json:"etag,omitempty" tf:"etag,omitempty"` + + ID *string `json:"id,omitempty" tf:"id,omitempty"` +} + +type FolderIAMMemberParameters struct { + + // +kubebuilder:validation:Optional + Condition []ConditionParameters `json:"condition,omitempty" tf:"condition,omitempty"` + + // +kubebuilder:validation:Required + Folder *string `json:"folder" tf:"folder,omitempty"` + + // +kubebuilder:validation:Required + Member *string `json:"member" tf:"member,omitempty"` + + // +kubebuilder:validation:Required + Role *string `json:"role" tf:"role,omitempty"` +} + +// FolderIAMMemberSpec defines the desired state of FolderIAMMember +type FolderIAMMemberSpec struct { + v1.ResourceSpec `json:",inline"` + ForProvider FolderIAMMemberParameters `json:"forProvider"` +} + +// FolderIAMMemberStatus defines the observed state of FolderIAMMember. +type FolderIAMMemberStatus struct { + v1.ResourceStatus `json:",inline"` + AtProvider FolderIAMMemberObservation `json:"atProvider,omitempty"` +} + +// +kubebuilder:object:root=true + +// FolderIAMMember is the Schema for the FolderIAMMembers API. +// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status" +// +kubebuilder:printcolumn:name="SYNCED",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status" +// +kubebuilder:printcolumn:name="EXTERNAL-NAME",type="string",JSONPath=".metadata.annotations.crossplane\\.io/external-name" +// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp" +// +kubebuilder:subresource:status +// +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,gcp} +type FolderIAMMember struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + Spec FolderIAMMemberSpec `json:"spec"` + Status FolderIAMMemberStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// FolderIAMMemberList contains a list of FolderIAMMembers +type FolderIAMMemberList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []FolderIAMMember `json:"items"` +} + +// Repository type metadata. +var ( + FolderIAMMember_Kind = "FolderIAMMember" + FolderIAMMember_GroupKind = schema.GroupKind{Group: CRDGroup, Kind: FolderIAMMember_Kind}.String() + FolderIAMMember_KindAPIVersion = FolderIAMMember_Kind + "." + CRDGroupVersion.String() + FolderIAMMember_GroupVersionKind = CRDGroupVersion.WithKind(FolderIAMMember_Kind) +) + +func init() { + SchemeBuilder.Register(&FolderIAMMember{}, &FolderIAMMemberList{}) +} diff --git a/apis/cloudplatform/v1beta1/zz_generated.deepcopy.go b/apis/cloudplatform/v1beta1/zz_generated.deepcopy.go index 0f7f20511..58fb886c8 100644 --- a/apis/cloudplatform/v1beta1/zz_generated.deepcopy.go +++ b/apis/cloudplatform/v1beta1/zz_generated.deepcopy.go @@ -144,6 +144,161 @@ func (in *Folder) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FolderIAMMember) DeepCopyInto(out *FolderIAMMember) { + *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 FolderIAMMember. +func (in *FolderIAMMember) DeepCopy() *FolderIAMMember { + if in == nil { + return nil + } + out := new(FolderIAMMember) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *FolderIAMMember) 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 *FolderIAMMemberList) DeepCopyInto(out *FolderIAMMemberList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]FolderIAMMember, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FolderIAMMemberList. +func (in *FolderIAMMemberList) DeepCopy() *FolderIAMMemberList { + if in == nil { + return nil + } + out := new(FolderIAMMemberList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *FolderIAMMemberList) 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 *FolderIAMMemberObservation) DeepCopyInto(out *FolderIAMMemberObservation) { + *out = *in + if in.Etag != nil { + in, out := &in.Etag, &out.Etag + *out = new(string) + **out = **in + } + if in.ID != nil { + in, out := &in.ID, &out.ID + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FolderIAMMemberObservation. +func (in *FolderIAMMemberObservation) DeepCopy() *FolderIAMMemberObservation { + if in == nil { + return nil + } + out := new(FolderIAMMemberObservation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FolderIAMMemberParameters) DeepCopyInto(out *FolderIAMMemberParameters) { + *out = *in + if in.Condition != nil { + in, out := &in.Condition, &out.Condition + *out = make([]ConditionParameters, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Folder != nil { + in, out := &in.Folder, &out.Folder + *out = new(string) + **out = **in + } + if in.Member != nil { + in, out := &in.Member, &out.Member + *out = new(string) + **out = **in + } + if in.Role != nil { + in, out := &in.Role, &out.Role + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FolderIAMMemberParameters. +func (in *FolderIAMMemberParameters) DeepCopy() *FolderIAMMemberParameters { + if in == nil { + return nil + } + out := new(FolderIAMMemberParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FolderIAMMemberSpec) DeepCopyInto(out *FolderIAMMemberSpec) { + *out = *in + in.ResourceSpec.DeepCopyInto(&out.ResourceSpec) + in.ForProvider.DeepCopyInto(&out.ForProvider) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FolderIAMMemberSpec. +func (in *FolderIAMMemberSpec) DeepCopy() *FolderIAMMemberSpec { + if in == nil { + return nil + } + out := new(FolderIAMMemberSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FolderIAMMemberStatus) DeepCopyInto(out *FolderIAMMemberStatus) { + *out = *in + in.ResourceStatus.DeepCopyInto(&out.ResourceStatus) + in.AtProvider.DeepCopyInto(&out.AtProvider) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FolderIAMMemberStatus. +func (in *FolderIAMMemberStatus) DeepCopy() *FolderIAMMemberStatus { + if in == nil { + return nil + } + out := new(FolderIAMMemberStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *FolderList) DeepCopyInto(out *FolderList) { *out = *in @@ -636,6 +791,51 @@ func (in *OrganizationIAMMember) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OrganizationIAMMemberConditionObservation) DeepCopyInto(out *OrganizationIAMMemberConditionObservation) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OrganizationIAMMemberConditionObservation. +func (in *OrganizationIAMMemberConditionObservation) DeepCopy() *OrganizationIAMMemberConditionObservation { + if in == nil { + return nil + } + out := new(OrganizationIAMMemberConditionObservation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OrganizationIAMMemberConditionParameters) DeepCopyInto(out *OrganizationIAMMemberConditionParameters) { + *out = *in + if in.Description != nil { + in, out := &in.Description, &out.Description + *out = new(string) + **out = **in + } + if in.Expression != nil { + in, out := &in.Expression, &out.Expression + *out = new(string) + **out = **in + } + if in.Title != nil { + in, out := &in.Title, &out.Title + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OrganizationIAMMemberConditionParameters. +func (in *OrganizationIAMMemberConditionParameters) DeepCopy() *OrganizationIAMMemberConditionParameters { + if in == nil { + return nil + } + out := new(OrganizationIAMMemberConditionParameters) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *OrganizationIAMMemberList) DeepCopyInto(out *OrganizationIAMMemberList) { *out = *in @@ -698,7 +898,7 @@ func (in *OrganizationIAMMemberParameters) DeepCopyInto(out *OrganizationIAMMemb *out = *in if in.Condition != nil { in, out := &in.Condition, &out.Condition - *out = make([]ConditionParameters, len(*in)) + *out = make([]OrganizationIAMMemberConditionParameters, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } diff --git a/apis/cloudplatform/v1beta1/zz_generated.managed.go b/apis/cloudplatform/v1beta1/zz_generated.managed.go index 63ef076ff..b36aaf8d4 100644 --- a/apis/cloudplatform/v1beta1/zz_generated.managed.go +++ b/apis/cloudplatform/v1beta1/zz_generated.managed.go @@ -85,6 +85,72 @@ func (mg *Folder) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) { mg.Spec.WriteConnectionSecretToReference = r } +// GetCondition of this FolderIAMMember. +func (mg *FolderIAMMember) GetCondition(ct xpv1.ConditionType) xpv1.Condition { + return mg.Status.GetCondition(ct) +} + +// GetDeletionPolicy of this FolderIAMMember. +func (mg *FolderIAMMember) GetDeletionPolicy() xpv1.DeletionPolicy { + return mg.Spec.DeletionPolicy +} + +// GetProviderConfigReference of this FolderIAMMember. +func (mg *FolderIAMMember) GetProviderConfigReference() *xpv1.Reference { + return mg.Spec.ProviderConfigReference +} + +/* +GetProviderReference of this FolderIAMMember. +Deprecated: Use GetProviderConfigReference. +*/ +func (mg *FolderIAMMember) GetProviderReference() *xpv1.Reference { + return mg.Spec.ProviderReference +} + +// GetPublishConnectionDetailsTo of this FolderIAMMember. +func (mg *FolderIAMMember) GetPublishConnectionDetailsTo() *xpv1.PublishConnectionDetailsTo { + return mg.Spec.PublishConnectionDetailsTo +} + +// GetWriteConnectionSecretToReference of this FolderIAMMember. +func (mg *FolderIAMMember) GetWriteConnectionSecretToReference() *xpv1.SecretReference { + return mg.Spec.WriteConnectionSecretToReference +} + +// SetConditions of this FolderIAMMember. +func (mg *FolderIAMMember) SetConditions(c ...xpv1.Condition) { + mg.Status.SetConditions(c...) +} + +// SetDeletionPolicy of this FolderIAMMember. +func (mg *FolderIAMMember) SetDeletionPolicy(r xpv1.DeletionPolicy) { + mg.Spec.DeletionPolicy = r +} + +// SetProviderConfigReference of this FolderIAMMember. +func (mg *FolderIAMMember) SetProviderConfigReference(r *xpv1.Reference) { + mg.Spec.ProviderConfigReference = r +} + +/* +SetProviderReference of this FolderIAMMember. +Deprecated: Use SetProviderConfigReference. +*/ +func (mg *FolderIAMMember) SetProviderReference(r *xpv1.Reference) { + mg.Spec.ProviderReference = r +} + +// SetPublishConnectionDetailsTo of this FolderIAMMember. +func (mg *FolderIAMMember) SetPublishConnectionDetailsTo(r *xpv1.PublishConnectionDetailsTo) { + mg.Spec.PublishConnectionDetailsTo = r +} + +// SetWriteConnectionSecretToReference of this FolderIAMMember. +func (mg *FolderIAMMember) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) { + mg.Spec.WriteConnectionSecretToReference = r +} + // GetCondition of this OrganizationIAMAuditConfig. func (mg *OrganizationIAMAuditConfig) GetCondition(ct xpv1.ConditionType) xpv1.Condition { return mg.Status.GetCondition(ct) diff --git a/apis/cloudplatform/v1beta1/zz_generated.managedlist.go b/apis/cloudplatform/v1beta1/zz_generated.managedlist.go index 5cc24a1c6..c5cd642d1 100644 --- a/apis/cloudplatform/v1beta1/zz_generated.managedlist.go +++ b/apis/cloudplatform/v1beta1/zz_generated.managedlist.go @@ -19,6 +19,15 @@ package v1beta1 import resource "github.com/crossplane/crossplane-runtime/pkg/resource" +// GetItems of this FolderIAMMemberList. +func (l *FolderIAMMemberList) GetItems() []resource.Managed { + items := make([]resource.Managed, len(l.Items)) + for i := range l.Items { + items[i] = &l.Items[i] + } + return items +} + // GetItems of this FolderList. func (l *FolderList) GetItems() []resource.Managed { items := make([]resource.Managed, len(l.Items)) diff --git a/apis/cloudplatform/v1beta1/zz_generated_terraformed.go b/apis/cloudplatform/v1beta1/zz_generated_terraformed.go index e917a05e8..c91283919 100755 --- a/apis/cloudplatform/v1beta1/zz_generated_terraformed.go +++ b/apis/cloudplatform/v1beta1/zz_generated_terraformed.go @@ -99,6 +99,80 @@ func (tr *Folder) GetTerraformSchemaVersion() int { return 0 } +// GetTerraformResourceType returns Terraform resource type for this FolderIAMMember +func (mg *FolderIAMMember) GetTerraformResourceType() string { + return "google_folder_iam_member" +} + +// GetConnectionDetailsMapping for this FolderIAMMember +func (tr *FolderIAMMember) GetConnectionDetailsMapping() map[string]string { + return nil +} + +// GetObservation of this FolderIAMMember +func (tr *FolderIAMMember) GetObservation() (map[string]any, error) { + o, err := json.TFParser.Marshal(tr.Status.AtProvider) + if err != nil { + return nil, err + } + base := map[string]any{} + return base, json.TFParser.Unmarshal(o, &base) +} + +// SetObservation for this FolderIAMMember +func (tr *FolderIAMMember) SetObservation(obs map[string]any) error { + p, err := json.TFParser.Marshal(obs) + if err != nil { + return err + } + return json.TFParser.Unmarshal(p, &tr.Status.AtProvider) +} + +// GetID returns ID of underlying Terraform resource of this FolderIAMMember +func (tr *FolderIAMMember) GetID() string { + if tr.Status.AtProvider.ID == nil { + return "" + } + return *tr.Status.AtProvider.ID +} + +// GetParameters of this FolderIAMMember +func (tr *FolderIAMMember) GetParameters() (map[string]any, error) { + p, err := json.TFParser.Marshal(tr.Spec.ForProvider) + if err != nil { + return nil, err + } + base := map[string]any{} + return base, json.TFParser.Unmarshal(p, &base) +} + +// SetParameters for this FolderIAMMember +func (tr *FolderIAMMember) SetParameters(params map[string]any) error { + p, err := json.TFParser.Marshal(params) + if err != nil { + return err + } + return json.TFParser.Unmarshal(p, &tr.Spec.ForProvider) +} + +// LateInitialize this FolderIAMMember using its observed tfState. +// returns True if there are any spec changes for the resource. +func (tr *FolderIAMMember) LateInitialize(attrs []byte) (bool, error) { + params := &FolderIAMMemberParameters{} + if err := json.TFParser.Unmarshal(attrs, params); err != nil { + return false, errors.Wrap(err, "failed to unmarshal Terraform state parameters for late-initialization") + } + opts := []resource.GenericLateInitializerOption{resource.WithZeroValueJSONOmitEmptyFilter(resource.CNameWildcard)} + + li := resource.NewGenericLateInitializer(opts...) + return li.LateInitialize(&tr.Spec.ForProvider, params) +} + +// GetTerraformSchemaVersion returns the associated Terraform schema version +func (tr *FolderIAMMember) GetTerraformSchemaVersion() int { + return 0 +} + // GetTerraformResourceType returns Terraform resource type for this OrganizationIAMAuditConfig func (mg *OrganizationIAMAuditConfig) GetTerraformResourceType() string { return "google_organization_iam_audit_config" diff --git a/apis/cloudplatform/v1beta1/zz_organizationiammember_types.go b/apis/cloudplatform/v1beta1/zz_organizationiammember_types.go index 296669305..14b3cb7a3 100755 --- a/apis/cloudplatform/v1beta1/zz_organizationiammember_types.go +++ b/apis/cloudplatform/v1beta1/zz_organizationiammember_types.go @@ -25,10 +25,10 @@ import ( v1 "github.com/crossplane/crossplane-runtime/apis/common/v1" ) -type ConditionObservation struct { +type OrganizationIAMMemberConditionObservation struct { } -type ConditionParameters struct { +type OrganizationIAMMemberConditionParameters struct { // +kubebuilder:validation:Optional Description *string `json:"description,omitempty" tf:"description,omitempty"` @@ -49,7 +49,7 @@ type OrganizationIAMMemberObservation struct { type OrganizationIAMMemberParameters struct { // +kubebuilder:validation:Optional - Condition []ConditionParameters `json:"condition,omitempty" tf:"condition,omitempty"` + Condition []OrganizationIAMMemberConditionParameters `json:"condition,omitempty" tf:"condition,omitempty"` // +kubebuilder:validation:Required Member *string `json:"member" tf:"member,omitempty"` diff --git a/config/external_name.go b/config/external_name.go index 5c45dff5b..58f9b5c14 100644 --- a/config/external_name.go +++ b/config/external_name.go @@ -30,6 +30,8 @@ var externalNameConfigs = map[string]config.ExternalName{ // // Folders can be imported using the folder's id, e.g. folders/1234567 "google_folder": config.IdentifierFromProvider, + // Imported by using the following format: your-folder roles/viewer user:foo@example.com + "google_folder_iam_member": config.IdentifierFromProvider, // Imported by using the following format: organizations/{{org_id}}/roles/{{role_id}} "google_organization_iam_custom_role": config.IdentifierFromProvider, // Imported by using the following format: your-orgid roles/viewer user:foo@example.com diff --git a/examples/cloudplatform/folderiammember.yaml b/examples/cloudplatform/folderiammember.yaml new file mode 100644 index 000000000..c98252825 --- /dev/null +++ b/examples/cloudplatform/folderiammember.yaml @@ -0,0 +1,13 @@ +apiVersion: cloudplatform.gcp.upbound.io/v1beta1 +kind: FolderIAMMember +metadata: + annotations: + meta.upbound.io/example-id: cloudplatform/v1beta1/folderiammember + labels: + testing.upbound.io/example-name: folder-iam-member + name: folder-iam-member +spec: + forProvider: + member: "${data.google_iam_member.member}" + role: "roles/viewer" + folder: ${data.cloudplatform_folder.folderId} diff --git a/internal/controller/cloudplatform/folderiammember/zz_controller.go b/internal/controller/cloudplatform/folderiammember/zz_controller.go new file mode 100755 index 000000000..009baae22 --- /dev/null +++ b/internal/controller/cloudplatform/folderiammember/zz_controller.go @@ -0,0 +1,63 @@ +/* +Copyright 2021 The Crossplane Authors. + +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 upjet. DO NOT EDIT. + +package folderiammember + +import ( + "time" + + "github.com/crossplane/crossplane-runtime/pkg/connection" + "github.com/crossplane/crossplane-runtime/pkg/event" + "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" + "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" + xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + tjcontroller "github.com/upbound/upjet/pkg/controller" + "github.com/upbound/upjet/pkg/terraform" + ctrl "sigs.k8s.io/controller-runtime" + + v1beta1 "github.com/upbound/provider-gcp/apis/cloudplatform/v1beta1" +) + +// Setup adds a controller that reconciles FolderIAMMember managed resources. +func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { + name := managed.ControllerName(v1beta1.FolderIAMMember_GroupVersionKind.String()) + var initializers managed.InitializerChain + cps := []managed.ConnectionPublisher{managed.NewAPISecretPublisher(mgr.GetClient(), mgr.GetScheme())} + if o.SecretStoreConfigGVK != nil { + cps = append(cps, connection.NewDetailsManager(mgr.GetClient(), *o.SecretStoreConfigGVK)) + } + r := managed.NewReconciler(mgr, + xpresource.ManagedKind(v1beta1.FolderIAMMember_GroupVersionKind), + managed.WithExternalConnecter(tjcontroller.NewConnector(mgr.GetClient(), o.WorkspaceStore, o.SetupFn, o.Provider.Resources["google_folder_iam_member"], + tjcontroller.WithCallbackProvider(tjcontroller.NewAPICallbacks(mgr, xpresource.ManagedKind(v1beta1.FolderIAMMember_GroupVersionKind))), + )), + managed.WithLogger(o.Logger.WithValues("controller", name)), + managed.WithRecorder(event.NewAPIRecorder(mgr.GetEventRecorderFor(name))), + managed.WithFinalizer(terraform.NewWorkspaceFinalizer(o.WorkspaceStore, xpresource.NewAPIFinalizer(mgr.GetClient(), managed.FinalizerName))), + managed.WithTimeout(3*time.Minute), + managed.WithInitializers(initializers), + managed.WithConnectionPublishers(cps...), + managed.WithPollInterval(o.PollInterval), + ) + + return ctrl.NewControllerManagedBy(mgr). + Named(name). + WithOptions(o.ForControllerRuntime()). + For(&v1beta1.FolderIAMMember{}). + Complete(ratelimiter.NewReconciler(name, r, o.GlobalRateLimiter)) +} diff --git a/internal/controller/zz_setup.go b/internal/controller/zz_setup.go index 862a05479..34d546275 100755 --- a/internal/controller/zz_setup.go +++ b/internal/controller/zz_setup.go @@ -28,6 +28,7 @@ import ( function "github.com/upbound/provider-gcp/internal/controller/cloudfunctions/function" functioniammember "github.com/upbound/provider-gcp/internal/controller/cloudfunctions/functioniammember" folder "github.com/upbound/provider-gcp/internal/controller/cloudplatform/folder" + folderiammember "github.com/upbound/provider-gcp/internal/controller/cloudplatform/folderiammember" organizationiamauditconfig "github.com/upbound/provider-gcp/internal/controller/cloudplatform/organizationiamauditconfig" organizationiamcustomrole "github.com/upbound/provider-gcp/internal/controller/cloudplatform/organizationiamcustomrole" organizationiammember "github.com/upbound/provider-gcp/internal/controller/cloudplatform/organizationiammember" @@ -248,6 +249,7 @@ func Setup(mgr ctrl.Manager, o controller.Options) error { function.Setup, functioniammember.Setup, folder.Setup, + folderiammember.Setup, organizationiamauditconfig.Setup, organizationiamcustomrole.Setup, organizationiammember.Setup, diff --git a/package/crds/bigquery.gcp.upbound.io_jobs.yaml b/package/crds/bigquery.gcp.upbound.io_jobs.yaml index 093900504..8c7a58095 100644 --- a/package/crds/bigquery.gcp.upbound.io_jobs.yaml +++ b/package/crds/bigquery.gcp.upbound.io_jobs.yaml @@ -993,13 +993,13 @@ spec: sourceUris: description: 'The fully-qualified URIs that point to your data in Google Cloud. For Google Cloud Storage URIs: Each - URI can contain one ” wildcard character and it must come - after the ''bucket'' name. Size limits related to load - jobs apply to external data sources. For Google Cloud + URI can contain one '''' wildcard character and it must + come after the ''bucket'' name. Size limits related to + load jobs apply to external data sources. For Google Cloud Bigtable URIs: Exactly one URI can be specified and it has be a fully specified and valid HTTPS URL for a Google Cloud Bigtable table. For Google Cloud Datastore backups: - Exactly one URI can be specified. Also, the ” wildcard + Exactly one URI can be specified. Also, the '''' wildcard character is not allowed.' items: type: string diff --git a/package/crds/cloudplatform.gcp.upbound.io_folderiammembers.yaml b/package/crds/cloudplatform.gcp.upbound.io_folderiammembers.yaml new file mode 100644 index 000000000..2e72abd97 --- /dev/null +++ b/package/crds/cloudplatform.gcp.upbound.io_folderiammembers.yaml @@ -0,0 +1,319 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.8.0 + creationTimestamp: null + name: folderiammembers.cloudplatform.gcp.upbound.io +spec: + group: cloudplatform.gcp.upbound.io + names: + categories: + - crossplane + - managed + - gcp + kind: FolderIAMMember + listKind: FolderIAMMemberList + plural: folderiammembers + singular: folderiammember + scope: Cluster + versions: + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=='Ready')].status + name: READY + type: string + - jsonPath: .status.conditions[?(@.type=='Synced')].status + name: SYNCED + type: string + - jsonPath: .metadata.annotations.crossplane\.io/external-name + name: EXTERNAL-NAME + type: string + - jsonPath: .metadata.creationTimestamp + name: AGE + type: date + name: v1beta1 + schema: + openAPIV3Schema: + description: FolderIAMMember is the Schema for the FolderIAMMembers API. + properties: + apiVersion: + 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/sig-architecture/api-conventions.md#resources' + type: string + kind: + 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/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: FolderIAMMemberSpec defines the desired state of FolderIAMMember + properties: + deletionPolicy: + default: Delete + description: DeletionPolicy specifies what will happen to the underlying + external when this managed resource is deleted - either "Delete" + or "Orphan" the external resource. + enum: + - Orphan + - Delete + type: string + forProvider: + properties: + condition: + items: + properties: + description: + type: string + expression: + type: string + title: + type: string + required: + - expression + - title + type: object + type: array + folder: + type: string + member: + type: string + role: + type: string + required: + - folder + - member + - role + type: object + providerConfigRef: + default: + name: default + description: ProviderConfigReference specifies how the provider that + will be used to create, observe, update, and delete this managed + resource should be configured. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of this + reference is required. The default is 'Required', which + means the reconcile will fail if the reference cannot be + resolved. 'Optional' means this reference will be a no-op + if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will attempt + to resolve the reference only when the corresponding field + is not present. Use 'Always' to resolve the reference on + every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + providerRef: + description: 'ProviderReference specifies the provider that will be + used to create, observe, update, and delete this managed resource. + Deprecated: Please use ProviderConfigReference, i.e. `providerConfigRef`' + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of this + reference is required. The default is 'Required', which + means the reconcile will fail if the reference cannot be + resolved. 'Optional' means this reference will be a no-op + if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will attempt + to resolve the reference only when the corresponding field + is not present. Use 'Always' to resolve the reference on + every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + publishConnectionDetailsTo: + description: PublishConnectionDetailsTo specifies the connection secret + config which contains a name, metadata and a reference to secret + store config to which any connection details for this managed resource + should be written. Connection details frequently include the endpoint, + username, and password required to connect to the managed resource. + properties: + configRef: + default: + name: default + description: SecretStoreConfigRef specifies which secret store + config should be used for this ConnectionSecret. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of + this reference is required. The default is 'Required', + which means the reconcile will fail if the reference + cannot be resolved. 'Optional' means this reference + will be a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will + attempt to resolve the reference only when the corresponding + field is not present. Use 'Always' to resolve the reference + on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + metadata: + description: Metadata is the metadata for connection secret. + properties: + annotations: + additionalProperties: + type: string + description: Annotations are the annotations to be added to + connection secret. - For Kubernetes secrets, this will be + used as "metadata.annotations". - It is up to Secret Store + implementation for others store types. + type: object + labels: + additionalProperties: + type: string + description: Labels are the labels/tags to be added to connection + secret. - For Kubernetes secrets, this will be used as "metadata.labels". + - It is up to Secret Store implementation for others store + types. + type: object + type: + description: Type is the SecretType for the connection secret. + - Only valid for Kubernetes Secret Stores. + type: string + type: object + name: + description: Name is the name of the connection secret. + type: string + required: + - name + type: object + writeConnectionSecretToRef: + description: WriteConnectionSecretToReference specifies the namespace + and name of a Secret to which any connection details for this managed + resource should be written. Connection details frequently include + the endpoint, username, and password required to connect to the + managed resource. This field is planned to be replaced in a future + release in favor of PublishConnectionDetailsTo. Currently, both + could be set independently and connection details would be published + to both without affecting each other. + properties: + name: + description: Name of the secret. + type: string + namespace: + description: Namespace of the secret. + type: string + required: + - name + - namespace + type: object + required: + - forProvider + type: object + status: + description: FolderIAMMemberStatus defines the observed state of FolderIAMMember. + properties: + atProvider: + properties: + etag: + type: string + id: + type: string + type: object + conditions: + description: Conditions of the resource. + items: + description: A Condition that may apply to a resource. + properties: + lastTransitionTime: + description: LastTransitionTime is the last time this condition + transitioned from one status to another. + format: date-time + type: string + message: + description: A Message containing details about this condition's + last transition from one status to another, if any. + type: string + reason: + description: A Reason for this condition's last transition from + one status to another. + type: string + status: + description: Status of this condition; is it currently True, + False, or Unknown? + type: string + type: + description: Type of this condition. At most one of each condition + type may apply to a resource at any point in time. + type: string + required: + - lastTransitionTime + - reason + - status + - type + type: object + type: array + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] From b3413b841927e7f91a752f33439ebebc14adf038 Mon Sep 17 00:00:00 2001 From: Brad Wadsworth Date: Fri, 16 Dec 2022 11:39:50 -0600 Subject: [PATCH 2/5] reverted files --- apis/bigquery/v1beta1/zz_job_types.go | 4 ++-- package/crds/bigquery.gcp.upbound.io_jobs.yaml | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apis/bigquery/v1beta1/zz_job_types.go b/apis/bigquery/v1beta1/zz_job_types.go index c74bd724e..30e6fb761 100755 --- a/apis/bigquery/v1beta1/zz_job_types.go +++ b/apis/bigquery/v1beta1/zz_job_types.go @@ -478,11 +478,11 @@ type LoadParameters struct { SourceFormat *string `json:"sourceFormat,omitempty" tf:"source_format,omitempty"` // The fully-qualified URIs that point to your data in Google Cloud. - // For Google Cloud Storage URIs: Each URI can contain one '' wildcard character + // For Google Cloud Storage URIs: Each URI can contain one ” wildcard character // and it must come after the 'bucket' name. Size limits related to load jobs apply // to external data sources. For Google Cloud Bigtable URIs: Exactly one URI can be // specified and it has be a fully specified and valid HTTPS URL for a Google Cloud Bigtable table. - // For Google Cloud Datastore backups: Exactly one URI can be specified. Also, the '' wildcard character is not allowed. + // For Google Cloud Datastore backups: Exactly one URI can be specified. Also, the ” wildcard character is not allowed. // +kubebuilder:validation:Required SourceUris []*string `json:"sourceUris" tf:"source_uris,omitempty"` diff --git a/package/crds/bigquery.gcp.upbound.io_jobs.yaml b/package/crds/bigquery.gcp.upbound.io_jobs.yaml index 8c7a58095..093900504 100644 --- a/package/crds/bigquery.gcp.upbound.io_jobs.yaml +++ b/package/crds/bigquery.gcp.upbound.io_jobs.yaml @@ -993,13 +993,13 @@ spec: sourceUris: description: 'The fully-qualified URIs that point to your data in Google Cloud. For Google Cloud Storage URIs: Each - URI can contain one '''' wildcard character and it must - come after the ''bucket'' name. Size limits related to - load jobs apply to external data sources. For Google Cloud + URI can contain one ” wildcard character and it must come + after the ''bucket'' name. Size limits related to load + jobs apply to external data sources. For Google Cloud Bigtable URIs: Exactly one URI can be specified and it has be a fully specified and valid HTTPS URL for a Google Cloud Bigtable table. For Google Cloud Datastore backups: - Exactly one URI can be specified. Also, the '''' wildcard + Exactly one URI can be specified. Also, the ” wildcard character is not allowed.' items: type: string From c70ca1b1df253d6ffe36f078686278da9625416a Mon Sep 17 00:00:00 2001 From: Brad Wadsworth Date: Fri, 16 Dec 2022 13:12:27 -0600 Subject: [PATCH 3/5] add folder ref for folder iam member --- .../v1beta1/zz_folderiammember_types.go | 13 +++- .../v1beta1/zz_generated.deepcopy.go | 10 +++ .../v1beta1/zz_generated.resolvers.go | 26 +++++++ config/cloudplatform/config.go | 5 ++ config/external_name.go | 2 +- examples/cloudplatform/folderiammember.yaml | 2 +- ...tform.gcp.upbound.io_folderiammembers.yaml | 74 ++++++++++++++++++- 7 files changed, 127 insertions(+), 5 deletions(-) diff --git a/apis/cloudplatform/v1beta1/zz_folderiammember_types.go b/apis/cloudplatform/v1beta1/zz_folderiammember_types.go index e6ae18f0c..fa8cd3141 100755 --- a/apis/cloudplatform/v1beta1/zz_folderiammember_types.go +++ b/apis/cloudplatform/v1beta1/zz_folderiammember_types.go @@ -51,8 +51,17 @@ type FolderIAMMemberParameters struct { // +kubebuilder:validation:Optional Condition []ConditionParameters `json:"condition,omitempty" tf:"condition,omitempty"` - // +kubebuilder:validation:Required - Folder *string `json:"folder" tf:"folder,omitempty"` + // +crossplane:generate:reference:type=Folder + // +kubebuilder:validation:Optional + Folder *string `json:"folder,omitempty" tf:"folder,omitempty"` + + // Reference to a Folder to populate folder. + // +kubebuilder:validation:Optional + FolderRef *v1.Reference `json:"folderRef,omitempty" tf:"-"` + + // Selector for a Folder to populate folder. + // +kubebuilder:validation:Optional + FolderSelector *v1.Selector `json:"folderSelector,omitempty" tf:"-"` // +kubebuilder:validation:Required Member *string `json:"member" tf:"member,omitempty"` diff --git a/apis/cloudplatform/v1beta1/zz_generated.deepcopy.go b/apis/cloudplatform/v1beta1/zz_generated.deepcopy.go index 58fb886c8..2df997375 100644 --- a/apis/cloudplatform/v1beta1/zz_generated.deepcopy.go +++ b/apis/cloudplatform/v1beta1/zz_generated.deepcopy.go @@ -243,6 +243,16 @@ func (in *FolderIAMMemberParameters) DeepCopyInto(out *FolderIAMMemberParameters *out = new(string) **out = **in } + if in.FolderRef != nil { + in, out := &in.FolderRef, &out.FolderRef + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.FolderSelector != nil { + in, out := &in.FolderSelector, &out.FolderSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } if in.Member != nil { in, out := &in.Member, &out.Member *out = new(string) diff --git a/apis/cloudplatform/v1beta1/zz_generated.resolvers.go b/apis/cloudplatform/v1beta1/zz_generated.resolvers.go index 2572e7a37..c324db5d1 100644 --- a/apis/cloudplatform/v1beta1/zz_generated.resolvers.go +++ b/apis/cloudplatform/v1beta1/zz_generated.resolvers.go @@ -53,6 +53,32 @@ func (mg *Folder) ResolveReferences(ctx context.Context, c client.Reader) error return nil } +// ResolveReferences of this FolderIAMMember. +func (mg *FolderIAMMember) ResolveReferences(ctx context.Context, c client.Reader) error { + r := reference.NewAPIResolver(c, mg) + + var rsp reference.ResolutionResponse + var err error + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.Folder), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.FolderRef, + Selector: mg.Spec.ForProvider.FolderSelector, + To: reference.To{ + List: &FolderList{}, + Managed: &Folder{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.Folder") + } + mg.Spec.ForProvider.Folder = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.ForProvider.FolderRef = rsp.ResolvedReference + + return nil +} + // ResolveReferences of this Project. func (mg *Project) ResolveReferences(ctx context.Context, c client.Reader) error { r := reference.NewAPIResolver(c, mg) diff --git a/config/cloudplatform/config.go b/config/cloudplatform/config.go index 050f14b25..33474d177 100644 --- a/config/cloudplatform/config.go +++ b/config/cloudplatform/config.go @@ -13,6 +13,11 @@ import ( // Configure configures individual resources by adding custom // ResourceConfigurators. func Configure(p *config.Provider) { + p.AddResourceConfigurator("google_folder_iam_member", func(r *config.Resource) { + r.References["folder"] = config.Reference{ + Type: "Folder", + } + }) p.AddResourceConfigurator("google_project", func(r *config.Resource) { r.TerraformResource.Schema["org_id"].Description = "The numeric ID of the organization this project belongs to." diff --git a/config/external_name.go b/config/external_name.go index 58f9b5c14..a2d8732e0 100644 --- a/config/external_name.go +++ b/config/external_name.go @@ -30,7 +30,7 @@ var externalNameConfigs = map[string]config.ExternalName{ // // Folders can be imported using the folder's id, e.g. folders/1234567 "google_folder": config.IdentifierFromProvider, - // Imported by using the following format: your-folder roles/viewer user:foo@example.com + // Imported by using the following format: folders/your-folder-id roles/viewer user:foo@example.com "google_folder_iam_member": config.IdentifierFromProvider, // Imported by using the following format: organizations/{{org_id}}/roles/{{role_id}} "google_organization_iam_custom_role": config.IdentifierFromProvider, diff --git a/examples/cloudplatform/folderiammember.yaml b/examples/cloudplatform/folderiammember.yaml index c98252825..a99f236ec 100644 --- a/examples/cloudplatform/folderiammember.yaml +++ b/examples/cloudplatform/folderiammember.yaml @@ -10,4 +10,4 @@ spec: forProvider: member: "${data.google_iam_member.member}" role: "roles/viewer" - folder: ${data.cloudplatform_folder.folderId} + folder: ${data.cloudplatform_folder.id} diff --git a/package/crds/cloudplatform.gcp.upbound.io_folderiammembers.yaml b/package/crds/cloudplatform.gcp.upbound.io_folderiammembers.yaml index 2e72abd97..5ecf5349a 100644 --- a/package/crds/cloudplatform.gcp.upbound.io_folderiammembers.yaml +++ b/package/crds/cloudplatform.gcp.upbound.io_folderiammembers.yaml @@ -80,12 +80,84 @@ spec: type: array folder: type: string + folderRef: + description: Reference to a Folder to populate folder. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of + this reference is required. The default is 'Required', + which means the reconcile will fail if the reference + cannot be resolved. 'Optional' means this reference + will be a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will + attempt to resolve the reference only when the corresponding + field is not present. Use 'Always' to resolve the reference + on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + folderSelector: + description: Selector for a Folder to populate folder. + properties: + matchControllerRef: + description: MatchControllerRef ensures an object with the + same controller reference as the selecting object is selected. + type: boolean + matchLabels: + additionalProperties: + type: string + description: MatchLabels ensures an object with matching labels + is selected. + type: object + policy: + description: Policies for selection. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of + this reference is required. The default is 'Required', + which means the reconcile will fail if the reference + cannot be resolved. 'Optional' means this reference + will be a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will + attempt to resolve the reference only when the corresponding + field is not present. Use 'Always' to resolve the reference + on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + type: object member: type: string role: type: string required: - - folder - member - role type: object From be17ce25cbff9281bbba6a94fe7c8a95d30ce174 Mon Sep 17 00:00:00 2001 From: Brad Wadsworth Date: Wed, 21 Dec 2022 15:04:07 -0600 Subject: [PATCH 4/5] add annotation for testing --- examples/cloudplatform/folderiammember.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/cloudplatform/folderiammember.yaml b/examples/cloudplatform/folderiammember.yaml index a99f236ec..59f08fe07 100644 --- a/examples/cloudplatform/folderiammember.yaml +++ b/examples/cloudplatform/folderiammember.yaml @@ -3,6 +3,7 @@ kind: FolderIAMMember metadata: annotations: meta.upbound.io/example-id: cloudplatform/v1beta1/folderiammember + upjet.upbound.io/manual-intervention: "Depends on a valid folder & member" labels: testing.upbound.io/example-name: folder-iam-member name: folder-iam-member From ef7f5798604a5b44a2a6b7e78f932870f75683ee Mon Sep 17 00:00:00 2001 From: Brad Wadsworth Date: Wed, 28 Dec 2022 16:56:57 -0600 Subject: [PATCH 5/5] add extractor --- apis/cloudplatform/v1beta1/zz_folderiammember_types.go | 1 + apis/cloudplatform/v1beta1/zz_generated.resolvers.go | 2 +- config/cloudplatform/config.go | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apis/cloudplatform/v1beta1/zz_folderiammember_types.go b/apis/cloudplatform/v1beta1/zz_folderiammember_types.go index fa8cd3141..36562cac8 100755 --- a/apis/cloudplatform/v1beta1/zz_folderiammember_types.go +++ b/apis/cloudplatform/v1beta1/zz_folderiammember_types.go @@ -52,6 +52,7 @@ type FolderIAMMemberParameters struct { Condition []ConditionParameters `json:"condition,omitempty" tf:"condition,omitempty"` // +crossplane:generate:reference:type=Folder + // +crossplane:generate:reference:extractor=github.com/upbound/provider-gcp/config/common.ExtractResourceID() // +kubebuilder:validation:Optional Folder *string `json:"folder,omitempty" tf:"folder,omitempty"` diff --git a/apis/cloudplatform/v1beta1/zz_generated.resolvers.go b/apis/cloudplatform/v1beta1/zz_generated.resolvers.go index c324db5d1..e40f91766 100644 --- a/apis/cloudplatform/v1beta1/zz_generated.resolvers.go +++ b/apis/cloudplatform/v1beta1/zz_generated.resolvers.go @@ -62,7 +62,7 @@ func (mg *FolderIAMMember) ResolveReferences(ctx context.Context, c client.Reade rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.Folder), - Extract: reference.ExternalName(), + Extract: common.ExtractResourceID(), Reference: mg.Spec.ForProvider.FolderRef, Selector: mg.Spec.ForProvider.FolderSelector, To: reference.To{ diff --git a/config/cloudplatform/config.go b/config/cloudplatform/config.go index 33474d177..52c34503f 100644 --- a/config/cloudplatform/config.go +++ b/config/cloudplatform/config.go @@ -15,7 +15,8 @@ import ( func Configure(p *config.Provider) { p.AddResourceConfigurator("google_folder_iam_member", func(r *config.Resource) { r.References["folder"] = config.Reference{ - Type: "Folder", + Type: "Folder", + Extractor: common.ExtractResourceIDFuncPath, } }) p.AddResourceConfigurator("google_project", func(r *config.Resource) {