diff --git a/api/v2/checluster_webhook.go b/api/v2/checluster_webhook.go index eb0fd249e..7b1b23102 100644 --- a/api/v2/checluster_webhook.go +++ b/api/v2/checluster_webhook.go @@ -18,6 +18,9 @@ import ( "strconv" "strings" + "github.com/devfile/devworkspace-operator/pkg/infrastructure" + "k8s.io/utils/pointer" + "github.com/eclipse-che/che-operator/pkg/common/constants" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/types" @@ -43,6 +46,14 @@ var _ webhook.Defaulter = &CheCluster{} // Default implements webhook.Defaulter so a webhook will be registered for the type func (r *CheCluster) Default() { setContainerBuildConfiguration(r) + setDisableContainerBuildCapabilities(r) +} + +func setDisableContainerBuildCapabilities(cheCluster *CheCluster) { + // Container build capabilities can be enabled on OpenShift only + if !infrastructure.IsOpenShift() { + cheCluster.Spec.DevEnvironments.DisableContainerBuildCapabilities = pointer.Bool(true) + } } // Sets ContainerBuildConfiguration if container build capabilities is enabled. diff --git a/pkg/deploy/migration/checluster-defaults-cleaner_test.go b/pkg/deploy/migration/checluster-defaults-cleaner_test.go index e114cb75c..83cb50fdb 100644 --- a/pkg/deploy/migration/checluster-defaults-cleaner_test.go +++ b/pkg/deploy/migration/checluster-defaults-cleaner_test.go @@ -550,39 +550,6 @@ func TestCheClusterDefaultsCleanerDisableContainerBuildCapabilities(t *testing.T } testCases := []testCase{ - { - name: "Kubernetes case #1", - infra: infrastructure.Kubernetes, - cheCluster: &chev2.CheCluster{ - ObjectMeta: metav1.ObjectMeta{ - Name: "eclipse-che", - Namespace: "eclipse-che", - }, - Status: chev2.CheClusterStatus{ - CheVersion: "next", - }, - }, - expectedDisableContainerBuildCapabilities: pointer.BoolPtr(true), - }, - { - name: "Kubernetes case #2", - infra: infrastructure.Kubernetes, - cheCluster: &chev2.CheCluster{ - ObjectMeta: metav1.ObjectMeta{ - Name: "eclipse-che", - Namespace: "eclipse-che", - }, - Spec: chev2.CheClusterSpec{ - DevEnvironments: chev2.CheClusterDevEnvironments{ - DisableContainerBuildCapabilities: pointer.BoolPtr(false), - }, - }, - Status: chev2.CheClusterStatus{ - CheVersion: "next", - }, - }, - expectedDisableContainerBuildCapabilities: pointer.BoolPtr(true), - }, { name: "OpenShift case #1", infra: infrastructure.OpenShiftv4,