diff --git a/api/v1alpha1/nonadminrestore_types.go b/api/v1alpha1/nonadminrestore_types.go index 47b80be..4a50149 100644 --- a/api/v1alpha1/nonadminrestore_types.go +++ b/api/v1alpha1/nonadminrestore_types.go @@ -24,9 +24,7 @@ import ( // NonAdminRestoreSpec defines the desired state of NonAdminRestore type NonAdminRestoreSpec struct { // Specification for a Velero restore. - // +kubebuilder:validation:Required - RestoreSpec *velerov1api.RestoreSpec `json:"restoreSpec,omitempty"` - // TODO add test that NAR can not be created without restoreSpec or restoreSpec.backupName + RestoreSpec *velerov1api.RestoreSpec `json:"restoreSpec"` // TODO need to investigate restoreSpec.namespaceMapping, depends on how NAC tracks the namespace access per user // TODO NonAdminRestore log level, by default TODO. diff --git a/config/crd/bases/nac.oadp.openshift.io_nonadminrestores.yaml b/config/crd/bases/nac.oadp.openshift.io_nonadminrestores.yaml index 6b8f540..fa420e3 100644 --- a/config/crd/bases/nac.oadp.openshift.io_nonadminrestores.yaml +++ b/config/crd/bases/nac.oadp.openshift.io_nonadminrestores.yaml @@ -445,6 +445,8 @@ spec: required: - backupName type: object + required: + - restoreSpec type: object status: description: NonAdminRestoreStatus defines the observed state of NonAdminRestore diff --git a/internal/controller/nonadminrestore_controller_test.go b/internal/controller/nonadminrestore_controller_test.go index 8d0e4ac..0f7474a 100644 --- a/internal/controller/nonadminrestore_controller_test.go +++ b/internal/controller/nonadminrestore_controller_test.go @@ -32,11 +32,6 @@ import ( "github.com/migtools/oadp-non-admin/internal/common/constant" ) -type clusterScenario struct { - namespace string - nonAdminRestore string -} - type nonAdminRestoreReconcileScenario struct { restoreSpec *v1.RestoreSpec namespace string @@ -56,65 +51,6 @@ func createTestNonAdminRestore(name string, namespace string, restoreSpec v1.Res } } -// TODO this does not work with envtest :question: -var _ = ginkgo.Describe("Test NonAdminRestore in cluster validation", func() { - var ( - ctx = context.Background() - currentTestScenario clusterScenario - updateTestScenario = func(scenario clusterScenario) { - currentTestScenario = scenario - } - ) - - ginkgo.AfterEach(func() { - nonAdminRestore := &nacv1alpha1.NonAdminRestore{} - if k8sClient.Get( - ctx, - types.NamespacedName{ - Name: currentTestScenario.nonAdminRestore, - Namespace: currentTestScenario.namespace, - }, - nonAdminRestore, - ) == nil { - gomega.Expect(k8sClient.Delete(ctx, nonAdminRestore)).To(gomega.Succeed()) - } - - namespace := &corev1.Namespace{ - ObjectMeta: metav1.ObjectMeta{ - Name: currentTestScenario.namespace, - }, - } - gomega.Expect(k8sClient.Delete(ctx, namespace)).To(gomega.Succeed()) - }) - - ginkgo.DescribeTable("Validation is false", - func(scenario clusterScenario) { - updateTestScenario(scenario) - - namespace := &corev1.Namespace{ - ObjectMeta: metav1.ObjectMeta{ - Name: scenario.namespace, - }, - } - gomega.Expect(k8sClient.Create(ctx, namespace)).To(gomega.Succeed()) - - nonAdminRestore := &nacv1alpha1.NonAdminRestore{ - ObjectMeta: metav1.ObjectMeta{ - Name: scenario.nonAdminRestore, - Namespace: scenario.namespace, - }, - // Spec: nacv1alpha1.NonAdminRestoreSpec{}, - } - gomega.Expect(k8sClient.Create(ctx, nonAdminRestore)).To(gomega.Not(gomega.Succeed())) - }, - ginkgo.Entry("Should NOT create NonAdminRestore without spec.restoreSpec", clusterScenario{ - namespace: "test-nonadminrestore-cluster-1", - nonAdminRestore: "test-nonadminrestore-cluster-1-cr", - }), - // TODO Should NOT create NonAdminRestore without spec.restoreSpec.backupName - ) -}) - var _ = ginkgo.Describe("Test NonAdminRestore Reconcile function", func() { var ( ctx = context.Background()