Skip to content

Commit daf3edd

Browse files
committed
add crd list and check storagecluster ownership
Signed-off-by: Oded Viner <[email protected]>
1 parent d802422 commit daf3edd

File tree

4 files changed

+50
-325
lines changed

4 files changed

+50
-325
lines changed

cmd/odf/restore/crds.go

+47-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import (
55
"strings"
66

77
"github.com/red-hat-storage/odf-cli/cmd/odf/root"
8-
"github.com/red-hat-storage/odf-cli/pkg/crd"
98
"github.com/rook/kubectl-rook-ceph/pkg/k8sutil"
109
"github.com/rook/kubectl-rook-ceph/pkg/logging"
10+
pkgrestore "github.com/rook/kubectl-rook-ceph/pkg/restore"
1111
"github.com/spf13/cobra"
1212
)
1313

@@ -49,6 +49,15 @@ func parseFullyQualifiedCRD(fqcrd string) (resourceName, groupName, version stri
4949
return resourceName, groupName, ver, nil
5050
}
5151

52+
func contains(slice []string, item string) bool {
53+
for _, s := range slice {
54+
if s == item {
55+
return true
56+
}
57+
}
58+
return false
59+
}
60+
5261
// deletedCmd represents the deleted command
5362
var deletedCmd = &cobra.Command{
5463
Use: "deleted",
@@ -73,7 +82,43 @@ var deletedCmd = &cobra.Command{
7382
if len(args) > 1 {
7483
newArgs[1] = args[1]
7584
}
76-
crd.RestoreCrdNew(cmd.Context(), root.ClientSets, root.OperatorNamespace, root.StorageClusterNamespace, groupName, version, newArgs)
85+
var customResources []pkgrestore.CustomResource
86+
if contains(newArgs, "storageclusters") {
87+
customResources = []pkgrestore.CustomResource{
88+
// ceph.rook.io/v1
89+
{Group: "ceph.rook.io", Version: "v1", Resource: "cephblockpoolradosnamespaces"},
90+
{Group: "ceph.rook.io", Version: "v1", Resource: "cephblockpools"},
91+
{Group: "ceph.rook.io", Version: "v1", Resource: "cephbucketnotifications"},
92+
{Group: "ceph.rook.io", Version: "v1", Resource: "cephbuckettopics"},
93+
{Group: "ceph.rook.io", Version: "v1", Resource: "cephclients"},
94+
{Group: "ceph.rook.io", Version: "v1", Resource: "cephclusters"},
95+
{Group: "ceph.rook.io", Version: "v1", Resource: "cephcosidrivers"},
96+
{Group: "ceph.rook.io", Version: "v1", Resource: "cephfilesystemmirrors"},
97+
{Group: "ceph.rook.io", Version: "v1", Resource: "cephfilesystems"},
98+
{Group: "ceph.rook.io", Version: "v1", Resource: "cephfilesystemsubvolumegroups"},
99+
{Group: "ceph.rook.io", Version: "v1", Resource: "cephnfses"},
100+
{Group: "ceph.rook.io", Version: "v1", Resource: "cephobjectrealms"},
101+
{Group: "ceph.rook.io", Version: "v1", Resource: "cephobjectstores"},
102+
{Group: "ceph.rook.io", Version: "v1", Resource: "cephobjectstoreusers"},
103+
{Group: "ceph.rook.io", Version: "v1", Resource: "cephobjectzonegroups"},
104+
{Group: "ceph.rook.io", Version: "v1", Resource: "cephobjectzones"},
105+
{Group: "ceph.rook.io", Version: "v1", Resource: "cephrbdmirrors"},
106+
107+
// noobaa.io/v1alpha1
108+
{Group: "noobaa.io", Version: "v1alpha1", Resource: "backingstores"},
109+
{Group: "noobaa.io", Version: "v1alpha1", Resource: "bucketclasses"},
110+
{Group: "noobaa.io", Version: "v1alpha1", Resource: "namespacestores"},
111+
{Group: "noobaa.io", Version: "v1alpha1", Resource: "noobaaaccounts"},
112+
{Group: "noobaa.io", Version: "v1alpha1", Resource: "noobaas"},
113+
114+
// ocs.openshift.io/v1alpha1
115+
{Group: "ocs.openshift.io", Version: "v1alpha1", Resource: "storageconsumers"},
116+
}
117+
} else {
118+
customResources = []pkgrestore.CustomResource{}
119+
}
120+
121+
pkgrestore.RestoreCrd(cmd.Context(), root.ClientSets, root.OperatorNamespace, root.StorageClusterNamespace, groupName, version, "ocs-operator", customResources, newArgs)
77122
k8sutil.SetDeploymentScale(cmd.Context(), root.ClientSets.Kube, root.OperatorNamespace, "ocs-operator", 1)
78123
},
79124
}

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/pkg/errors v0.9.1
99
github.com/ramendr/ramenctl v0.4.0
1010
github.com/red-hat-storage/ocs-operator/api/v4 v4.0.0-20240701091545-dfffbde82a9d
11-
github.com/rook/kubectl-rook-ceph v0.9.3
11+
github.com/rook/kubectl-rook-ceph v0.9.4-0.20250428051344-dbfe77cc57a1
1212
github.com/rook/rook v1.17.1
1313
github.com/spf13/cobra v1.9.1
1414
github.com/stretchr/testify v1.10.0

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -743,8 +743,8 @@ github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTE
743743
github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o=
744744
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
745745
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
746-
github.com/rook/kubectl-rook-ceph v0.9.3 h1:+7THA8a+S2ArJrs9jpY1eJscAjPBKjlLXSmCVPU3eoY=
747-
github.com/rook/kubectl-rook-ceph v0.9.3/go.mod h1:dOQ+Yccc41DxZqe9jpvAUHsYTquYP/SKClrPmG70SLM=
746+
github.com/rook/kubectl-rook-ceph v0.9.4-0.20250428051344-dbfe77cc57a1 h1:znvPe0apxkTdkdiVINk0DfUbMGt6Vv+I9mgKfsr3odY=
747+
github.com/rook/kubectl-rook-ceph v0.9.4-0.20250428051344-dbfe77cc57a1/go.mod h1:UvOPYgfA3+ulKE2omD+A6g82hst24jwO4gY9JIZqfu8=
748748
github.com/rook/rook v1.17.1 h1:nNUGesl5UtCVGi8Ta/Gl2m5z9rNmqnEzqSjY6vRFzKA=
749749
github.com/rook/rook v1.17.1/go.mod h1:Z5nuT7cGJLek9nRDH92J3XTcdqGMIyGDsFYo/O3NuT0=
750750
github.com/rook/rook/pkg/apis v0.0.0-20241216163035-3170ac6a0c58 h1:z7TkRb4D+XvXIGg4ClSjZw8gAPQcZg9zUSFfZ0pUcTY=

0 commit comments

Comments
 (0)