diff --git a/controllers/default_test.go b/controllers/default_test.go index bc09594b..7eb9adf3 100644 --- a/controllers/default_test.go +++ b/controllers/default_test.go @@ -232,8 +232,8 @@ var _ = g.Describe("Reconcile default ShipwrightBuild installation", func() { test.EventuallyRemoved(ctx, k8sClient, expectedDeployment) }) - // TODO: Do not delete the CRDs! This is something only a cluster admin should do. - g.It("deletes the custom resource definitions for the Shipwright build APIs", func(ctx g.SpecContext) { + // Deteling the build instance should not delete CRDS + g.It("should not delete the custom resource definitions for the Shipwright build APIs", func(ctx g.SpecContext) { test.CRDEventuallyExists(ctx, k8sClient, "builds.shipwright.io") test.CRDEventuallyExists(ctx, k8sClient, "buildruns.shipwright.io") test.CRDEventuallyExists(ctx, k8sClient, "buildstrategies.shipwright.io") @@ -244,10 +244,10 @@ var _ = g.Describe("Reconcile default ShipwrightBuild installation", func() { o.Expect(err).NotTo(o.HaveOccurred()) // Verify - check the behavior - test.CRDEventuallyRemoved(ctx, k8sClient, "builds.shipwright.io") - test.CRDEventuallyRemoved(ctx, k8sClient, "buildruns.shipwright.io") - test.CRDEventuallyRemoved(ctx, k8sClient, "buildstrategies.shipwright.io") - test.CRDEventuallyRemoved(ctx, k8sClient, "clusterbuildstrategies.shipwright.io") + test.CRDEventuallyExists(ctx, k8sClient, "builds.shipwright.io") + test.CRDEventuallyExists(ctx, k8sClient, "buildruns.shipwright.io") + test.CRDEventuallyExists(ctx, k8sClient, "buildstrategies.shipwright.io") + test.CRDEventuallyExists(ctx, k8sClient, "clusterbuildstrategies.shipwright.io") }) }) diff --git a/controllers/shipwrightbuild_controller.go b/controllers/shipwrightbuild_controller.go index 0cec883d..96a5ef95 100644 --- a/controllers/shipwrightbuild_controller.go +++ b/controllers/shipwrightbuild_controller.go @@ -197,7 +197,7 @@ func (r *ShipwrightBuildReconciler) Reconcile(ctx context.Context, req ctrl.Requ } logger.Info("Deleting manifests...") - if err := manifest.Delete(); err != nil { + if err := manifest.Filter(manifestival.NoCRDs).Delete(); err != nil { logger.Error(err, "deleting manifest's resources") return RequeueWithError(err) }