diff --git a/pkg/deploy/server/server_configmap.go b/pkg/deploy/server/server_configmap.go index b8b19a755..fe5108701 100644 --- a/pkg/deploy/server/server_configmap.go +++ b/pkg/deploy/server/server_configmap.go @@ -43,6 +43,7 @@ type CheConfigMap struct { CheApi string `json:"CHE_API"` CheApiInternal string `json:"CHE_API_INTERNAL"` CheWebSocketEndpoint string `json:"CHE_WEBSOCKET_ENDPOINT"` + CheWebSocketInternalEndpoint string `json:"CHE_WEBSOCKET_INTERNAL_ENDPOINT"` CheDebugServer string `json:"CHE_DEBUG_SERVER"` CheMetricsEnabled string `json:"CHE_METRICS_ENABLED"` CheInfrastructureActive string `json:"CHE_INFRASTRUCTURE_ACTIVE"` @@ -75,7 +76,6 @@ type CheConfigMap struct { PluginRegistryInternalUrl string `json:"CHE_WORKSPACE_PLUGIN__REGISTRY__INTERNAL__URL,omitempty"` DevfileRegistryUrl string `json:"CHE_WORKSPACE_DEVFILE__REGISTRY__URL,omitempty"` DevfileRegistryInternalUrl string `json:"CHE_WORKSPACE_DEVFILE__REGISTRY__INTERNAL__URL,omitempty"` - WebSocketEndpointMinor string `json:"CHE_WEBSOCKET_ENDPOINT__MINOR"` CheWorkspacePluginBrokerMetadataImage string `json:"CHE_WORKSPACE_PLUGIN__BROKER_METADATA_IMAGE,omitempty"` CheWorkspacePluginBrokerArtifactsImage string `json:"CHE_WORKSPACE_PLUGIN__BROKER_ARTIFACTS_IMAGE,omitempty"` CheServerSecureExposerJwtProxyImage string `json:"CHE_SERVER_SECURE__EXPOSER_JWTPROXY_IMAGE,omitempty"` @@ -187,46 +187,32 @@ func (s *Server) getCheConfigMapData() (cheEnv map[string]string, err error) { workspaceNamespaceDefault := util.GetWorkspaceNamespaceDefault(s.deployContext.CheCluster) cheAPI := protocol + "://" + cheHost + "/api" - var keycloakInternalURL, pluginRegistryInternalURL, devfileRegistryInternalURL, cheInternalAPI, webSocketEndpoint, webSocketEndpointMinor string + var keycloakInternalURL, pluginRegistryInternalURL, devfileRegistryInternalURL, cheInternalAPI, webSocketInternalEndpoint string if s.deployContext.CheCluster.IsInternalClusterSVCNamesEnabled() && !s.deployContext.CheCluster.Spec.Auth.ExternalIdentityProvider { keycloakInternalURL = fmt.Sprintf("%s://%s.%s.svc:8080/auth", "http", deploy.IdentityProviderName, s.deployContext.CheCluster.Namespace) - } else { - keycloakInternalURL = keycloakURL } // If there is a devfile registry deployed by operator - if !s.deployContext.CheCluster.Spec.Server.ExternalDevfileRegistry { - if s.deployContext.CheCluster.IsInternalClusterSVCNamesEnabled() { - devfileRegistryInternalURL = fmt.Sprintf("http://%s.%s.svc:8080", deploy.DevfileRegistryName, s.deployContext.CheCluster.Namespace) - } else { - devfileRegistryInternalURL = s.deployContext.CheCluster.Status.DevfileRegistryURL - } + if s.deployContext.CheCluster.IsInternalClusterSVCNamesEnabled() && !s.deployContext.CheCluster.Spec.Server.ExternalDevfileRegistry { + devfileRegistryInternalURL = fmt.Sprintf("http://%s.%s.svc:8080", deploy.DevfileRegistryName, s.deployContext.CheCluster.Namespace) } if s.deployContext.CheCluster.IsInternalClusterSVCNamesEnabled() && !s.deployContext.CheCluster.Spec.Server.ExternalPluginRegistry { pluginRegistryInternalURL = fmt.Sprintf("http://%s.%s.svc:8080/v3", deploy.PluginRegistryName, s.deployContext.CheCluster.Namespace) - } else { - pluginRegistryInternalURL = pluginRegistryURL } if s.deployContext.CheCluster.IsInternalClusterSVCNamesEnabled() { cheInternalAPI = fmt.Sprintf("http://%s.%s.svc:8080/api", deploy.CheServiceName, s.deployContext.CheCluster.Namespace) - webSocketEndpoint = fmt.Sprintf("ws://%s.%s.svc:8080/api/websocket", deploy.CheServiceName, s.deployContext.CheCluster.Namespace) - webSocketEndpointMinor = fmt.Sprintf("ws://%s.%s.svc:8080/api/websocket-minor", deploy.CheServiceName, s.deployContext.CheCluster.Namespace) - } else { - cheInternalAPI = cheAPI - - wsprotocol := "ws" - - if tlsSupport { - wsprotocol = "wss" - } - - webSocketEndpoint = wsprotocol + "://" + cheHost + "/api/websocket" - webSocketEndpointMinor = wsprotocol + "://" + cheHost + "/api/websocket-minor" + webSocketInternalEndpoint = fmt.Sprintf("ws://%s.%s.svc:8080/api/websocket", deploy.CheServiceName, s.deployContext.CheCluster.Namespace) } + wsprotocol := "ws" + if tlsSupport { + wsprotocol = "wss" + } + webSocketEndpoint := wsprotocol + "://" + cheHost + "/api/websocket" + data := &CheConfigMap{ CheMultiUser: cheMultiUser, CheHost: cheHost, @@ -234,7 +220,7 @@ func (s *Server) getCheConfigMapData() (cheEnv map[string]string, err error) { CheApi: cheAPI, CheApiInternal: cheInternalAPI, CheWebSocketEndpoint: webSocketEndpoint, - WebSocketEndpointMinor: webSocketEndpointMinor, + CheWebSocketInternalEndpoint: webSocketInternalEndpoint, CheDebugServer: cheDebug, CheInfrastructureActive: infra, CheInfraKubernetesServiceAccountName: "che-workspace", diff --git a/pkg/deploy/server/server_configmap_test.go b/pkg/deploy/server/server_configmap_test.go index 02796a9f7..17c4a4dcb 100644 --- a/pkg/deploy/server/server_configmap_test.go +++ b/pkg/deploy/server/server_configmap_test.go @@ -147,6 +147,23 @@ func TestConfigMap(t *testing.T) { "CHE_INFRA_KUBERNETES_TLS__KEY": "KEY", }, }, + { + name: "Test k8s data, check public url when internal network enabled.", + cheCluster: &orgv1.CheCluster{ + ObjectMeta: metav1.ObjectMeta{ + Name: "eclipse-che", + Namespace: "eclipse-che", + }, + Spec: orgv1.CheClusterSpec{ + Server: orgv1.CheClusterSpecServer{ + CheHost: "che-host", + }, + }, + }, + expectedData: map[string]string{ + "CHE_WEBSOCKET_ENDPOINT": "ws://che-host/api/websocket", + }, + }, { name: "Test k8s data, with internal cluster svc names", cheCluster: &orgv1.CheCluster{ @@ -161,8 +178,7 @@ func TestConfigMap(t *testing.T) { }, }, expectedData: map[string]string{ - "CHE_WEBSOCKET_ENDPOINT": "ws://che-host.eclipse-che.svc:8080/api/websocket", - "CHE_WEBSOCKET_ENDPOINT__MINOR": "ws://che-host.eclipse-che.svc:8080/api/websocket-minor", + "CHE_WEBSOCKET_INTERNAL_ENDPOINT": "ws://che-host.eclipse-che.svc:8080/api/websocket", }, }, { @@ -180,8 +196,7 @@ func TestConfigMap(t *testing.T) { }, }, expectedData: map[string]string{ - "CHE_WEBSOCKET_ENDPOINT": "ws://che-host/api/websocket", - "CHE_WEBSOCKET_ENDPOINT__MINOR": "ws://che-host/api/websocket-minor", + "CHE_WEBSOCKET_ENDPOINT": "ws://che-host/api/websocket", }, }, { @@ -444,7 +459,7 @@ func TestShouldSetUpCorrectlyDevfileRegistryURL(t *testing.T) { }, }, expectedData: map[string]string{ - "CHE_WORKSPACE_DEVFILE__REGISTRY__INTERNAL__URL": "http://devfile-registry.internal", + "CHE_WORKSPACE_DEVFILE__REGISTRY__INTERNAL__URL": "", "CHE_WORKSPACE_DEVFILE__REGISTRY__URL": "http://devfile-registry.internal", }, }, @@ -473,7 +488,7 @@ func TestShouldSetUpCorrectlyDevfileRegistryURL(t *testing.T) { }, }, { - name: "Test devfile registry urls #5", + name: "Test devfile registry urls #6", cheCluster: &orgv1.CheCluster{ TypeMeta: metav1.TypeMeta{ Kind: "CheCluster", @@ -497,12 +512,12 @@ func TestShouldSetUpCorrectlyDevfileRegistryURL(t *testing.T) { }, }, expectedData: map[string]string{ - "CHE_WORKSPACE_DEVFILE__REGISTRY__INTERNAL__URL": "http://devfile-registry.internal", + "CHE_WORKSPACE_DEVFILE__REGISTRY__INTERNAL__URL": "", "CHE_WORKSPACE_DEVFILE__REGISTRY__URL": "http://devfile-registry.internal http://devfile-registry.external.1 http://devfile-registry.external.2", }, }, { - name: "Test devfile registry urls #6", + name: "Test devfile registry urls #7", cheCluster: &orgv1.CheCluster{ TypeMeta: metav1.TypeMeta{ Kind: "CheCluster", @@ -582,7 +597,7 @@ func TestShouldSetUpCorrectlyInternalPluginRegistryServiceURL(t *testing.T) { }, }, expectedData: map[string]string{ - "CHE_WORKSPACE_PLUGIN__REGISTRY__INTERNAL__URL": "http://external-plugin-registry", + "CHE_WORKSPACE_PLUGIN__REGISTRY__INTERNAL__URL": "", }, }, { @@ -609,7 +624,7 @@ func TestShouldSetUpCorrectlyInternalPluginRegistryServiceURL(t *testing.T) { }, }, expectedData: map[string]string{ - "CHE_WORKSPACE_PLUGIN__REGISTRY__INTERNAL__URL": "http://external-plugin-registry", + "CHE_WORKSPACE_PLUGIN__REGISTRY__INTERNAL__URL": "", }, }, { @@ -636,7 +651,7 @@ func TestShouldSetUpCorrectlyInternalPluginRegistryServiceURL(t *testing.T) { }, }, expectedData: map[string]string{ - "CHE_WORKSPACE_PLUGIN__REGISTRY__INTERNAL__URL": "http://plugin-registry/v3", + "CHE_WORKSPACE_PLUGIN__REGISTRY__INTERNAL__URL": "", }, }, { @@ -696,7 +711,7 @@ func TestShouldSetUpCorrectlyInternalCheServerURL(t *testing.T) { testCases := []testCase{ { - name: "Should use public che-server url, when internal network is disabled", + name: "Should be an empty when internal network is disabled", cheCluster: &orgv1.CheCluster{ TypeMeta: metav1.TypeMeta{ Kind: "CheCluster", @@ -716,7 +731,7 @@ func TestShouldSetUpCorrectlyInternalCheServerURL(t *testing.T) { }, }, expectedData: map[string]string{ - "CHE_API_INTERNAL": "http://che-host/api", + "CHE_API_INTERNAL": "", }, }, { @@ -773,7 +788,7 @@ func TestShouldSetUpCorrectlyInternalIdentityProviderServiceURL(t *testing.T) { testCases := []testCase{ { - name: "Should use 'external' public identity provider url, when internal network is enabled #1", + name: "Should be an empty when enabled 'external' public identity provider url and internal network is enabled #1", cheCluster: &orgv1.CheCluster{ TypeMeta: metav1.TypeMeta{ Kind: "CheCluster", @@ -791,12 +806,12 @@ func TestShouldSetUpCorrectlyInternalIdentityProviderServiceURL(t *testing.T) { }, }, expectedData: map[string]string{ - "CHE_KEYCLOAK_AUTH__INTERNAL__SERVER__URL": "http://external-keycloak/auth", + "CHE_KEYCLOAK_AUTH__INTERNAL__SERVER__URL": "", "CHE_KEYCLOAK_AUTH__SERVER__URL": "http://external-keycloak/auth", }, }, { - name: "Should use 'external' public identity provider url, when internal network is enabled #2", + name: "Should be an empty when enabled 'external' public identity provider url and internal network is enabled #2", cheCluster: &orgv1.CheCluster{ TypeMeta: metav1.TypeMeta{ Kind: "CheCluster", @@ -814,12 +829,12 @@ func TestShouldSetUpCorrectlyInternalIdentityProviderServiceURL(t *testing.T) { }, }, expectedData: map[string]string{ - "CHE_KEYCLOAK_AUTH__INTERNAL__SERVER__URL": "http://external-keycloak/auth", + "CHE_KEYCLOAK_AUTH__INTERNAL__SERVER__URL": "", "CHE_KEYCLOAK_AUTH__SERVER__URL": "http://external-keycloak/auth", }, }, { - name: "Should use 'external' public identity provider url, when internal network is disabled", + name: "Should be and empty when enabled 'external' public identity provider url and internal network is disabled", cheCluster: &orgv1.CheCluster{ TypeMeta: metav1.TypeMeta{ Kind: "CheCluster", @@ -840,12 +855,12 @@ func TestShouldSetUpCorrectlyInternalIdentityProviderServiceURL(t *testing.T) { }, }, expectedData: map[string]string{ - "CHE_KEYCLOAK_AUTH__INTERNAL__SERVER__URL": "http://external-keycloak/auth", + "CHE_KEYCLOAK_AUTH__INTERNAL__SERVER__URL": "", "CHE_KEYCLOAK_AUTH__SERVER__URL": "http://external-keycloak/auth", }, }, { - name: "Should use public identity provider url, when internal network is disabled", + name: "Should be an empty when internal network is disabled", cheCluster: &orgv1.CheCluster{ TypeMeta: metav1.TypeMeta{ Kind: "CheCluster", @@ -866,7 +881,7 @@ func TestShouldSetUpCorrectlyInternalIdentityProviderServiceURL(t *testing.T) { }, }, expectedData: map[string]string{ - "CHE_KEYCLOAK_AUTH__INTERNAL__SERVER__URL": "http://keycloak/auth", + "CHE_KEYCLOAK_AUTH__INTERNAL__SERVER__URL": "", "CHE_KEYCLOAK_AUTH__SERVER__URL": "http://keycloak/auth", }, },