From 77b0248abfd11f1ffc7731fc2bd2a25cbe336178 Mon Sep 17 00:00:00 2001 From: Jeroen Vervaeke <9132134+jeroenvervaeke@users.noreply.github.com> Date: Wed, 22 Jan 2025 16:01:23 +0000 Subject: [PATCH] CLOUDP-296190: [Flex Clusters] --targetProjectId is not handled properly (#3572) --- internal/cli/backup/restores/start.go | 9 +++++++-- internal/kubernetes/operator/project/project.go | 5 ++--- internal/kubernetes/operator/project/project_test.go | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/internal/cli/backup/restores/start.go b/internal/cli/backup/restores/start.go index 710d76ed37..542baad436 100644 --- a/internal/cli/backup/restores/start.go +++ b/internal/cli/backup/restores/start.go @@ -85,12 +85,17 @@ func (opts *StartOpts) Run() error { } func (opts *StartOpts) newFlexBackupRestoreJobCreate() *admin.FlexBackupRestoreJobCreate20241113 { - return &admin.FlexBackupRestoreJobCreate20241113{ + request := &admin.FlexBackupRestoreJobCreate20241113{ SnapshotId: opts.snapshotID, TargetDeploymentItemName: opts.targetClusterName, - TargetProjectId: &opts.targetProjectID, InstanceName: &opts.clusterName, } + + if opts.targetProjectID != "" { + request.TargetProjectId = &opts.targetProjectID + } + + return request } func (opts *StartOpts) newCloudProviderSnapshotRestoreJob() *admin.DiskBackupSnapshotRestoreJob { diff --git a/internal/kubernetes/operator/project/project.go b/internal/kubernetes/operator/project/project.go index 82c8aa88ae..155bfd4438 100644 --- a/internal/kubernetes/operator/project/project.go +++ b/internal/kubernetes/operator/project/project.go @@ -184,7 +184,7 @@ func BuildAtlasProject(br *AtlasProjectBuildRequest) (*AtlasProjectResult, error } if br.Validator.FeatureExist(features.ResourceAtlasProject, featureCustomRoles) && !br.Validator.IsResourceSupported(features.ResourceAtlasCustomRole) { - customRoles, ferr := buildCustomRoles(br.ProjectStore, br.ProjectID) + customRoles, ferr := projectBuildCustomRoles(br.ProjectStore, br.ProjectID) if ferr != nil { return nil, ferr } @@ -275,8 +275,7 @@ func BuildProjectNamedConnectionSecret(credsProvider store.CredentialsGetter, na return secret } -//nolint:revive -func buildCustomRoles(crProvider store.DatabaseRoleLister, projectID string) ([]akov2.CustomRole, error) { +func projectBuildCustomRoles(crProvider store.DatabaseRoleLister, projectID string) ([]akov2.CustomRole, error) { dbRoles, err := crProvider.DatabaseRoles(projectID) if err != nil { return nil, err diff --git a/internal/kubernetes/operator/project/project_test.go b/internal/kubernetes/operator/project/project_test.go index 79a1663bd5..eb76baba95 100644 --- a/internal/kubernetes/operator/project/project_test.go +++ b/internal/kubernetes/operator/project/project_test.go @@ -1510,7 +1510,7 @@ func Test_buildCustomRoles(t *testing.T) { }, } - got, err := buildCustomRoles(rolesProvider, projectID) + got, err := projectBuildCustomRoles(rolesProvider, projectID) if err != nil { t.Fatalf("%v", err) }