chore: make Eclipse Che compatible with OCP 4.12 instance without the… (#1514)

* chore: make Eclipse Che compatible with OCP 4.12 instance without the Console

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
pull/1515/head
Anatolii Bazko 2022-09-07 17:53:44 +03:00 committed by GitHub
parent 848c033c8e
commit 53354c9004
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 6 deletions

View File

@ -14,7 +14,6 @@ package consolelink
import (
"fmt"
"github.com/devfile/devworkspace-operator/pkg/infrastructure"
"github.com/eclipse-che/che-operator/pkg/common/chetypes"
defaults "github.com/eclipse-che/che-operator/pkg/common/operator-defaults"
"github.com/eclipse-che/che-operator/pkg/common/utils"
@ -46,7 +45,7 @@ func NewConsoleLinkReconciler() *ConsoleLinkReconciler {
}
func (c *ConsoleLinkReconciler) Reconcile(ctx *chetypes.DeployContext) (reconcile.Result, bool, error) {
if !infrastructure.IsOpenShift() || !utils.IsK8SResourceServed(ctx.ClusterAPI.DiscoveryClient, ConsoleLinksResourceName) {
if !utils.IsK8SResourceServed(ctx.ClusterAPI.DiscoveryClient, ConsoleLinksResourceName) {
logrus.Debug("Console link won't be created. ConsoleLinks is not supported by kubernetes cluster.")
return reconcile.Result{}, true, nil
}

View File

@ -15,6 +15,8 @@ package dashboard
import (
"os"
fakeDiscovery "k8s.io/client-go/discovery/fake"
"k8s.io/apimachinery/pkg/api/resource"
"github.com/devfile/devworkspace-operator/pkg/infrastructure"
@ -236,6 +238,13 @@ func TestDashboardDeploymentEnvVars(t *testing.T) {
t.Run(testCase.name, func(t *testing.T) {
logf.SetLogger(zap.New(zap.WriteTo(os.Stdout), zap.UseDevMode(true)))
ctx := test.GetDeployContext(testCase.cheCluster, testCase.initObjects)
ctx.ClusterAPI.DiscoveryClient.(*fakeDiscovery.FakeDiscovery).Fake.Resources = []*metav1.APIResourceList{
{
APIResources: []metav1.APIResource{
{Name: ConsoleLinksResourceName},
},
},
}
dashboard := NewDashboardReconciler()
deployment, err := dashboard.getDashboardDeploymentSpec(ctx)

View File

@ -16,7 +16,6 @@ import (
"context"
"fmt"
"github.com/devfile/devworkspace-operator/pkg/infrastructure"
"github.com/eclipse-che/che-operator/pkg/common/chetypes"
"github.com/eclipse-che/che-operator/pkg/common/constants"
defaults "github.com/eclipse-che/che-operator/pkg/common/operator-defaults"
@ -32,8 +31,11 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"
)
const CHE_SELF_SIGNED_MOUNT_PATH = "/public-certs/che-self-signed"
const CHE_CUSTOM_CERTS_MOUNT_PATH = "/public-certs/custom"
const (
CHE_SELF_SIGNED_MOUNT_PATH = "/public-certs/che-self-signed"
CHE_CUSTOM_CERTS_MOUNT_PATH = "/public-certs/custom"
ConsoleLinksResourceName = "consolelinks"
)
func (d *DashboardReconciler) getDashboardDeploymentSpec(ctx *chetypes.DeployContext) (*appsv1.Deployment, error) {
var volumes []corev1.Volume
@ -73,7 +75,7 @@ func (d *DashboardReconciler) getDashboardDeploymentSpec(ctx *chetypes.DeployCon
Value: fmt.Sprintf("http://%s.%s.svc:8080/api", deploy.CheServiceName, ctx.CheCluster.Namespace)},
)
if infrastructure.IsOpenShift() {
if utils.IsK8SResourceServed(ctx.ClusterAPI.DiscoveryClient, ConsoleLinksResourceName) {
envVars = append(envVars,
corev1.EnvVar{
Name: "OPENSHIFT_CONSOLE_URL",