fix: Remove code depending on devworkspace.enable field (#1321)

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
pull/1323/head
Anatolii Bazko 2022-02-16 12:16:56 +02:00 committed by GitHub
parent f451dad61c
commit 4ff511928d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 34 deletions

View File

@ -111,7 +111,6 @@ func V2alpha1ToV1(v2 *v2alpha1.CheCluster, v1Obj *v1.CheCluster) error {
}
v1Obj.Annotations[v2alpha1StorageAnnotation] = string(v2Spec)
v2alpha1ToV1_Enabled(v1Obj, v2)
v2alpha1ToV1_Host(v1Obj, v2)
v2alpha1ToV1_GatewayImage(v1Obj, v2)
v2alpha1ToV1_GatewayConfigurerImage(v1Obj, v2)
@ -130,7 +129,7 @@ func V2alpha1ToV1(v2 *v2alpha1.CheCluster, v1Obj *v1.CheCluster) error {
}
func v1ToV2alpha1_Enabled(v1 *v1.CheCluster, v2 *v2alpha1.CheCluster) {
v2.Spec.Enabled = &v1.Spec.DevWorkspace.Enable
v2.Spec.Enabled = pointer.BoolPtr(true)
}
func v1ToV2alpha1_Host(v1 *v1.CheCluster, v2 *v2alpha1.CheCluster) {
@ -230,10 +229,6 @@ func v1ToV2alpha1_K8sIngressAnnotations(v1 *v1.CheCluster, v2 *v2alpha1.CheClust
}
}
func v2alpha1ToV1_Enabled(v1 *v1.CheCluster, v2 *v2alpha1.CheCluster) {
v1.Spec.DevWorkspace.Enable = v2.Spec.IsEnabled()
}
func v2alpha1ToV1_Host(v1 *v1.CheCluster, v2 *v2alpha1.CheCluster) {
v1.Spec.Server.CheHost = v2.Spec.Gateway.Host
}

View File

@ -137,8 +137,8 @@ func TestV1ToV2alpha1(t *testing.T) {
t.Error(err)
}
if *v2.Spec.Enabled {
t.Errorf("Unexpected v2.Spec.Enabled: %s", v2.Spec.Gateway.Host)
if !*v2.Spec.Enabled {
t.Errorf("Unexpected v2.Spec.Enabled: %t", *v2.Spec.Enabled)
}
})
@ -353,18 +353,6 @@ func TestV2alpha1ToV1(t *testing.T) {
}
})
t.Run("Enabled", func(t *testing.T) {
v1 := &v1.CheCluster{}
err := V2alpha1ToV1(&v2Obj, v1)
if err != nil {
t.Error(err)
}
if !v1.Spec.DevWorkspace.Enable {
t.Errorf("Unexpected v1.Spec.DevWorkspace.Enable: %v", v1.Spec.DevWorkspace.Enable)
}
})
t.Run("Host", func(t *testing.T) {
v1 := &v1.CheCluster{}
err := V2alpha1ToV1(&v2Obj, v1)

View File

@ -108,12 +108,11 @@ func doesCheClusterWithDevWorkspaceEnabledExist(mgr manager.Manager) (bool, erro
if err != nil {
return false, err
}
for _, cheCluster := range cheClusters.Items {
if cheCluster.Spec.DevWorkspace.Enable {
return true, nil
}
}
return false, nil
// Previous logic was depended on cheCluster.Spec.DevWorkspace.Enable field.
// Since DevWorkspace.Enable is enabled by default, then it is enough to check
// CheCluster existence.
return len(cheClusters.Items) != 0, nil
}
func findApiGroup(mgr manager.Manager, apiGroup string) (bool, error) {

View File

@ -103,12 +103,5 @@ func isOnlyOneOperatorManagesDWResources(deployContext *deploy.DeployContext) (b
return false, err
}
devWorkspaceEnabledNum := 0
for _, cheCluster := range cheClusters.Items {
if cheCluster.Spec.DevWorkspace.Enable {
devWorkspaceEnabledNum++
}
}
return devWorkspaceEnabledNum == 1, nil
return len(cheClusters.Items) == 1, nil
}