From cc636bae94e3cbf614b48e26e231a9f63faeda53 Mon Sep 17 00:00:00 2001 From: Yuwen Ma Date: Thu, 21 Nov 2024 05:35:11 +0000 Subject: [PATCH] chore: pass in just enough args to ResolveProject --- apis/bigquery/v1beta1/dataset_reference.go | 2 +- apis/bigqueryanalyticshub/v1alpha1/listing_reference.go | 2 +- apis/bigqueryconnection/v1alpha1/connection_reference.go | 2 +- apis/bigqueryconnection/v1beta1/connection_reference.go | 2 +- apis/discoveryengine/v1alpha1/datastore_reference.go | 2 +- apis/discoveryengine/v1alpha1/engine_reference.go | 2 +- apis/kms/v1alpha1/keyhandle_reference.go | 2 +- apis/refs/v1beta1/projectref.go | 8 ++++---- apis/securesourcemanager/v1alpha1/instance_reference.go | 2 +- apis/securesourcemanager/v1alpha1/repository_reference.go | 2 +- apis/workstations/v1alpha1/cluster_reference.go | 2 +- apis/workstations/v1alpha1/config_reference.go | 2 +- apis/workstations/v1beta1/cluster_reference.go | 2 +- dev/tools/controllerbuilder/template/apis/identity.go | 2 +- .../bigqueryanalyticshub/dataexchange_controller.go | 2 +- .../bigquerydatatransferconfig_controller.go | 2 +- .../certificatemanager/dnsauthorization_controller.go | 2 +- pkg/controller/direct/cloudbuild/workerpool_controller.go | 2 +- pkg/controller/direct/common/refs.go | 4 ++-- pkg/controller/direct/dataflow/refs.go | 2 +- pkg/controller/direct/dataform/repository_controller.go | 2 +- .../direct/firestore/firestoredatabase_controller.go | 2 +- .../direct/gkehub/featuremembership_controller.go | 2 +- .../direct/kms/autokeyconfig/autokeyconfig_controller.go | 2 +- pkg/controller/direct/logging/logbucketref.go | 2 +- pkg/controller/direct/logging/logmetric_controller.go | 2 +- .../direct/monitoring/monitoringdashboard_controller.go | 2 +- pkg/controller/direct/networkconnectivity/refs.go | 2 +- .../serviceconnectionpolicy_controller.go | 2 +- .../direct/privateca/privatecapool_controller.go | 2 +- .../privilegedaccessmanager/entitlement_controller.go | 2 +- .../direct/redis/cluster/rediscluster_controller.go | 2 +- pkg/controller/direct/redis/cluster/refs.go | 2 +- pkg/controller/direct/workstations/cluster_controller.go | 2 +- pkg/controller/direct/workstations/cluster_normalize.go | 2 +- 35 files changed, 39 insertions(+), 39 deletions(-) diff --git a/apis/bigquery/v1beta1/dataset_reference.go b/apis/bigquery/v1beta1/dataset_reference.go index 78a8a06316..65068450bf 100644 --- a/apis/bigquery/v1beta1/dataset_reference.go +++ b/apis/bigquery/v1beta1/dataset_reference.go @@ -90,7 +90,7 @@ func NewBigQueryDatasetRef(ctx context.Context, reader client.Reader, obj *BigQu id := &BigQueryDatasetRef{} // Get Parent - projectRef, err := refsv1beta1.ResolveProject(ctx, reader, obj, obj.Spec.ProjectRef) + projectRef, err := refsv1beta1.ResolveProject(ctx, reader, obj.GetNamespace(), obj.Spec.ProjectRef) if err != nil { return nil, err } diff --git a/apis/bigqueryanalyticshub/v1alpha1/listing_reference.go b/apis/bigqueryanalyticshub/v1alpha1/listing_reference.go index 5692d9d72b..dad46f1e5b 100644 --- a/apis/bigqueryanalyticshub/v1alpha1/listing_reference.go +++ b/apis/bigqueryanalyticshub/v1alpha1/listing_reference.go @@ -90,7 +90,7 @@ func NewBigQueryAnalyticsHubListingRef(ctx context.Context, reader client.Reader id := &BigQueryAnalyticsHubListingRef{} // Get Parent - projectRef, err := refsv1beta1.ResolveProject(ctx, reader, obj, obj.Spec.ProjectRef) + projectRef, err := refsv1beta1.ResolveProject(ctx, reader, obj.GetNamespace(), obj.Spec.ProjectRef) if err != nil { return nil, err } diff --git a/apis/bigqueryconnection/v1alpha1/connection_reference.go b/apis/bigqueryconnection/v1alpha1/connection_reference.go index 70baaf1d9a..47d28d3420 100644 --- a/apis/bigqueryconnection/v1alpha1/connection_reference.go +++ b/apis/bigqueryconnection/v1alpha1/connection_reference.go @@ -33,7 +33,7 @@ import ( func NewBigQueryConnectionConnectionRef(ctx context.Context, reader client.Reader, obj *BigQueryConnectionConnection) (*BigQueryConnectionConnectionRef, error) { id := &BigQueryConnectionConnectionRef{} - projectRef, err := refsv1beta1.ResolveProject(ctx, reader, obj, obj.Spec.ProjectRef) + projectRef, err := refsv1beta1.ResolveProject(ctx, reader, obj.GetNamespace(), obj.Spec.ProjectRef) if err != nil { return nil, err } diff --git a/apis/bigqueryconnection/v1beta1/connection_reference.go b/apis/bigqueryconnection/v1beta1/connection_reference.go index 74baa3a7f7..c6db53a819 100644 --- a/apis/bigqueryconnection/v1beta1/connection_reference.go +++ b/apis/bigqueryconnection/v1beta1/connection_reference.go @@ -32,7 +32,7 @@ import ( func NewBigQueryConnectionConnectionRef(ctx context.Context, reader client.Reader, obj *BigQueryConnectionConnection) (*BigQueryConnectionConnectionRef, error) { id := &BigQueryConnectionConnectionRef{} - projectRef, err := refsv1beta1.ResolveProject(ctx, reader, obj, obj.Spec.ProjectRef) + projectRef, err := refsv1beta1.ResolveProject(ctx, reader, obj.Namespace, obj.Spec.ProjectRef) if err != nil { return nil, err } diff --git a/apis/discoveryengine/v1alpha1/datastore_reference.go b/apis/discoveryengine/v1alpha1/datastore_reference.go index 86047900df..587aa48c7b 100644 --- a/apis/discoveryengine/v1alpha1/datastore_reference.go +++ b/apis/discoveryengine/v1alpha1/datastore_reference.go @@ -95,7 +95,7 @@ func (r *DiscoveryEngineDataStoreRef) NormalizedExternal(ctx context.Context, re // New builds a DiscoveryEngineDataStoreRef from the Config Connector DiscoveryEngineDataStore object. func NewDiscoveryEngineDataStoreIDFromObject(ctx context.Context, reader client.Reader, obj *DiscoveryEngineDataStore) (*DiscoveryEngineDataStoreID, error) { // Get Parent - projectRef, err := refsv1beta1.ResolveProject(ctx, reader, obj, obj.Spec.ProjectRef) + projectRef, err := refsv1beta1.ResolveProject(ctx, reader, obj.GetNamespace(), obj.Spec.ProjectRef) if err != nil { return nil, err } diff --git a/apis/discoveryengine/v1alpha1/engine_reference.go b/apis/discoveryengine/v1alpha1/engine_reference.go index c045d5aef8..ea3a798c8e 100644 --- a/apis/discoveryengine/v1alpha1/engine_reference.go +++ b/apis/discoveryengine/v1alpha1/engine_reference.go @@ -88,7 +88,7 @@ func (r *DiscoveryEngineEngineRef) NormalizedExternal(ctx context.Context, reade // New builds a DiscoveryEngineEngineRef from the Config Connector DiscoveryEngineEngine object. func NewDiscoveryEngineEngineRef(ctx context.Context, reader client.Reader, obj *DiscoveryEngineEngine) (*DiscoveryEngineEngineID, error) { // Get Parent - projectRef, err := refsv1beta1.ResolveProject(ctx, reader, obj, obj.Spec.ProjectRef) + projectRef, err := refsv1beta1.ResolveProject(ctx, reader, obj.GetNamespace(), obj.Spec.ProjectRef) if err != nil { return nil, err } diff --git a/apis/kms/v1alpha1/keyhandle_reference.go b/apis/kms/v1alpha1/keyhandle_reference.go index 15f00c2023..44df7102ad 100644 --- a/apis/kms/v1alpha1/keyhandle_reference.go +++ b/apis/kms/v1alpha1/keyhandle_reference.go @@ -90,7 +90,7 @@ func NewKMSKeyHandleRef(ctx context.Context, reader client.Reader, obj *KMSKeyHa id := &KMSKeyHandleRef{} // Get Parent - projectRef, err := refsv1beta1.ResolveProject(ctx, reader, obj, obj.Spec.ProjectRef) + projectRef, err := refsv1beta1.ResolveProject(ctx, reader, obj.GetNamespace(), obj.Spec.ProjectRef) if err != nil { return nil, err } diff --git a/apis/refs/v1beta1/projectref.go b/apis/refs/v1beta1/projectref.go index 904aae64b8..b8d1ef278d 100644 --- a/apis/refs/v1beta1/projectref.go +++ b/apis/refs/v1beta1/projectref.go @@ -68,7 +68,7 @@ func ResolveProjectFromAnnotation(ctx context.Context, reader client.Reader, src } // ResolveProject will resolve a ProjectRef to a Project, with the ProjectID. -func ResolveProject(ctx context.Context, reader client.Reader, src client.Object, ref *ProjectRef) (*Project, error) { +func ResolveProject(ctx context.Context, reader client.Reader, otherNamespace string, ref *ProjectRef) (*Project, error) { if ref == nil { return nil, nil } @@ -103,7 +103,7 @@ func ResolveProject(ctx context.Context, reader client.Reader, src client.Object Name: ref.Name, } if key.Namespace == "" { - key.Namespace = src.GetNamespace() + key.Namespace = otherNamespace } project := &unstructured.Unstructured{} @@ -136,7 +136,7 @@ func ResolveProjectID(ctx context.Context, reader client.Reader, obj *unstructur External: projectRefExternal, } - project, err := ResolveProject(ctx, reader, obj, &projectRef) + project, err := ResolveProject(ctx, reader, obj.GetNamespace(), &projectRef) if err != nil { return "", fmt.Errorf("cannot parse projectRef.external %q in %v %v/%v: %w", projectRefExternal, obj.GetKind(), obj.GetNamespace(), obj.GetName(), err) } @@ -155,7 +155,7 @@ func ResolveProjectID(ctx context.Context, reader client.Reader, obj *unstructur projectRef.Namespace = obj.GetNamespace() } - project, err := ResolveProject(ctx, reader, obj, &projectRef) + project, err := ResolveProject(ctx, reader, obj.GetNamespace(), &projectRef) if err != nil { return "", fmt.Errorf("cannot parse projectRef in %v %v/%v: %w", obj.GetKind(), obj.GetNamespace(), obj.GetName(), err) } diff --git a/apis/securesourcemanager/v1alpha1/instance_reference.go b/apis/securesourcemanager/v1alpha1/instance_reference.go index 616a5dd8ac..a1fbb0fab8 100644 --- a/apis/securesourcemanager/v1alpha1/instance_reference.go +++ b/apis/securesourcemanager/v1alpha1/instance_reference.go @@ -113,7 +113,7 @@ func NewSecureSourceManagerInstanceRef(ctx context.Context, reader client.Reader id := &SecureSourceManagerInstanceRef{} // Get Parent - projectRef, err := refsv1beta1.ResolveProject(ctx, reader, obj, obj.Spec.ProjectRef) + projectRef, err := refsv1beta1.ResolveProject(ctx, reader, obj.GetNamespace(), obj.Spec.ProjectRef) if err != nil { return nil, err } diff --git a/apis/securesourcemanager/v1alpha1/repository_reference.go b/apis/securesourcemanager/v1alpha1/repository_reference.go index 07982266f3..3acceb148c 100644 --- a/apis/securesourcemanager/v1alpha1/repository_reference.go +++ b/apis/securesourcemanager/v1alpha1/repository_reference.go @@ -90,7 +90,7 @@ func NewSecureSourceManagerRepositoryRef(ctx context.Context, reader client.Read id := &SecureSourceManagerRepositoryRef{} // Get Parent - projectRef, err := refsv1beta1.ResolveProject(ctx, reader, obj, obj.Spec.ProjectRef) + projectRef, err := refsv1beta1.ResolveProject(ctx, reader, obj.GetNamespace(), obj.Spec.ProjectRef) if err != nil { return nil, err } diff --git a/apis/workstations/v1alpha1/cluster_reference.go b/apis/workstations/v1alpha1/cluster_reference.go index 6e88abe01b..2546bc3b08 100644 --- a/apis/workstations/v1alpha1/cluster_reference.go +++ b/apis/workstations/v1alpha1/cluster_reference.go @@ -88,7 +88,7 @@ func NewWorkstationClusterRef(ctx context.Context, reader client.Reader, obj *Wo id := &WorkstationClusterRef{} // Get Parent - projectRef, err := refsv1beta1.ResolveProject(ctx, reader, obj, &obj.Spec.ProjectRef) + projectRef, err := refsv1beta1.ResolveProject(ctx, reader, obj.GetNamespace(), &obj.Spec.ProjectRef) if err != nil { return nil, err } diff --git a/apis/workstations/v1alpha1/config_reference.go b/apis/workstations/v1alpha1/config_reference.go index 0f8116a632..15b9d77216 100644 --- a/apis/workstations/v1alpha1/config_reference.go +++ b/apis/workstations/v1alpha1/config_reference.go @@ -88,7 +88,7 @@ func NewWorkstationConfigRef(ctx context.Context, reader client.Reader, obj *Wor id := &WorkstationConfigRef{} // Get Parent - projectRef, err := refsv1beta1.ResolveProject(ctx, reader, obj, obj.Spec.ProjectRef) + projectRef, err := refsv1beta1.ResolveProject(ctx, reader, obj.GetNamespace(), obj.Spec.ProjectRef) if err != nil { return nil, err } diff --git a/apis/workstations/v1beta1/cluster_reference.go b/apis/workstations/v1beta1/cluster_reference.go index 06c49aeaa5..c64042115b 100644 --- a/apis/workstations/v1beta1/cluster_reference.go +++ b/apis/workstations/v1beta1/cluster_reference.go @@ -88,7 +88,7 @@ func NewWorkstationClusterRef(ctx context.Context, reader client.Reader, obj *Wo id := &WorkstationClusterRef{} // Get Parent - projectRef, err := refsv1beta1.ResolveProject(ctx, reader, obj, &obj.Spec.ProjectRef) + projectRef, err := refsv1beta1.ResolveProject(ctx, reader, obj.GetNamespace(), &obj.Spec.ProjectRef) if err != nil { return nil, err } diff --git a/dev/tools/controllerbuilder/template/apis/identity.go b/dev/tools/controllerbuilder/template/apis/identity.go index 2aed5a2388..2b7859c8c9 100644 --- a/dev/tools/controllerbuilder/template/apis/identity.go +++ b/dev/tools/controllerbuilder/template/apis/identity.go @@ -59,7 +59,7 @@ func (p *{{.ProtoResource}}Parent) String() string { func New{{.ProtoResource}}Identity(ctx context.Context, reader client.Reader, obj *{{.Kind}}) (*{{.ProtoResource}}Identity, error) { // Get Parent - projectRef, err := refsv1beta1.ResolveProject(ctx, reader, obj, obj.Spec.ProjectRef) + projectRef, err := refsv1beta1.ResolveProject(ctx, reader, obj.GetNamespace(), obj.Spec.ProjectRef) if err != nil { return nil, err } diff --git a/pkg/controller/direct/bigqueryanalyticshub/dataexchange_controller.go b/pkg/controller/direct/bigqueryanalyticshub/dataexchange_controller.go index 9b3ae36eb1..17491cacb3 100644 --- a/pkg/controller/direct/bigqueryanalyticshub/dataexchange_controller.go +++ b/pkg/controller/direct/bigqueryanalyticshub/dataexchange_controller.go @@ -84,7 +84,7 @@ func (m *model) AdapterForObject(ctx context.Context, reader client.Reader, u *u return nil, fmt.Errorf("cannot resolve resource ID") } - projectRef, err := refs.ResolveProject(ctx, reader, obj, obj.Spec.ProjectRef) + projectRef, err := refs.ResolveProject(ctx, reader, obj.GetNamespace(), obj.Spec.ProjectRef) if err != nil { return nil, err } diff --git a/pkg/controller/direct/bigquerydatatransfer/bigquerydatatransferconfig_controller.go b/pkg/controller/direct/bigquerydatatransfer/bigquerydatatransferconfig_controller.go index 83aa240308..4e3a1a9a1b 100644 --- a/pkg/controller/direct/bigquerydatatransfer/bigquerydatatransferconfig_controller.go +++ b/pkg/controller/direct/bigquerydatatransfer/bigquerydatatransferconfig_controller.go @@ -125,7 +125,7 @@ func (m *model) AdapterForObject(ctx context.Context, reader client.Reader, u *u } // Resolve Project Ref - projectRef, err := refv1beta1.ResolveProject(ctx, reader, obj, obj.Spec.ProjectRef) + projectRef, err := refv1beta1.ResolveProject(ctx, reader, obj.GetNamespace(), obj.Spec.ProjectRef) if err != nil { return nil, err } diff --git a/pkg/controller/direct/certificatemanager/dnsauthorization_controller.go b/pkg/controller/direct/certificatemanager/dnsauthorization_controller.go index 869db3ce39..4a60bbb41f 100644 --- a/pkg/controller/direct/certificatemanager/dnsauthorization_controller.go +++ b/pkg/controller/direct/certificatemanager/dnsauthorization_controller.go @@ -86,7 +86,7 @@ func (m *model) AdapterForObject(ctx context.Context, reader client.Reader, u *u return nil, fmt.Errorf("cannot resolve resource ID") } - projectRef, err := refs.ResolveProject(ctx, reader, obj, &obj.Spec.ProjectRef) + projectRef, err := refs.ResolveProject(ctx, reader, obj.GetNamespace(), &obj.Spec.ProjectRef) if err != nil { return nil, err } diff --git a/pkg/controller/direct/cloudbuild/workerpool_controller.go b/pkg/controller/direct/cloudbuild/workerpool_controller.go index 711f528e41..037a611fd2 100644 --- a/pkg/controller/direct/cloudbuild/workerpool_controller.go +++ b/pkg/controller/direct/cloudbuild/workerpool_controller.go @@ -97,7 +97,7 @@ func (m *model) AdapterForObject(ctx context.Context, reader client.Reader, u *u return nil, fmt.Errorf("cannot resolve resource ID") } // Get GCP Project - projectRef, err := refs.ResolveProject(ctx, reader, obj, obj.Spec.ProjectRef) + projectRef, err := refs.ResolveProject(ctx, reader, obj.GetNamespace(), obj.Spec.ProjectRef) if err != nil { return nil, err } diff --git a/pkg/controller/direct/common/refs.go b/pkg/controller/direct/common/refs.go index 7ef1ae58f0..95163a7737 100644 --- a/pkg/controller/direct/common/refs.go +++ b/pkg/controller/direct/common/refs.go @@ -61,7 +61,7 @@ func normalizeResourceName(ctx context.Context, reader client.Reader, src client switch ref.Kind { case "Project": - project, err := refs.ResolveProject(ctx, reader, src, &refs.ProjectRef{ + project, err := refs.ResolveProject(ctx, reader, src.GetNamespace(), &refs.ProjectRef{ Name: ref.Name, Namespace: ref.Namespace, External: ref.External, @@ -167,7 +167,7 @@ func normalizeProjectRef(ctx context.Context, reader client.Reader, src client.O return nil, nil } - project, err := refs.ResolveProject(ctx, reader, src, ref) + project, err := refs.ResolveProject(ctx, reader, src.GetNamespace(), ref) if err != nil { return nil, err } diff --git a/pkg/controller/direct/dataflow/refs.go b/pkg/controller/direct/dataflow/refs.go index d114da1492..d7ef622608 100644 --- a/pkg/controller/direct/dataflow/refs.go +++ b/pkg/controller/direct/dataflow/refs.go @@ -26,7 +26,7 @@ func normalizeProjectRef(ctx context.Context, reader client.Reader, src client.O return nil, nil } - project, err := refs.ResolveProject(ctx, reader, src, ref) + project, err := refs.ResolveProject(ctx, reader, src.GetNamespace(), ref) if err != nil { return nil, err } diff --git a/pkg/controller/direct/dataform/repository_controller.go b/pkg/controller/direct/dataform/repository_controller.go index f33344954c..b6efd57b61 100644 --- a/pkg/controller/direct/dataform/repository_controller.go +++ b/pkg/controller/direct/dataform/repository_controller.go @@ -80,7 +80,7 @@ func (m *model) AdapterForObject(ctx context.Context, reader client.Reader, u *u return nil, fmt.Errorf("cannot resolve resource ID") } - projectRef, err := apirefs.ResolveProject(ctx, reader, obj, obj.Spec.ProjectRef) + projectRef, err := apirefs.ResolveProject(ctx, reader, obj.GetNamespace(), obj.Spec.ProjectRef) if err != nil { return nil, err } diff --git a/pkg/controller/direct/firestore/firestoredatabase_controller.go b/pkg/controller/direct/firestore/firestoredatabase_controller.go index f595184a3a..54a34ea2e8 100644 --- a/pkg/controller/direct/firestore/firestoredatabase_controller.go +++ b/pkg/controller/direct/firestore/firestoredatabase_controller.go @@ -102,7 +102,7 @@ func (m *model) AdapterForObject(ctx context.Context, reader client.Reader, u *u } // Get Project ID - projectRef, err := refs.ResolveProject(ctx, reader, obj, &obj.Spec.ProjectRef) + projectRef, err := refs.ResolveProject(ctx, reader, obj.GetNamespace(), &obj.Spec.ProjectRef) if err != nil { return nil, err } diff --git a/pkg/controller/direct/gkehub/featuremembership_controller.go b/pkg/controller/direct/gkehub/featuremembership_controller.go index f4e8f5ea37..08ab11224d 100644 --- a/pkg/controller/direct/gkehub/featuremembership_controller.go +++ b/pkg/controller/direct/gkehub/featuremembership_controller.go @@ -89,7 +89,7 @@ func (m *gkeHubModel) AdapterForObject(ctx context.Context, reader client.Reader Namespace: obj.Spec.ProjectRef.Namespace, External: obj.Spec.ProjectRef.External, } - project, err := refs.ResolveProject(ctx, reader, obj, projectRef) + project, err := refs.ResolveProject(ctx, reader, u.GetNamespace(), projectRef) if err != nil { return nil, err } diff --git a/pkg/controller/direct/kms/autokeyconfig/autokeyconfig_controller.go b/pkg/controller/direct/kms/autokeyconfig/autokeyconfig_controller.go index 65f5dba33d..79de711078 100644 --- a/pkg/controller/direct/kms/autokeyconfig/autokeyconfig_controller.go +++ b/pkg/controller/direct/kms/autokeyconfig/autokeyconfig_controller.go @@ -84,7 +84,7 @@ func (m *model) AdapterForObject(ctx context.Context, reader client.Reader, u *u var keyProject *refs.Project if obj.Spec.KeyProjectRef != nil { var err error - keyProject, err = refs.ResolveProject(ctx, reader, obj, obj.Spec.KeyProjectRef) + keyProject, err = refs.ResolveProject(ctx, reader, obj.GetNamespace(), obj.Spec.KeyProjectRef) if err != nil { return nil, fmt.Errorf("unable to resolve key project for autokeyConfig naem: %s, err: %w", obj.GetName(), err) } diff --git a/pkg/controller/direct/logging/logbucketref.go b/pkg/controller/direct/logging/logbucketref.go index dff88a355b..4239f720f8 100644 --- a/pkg/controller/direct/logging/logbucketref.go +++ b/pkg/controller/direct/logging/logbucketref.go @@ -99,7 +99,7 @@ func LogBucketRef_ConvertToExternal(ctx context.Context, reader client.Reader, s Namespace: obj.Spec.ProjectRef.Namespace, External: obj.Spec.ProjectRef.External, } - project, err := refs.ResolveProject(ctx, reader, loggingLogBucket, projectRef) + project, err := refs.ResolveProject(ctx, reader, loggingLogBucket.GetNamespace(), projectRef) if err != nil { return fmt.Errorf("cannot get project for referenced LoggingLogBucket %v: %w", key, err) } diff --git a/pkg/controller/direct/logging/logmetric_controller.go b/pkg/controller/direct/logging/logmetric_controller.go index bcdb20ce0c..32db91c031 100644 --- a/pkg/controller/direct/logging/logmetric_controller.go +++ b/pkg/controller/direct/logging/logmetric_controller.go @@ -89,7 +89,7 @@ func (m *logMetricModel) AdapterForObject(ctx context.Context, reader client.Rea return nil, fmt.Errorf("cannot resolve resource ID") } - projectRef, err := refs.ResolveProject(ctx, reader, obj, &obj.Spec.ProjectRef) + projectRef, err := refs.ResolveProject(ctx, reader, obj.GetNamespace(), &obj.Spec.ProjectRef) if err != nil { return nil, err } diff --git a/pkg/controller/direct/monitoring/monitoringdashboard_controller.go b/pkg/controller/direct/monitoring/monitoringdashboard_controller.go index b0b7636e7f..3bb5fe14a7 100644 --- a/pkg/controller/direct/monitoring/monitoringdashboard_controller.go +++ b/pkg/controller/direct/monitoring/monitoringdashboard_controller.go @@ -88,7 +88,7 @@ func (m *dashboardModel) AdapterForObject(ctx context.Context, kube client.Reade return nil, fmt.Errorf("cannot resolve resource ID") } - projectRef, err := refs.ResolveProject(ctx, kube, obj, &obj.Spec.ProjectRef) + projectRef, err := refs.ResolveProject(ctx, kube, obj.GetNamespace(), &obj.Spec.ProjectRef) if err != nil { return nil, err } diff --git a/pkg/controller/direct/networkconnectivity/refs.go b/pkg/controller/direct/networkconnectivity/refs.go index c13046522b..8b8cd4505e 100644 --- a/pkg/controller/direct/networkconnectivity/refs.go +++ b/pkg/controller/direct/networkconnectivity/refs.go @@ -26,7 +26,7 @@ func normalizeProjectRef(ctx context.Context, reader client.Reader, src client.O return nil, nil } - project, err := refs.ResolveProject(ctx, reader, src, ref) + project, err := refs.ResolveProject(ctx, reader, src.GetNamespace(), ref) if err != nil { return nil, err } diff --git a/pkg/controller/direct/networkconnectivity/serviceconnectionpolicy_controller.go b/pkg/controller/direct/networkconnectivity/serviceconnectionpolicy_controller.go index 2129400ad4..6fbc821370 100644 --- a/pkg/controller/direct/networkconnectivity/serviceconnectionpolicy_controller.go +++ b/pkg/controller/direct/networkconnectivity/serviceconnectionpolicy_controller.go @@ -95,7 +95,7 @@ func (m *serviceConnectionPolicyModel) AdapterForObject(ctx context.Context, kub return nil, fmt.Errorf("cannot resolve location") } - projectRef, err := refs.ResolveProject(ctx, kube, obj, &obj.Spec.ProjectRef) + projectRef, err := refs.ResolveProject(ctx, kube, obj.GetNamespace(), &obj.Spec.ProjectRef) if err != nil { return nil, err } diff --git a/pkg/controller/direct/privateca/privatecapool_controller.go b/pkg/controller/direct/privateca/privatecapool_controller.go index 311039d820..a1b33e43dc 100644 --- a/pkg/controller/direct/privateca/privatecapool_controller.go +++ b/pkg/controller/direct/privateca/privatecapool_controller.go @@ -90,7 +90,7 @@ func (m *caPoolModel) AdapterForObject(ctx context.Context, reader client.Reader return nil, fmt.Errorf("cannot resolve location") } - projectRef, err := refs.ResolveProject(ctx, reader, obj, refs.AsProjectRef(&obj.Spec.ProjectRef)) + projectRef, err := refs.ResolveProject(ctx, reader, obj.GetNamespace(), refs.AsProjectRef(&obj.Spec.ProjectRef)) if err != nil { return nil, err } diff --git a/pkg/controller/direct/privilegedaccessmanager/entitlement_controller.go b/pkg/controller/direct/privilegedaccessmanager/entitlement_controller.go index a90772d0f6..0edb83a7bb 100644 --- a/pkg/controller/direct/privilegedaccessmanager/entitlement_controller.go +++ b/pkg/controller/direct/privilegedaccessmanager/entitlement_controller.go @@ -169,7 +169,7 @@ func oneOfContainer(ctx context.Context, reader client.Reader, obj *krm.Privileg container := "" switch containerRef.(type) { case *refs.ProjectRef: - project, err := refs.ResolveProject(ctx, reader, obj, projectRef) + project, err := refs.ResolveProject(ctx, reader, obj.GetNamespace(), projectRef) if err != nil { return "", err } diff --git a/pkg/controller/direct/redis/cluster/rediscluster_controller.go b/pkg/controller/direct/redis/cluster/rediscluster_controller.go index 5f1a0815ce..996e4cfecc 100644 --- a/pkg/controller/direct/redis/cluster/rediscluster_controller.go +++ b/pkg/controller/direct/redis/cluster/rediscluster_controller.go @@ -97,7 +97,7 @@ func (m *redisClusterModel) AdapterForObject(ctx context.Context, kube client.Re return nil, fmt.Errorf("cannot resolve location") } - projectRef, err := refs.ResolveProject(ctx, kube, obj, &obj.Spec.ProjectRef) + projectRef, err := refs.ResolveProject(ctx, kube, obj.GetNamespace(), &obj.Spec.ProjectRef) if err != nil { return nil, err } diff --git a/pkg/controller/direct/redis/cluster/refs.go b/pkg/controller/direct/redis/cluster/refs.go index 65a18c6025..2b996414db 100644 --- a/pkg/controller/direct/redis/cluster/refs.go +++ b/pkg/controller/direct/redis/cluster/refs.go @@ -26,7 +26,7 @@ func normalizeProjectRef(ctx context.Context, reader client.Reader, src client.O return nil, nil } - project, err := refs.ResolveProject(ctx, reader, src, ref) + project, err := refs.ResolveProject(ctx, reader, src.GetNamespace(), ref) if err != nil { return nil, err } diff --git a/pkg/controller/direct/workstations/cluster_controller.go b/pkg/controller/direct/workstations/cluster_controller.go index f09158f390..1edc2044d6 100644 --- a/pkg/controller/direct/workstations/cluster_controller.go +++ b/pkg/controller/direct/workstations/cluster_controller.go @@ -116,7 +116,7 @@ func (m *modelWorkstationCluster) AdapterForObject(ctx context.Context, reader c return nil, fmt.Errorf("cannot resolve resource ID") } - projectRef, err := refs.ResolveProject(ctx, reader, obj, &obj.Spec.ProjectRef) + projectRef, err := refs.ResolveProject(ctx, reader, obj.GetNamespace(), &obj.Spec.ProjectRef) if err != nil { return nil, err } diff --git a/pkg/controller/direct/workstations/cluster_normalize.go b/pkg/controller/direct/workstations/cluster_normalize.go index 087e2d1a64..f213057d05 100644 --- a/pkg/controller/direct/workstations/cluster_normalize.go +++ b/pkg/controller/direct/workstations/cluster_normalize.go @@ -40,7 +40,7 @@ func NormalizeWorkstationCluster(ctx context.Context, kube client.Reader, obj *k if obj.Spec.PrivateClusterConfig != nil && obj.Spec.PrivateClusterConfig.AllowedProjects != nil { var resolvedProjects []refs.ProjectRef for _, projectRef := range obj.Spec.PrivateClusterConfig.AllowedProjects { - resolvedProject, err := refs.ResolveProject(ctx, kube, obj, &projectRef) + resolvedProject, err := refs.ResolveProject(ctx, kube, obj.GetNamespace(), &projectRef) if err != nil { return err }