fix: Disable container build capabilities on Kubernetes (#1719)

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
pull/1721/head
Anatolii Bazko 2023-07-05 12:18:53 +02:00 committed by GitHub
parent 4db565cb8e
commit 1bf8dde7b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 33 deletions

View File

@ -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.

View File

@ -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,