From 62385cca96cd411f991778b90d77f7bbcdebb20d Mon Sep 17 00:00:00 2001 From: Kaustav Majumder Date: Mon, 14 Oct 2024 15:17:54 +0530 Subject: [PATCH] Allow remote noobaa deletion Signed-off-by: Kaustav Majumder --- services/provider/server/server.go | 10 +++++++--- services/provider/server/server_test.go | 9 ++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/services/provider/server/server.go b/services/provider/server/server.go index 9f127f80d5..b4b7bd286c 100644 --- a/services/provider/server/server.go +++ b/services/provider/server/server.go @@ -11,7 +11,6 @@ import ( "encoding/json" "encoding/pem" "fmt" - "k8s.io/utils/ptr" "math" "net" "slices" @@ -19,6 +18,8 @@ import ( "strings" "time" + "k8s.io/utils/ptr" + "github.com/blang/semver/v4" nbv1 "github.com/noobaa/noobaa-operator/v5/pkg/apis/noobaa/v1alpha1" quotav1 "github.com/openshift/api/quota/v1" @@ -433,17 +434,20 @@ func (s *OCSProviderServer) getExternalResources(ctx context.Context, consumerRe Kind: "Secret", Data: mustMarshal(map[string]string{ "auth_token": string(authToken), - "mgmt_addr": noobaaMgmtAddress, + "mgmt_addr": fmt.Sprintf("https://%s:443", noobaaMgmtAddress), }), }) extR = append(extR, &pb.ExternalResource{ - Name: "noobaa-remote", + Name: "noobaa", Kind: "Noobaa", Data: mustMarshal(&nbv1.NooBaaSpec{ JoinSecret: &v1.SecretReference{ Name: "noobaa-remote-join-secret", }, + CleanupPolicy: nbv1.CleanupPolicySpec{ + AllowNoobaaDeletion: true, + }, }), }) return extR, nil diff --git a/services/provider/server/server_test.go b/services/provider/server/server_test.go index e23635362f..43cd62c905 100644 --- a/services/provider/server/server_test.go +++ b/services/provider/server/server_test.go @@ -62,11 +62,14 @@ var noobaaSpec = &nbv1.NooBaaSpec{ JoinSecret: &v1.SecretReference{ Name: "noobaa-remote-join-secret", }, + CleanupPolicy: nbv1.CleanupPolicySpec{ + AllowNoobaaDeletion: true, + }, } var joinSecret = map[string]string{ "auth_token": "authToken", - "mgmt_addr": "noobaaMgmtAddress", + "mgmt_addr": "https://noobaaMgmtAddress:443", } var mockExtR = map[string]*externalResource{ @@ -100,8 +103,8 @@ var mockExtR = map[string]*externalResource{ Kind: "Secret", Data: joinSecret, }, - "noobaa-remote": { - Name: "noobaa-remote", + "noobaa": { + Name: "noobaa", Kind: "Noobaa", Data: noobaaSpec, },