Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pkg/common/constants/constants.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (c) 2019-2023 Red Hat, Inc.
// Copyright (c) 2019-2026 Red Hat, Inc.
// This program and the accompanying materials are made
// available under the terms of the Eclipse Public License 2.0
// which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down Expand Up @@ -42,8 +42,10 @@ const (
DefaultServerCpuLimit = "1"
DefaultServerCpuRequest = "100m"
DefaultServerLogLevel = "INFO"
DefaultServerDebug = false
DefaultServerMetricsPort = int32(8087)
DefaultServerDebugPort = int32(8000)
DefaultServerPort = int32(8080)
DefaultCaBundleCertsCMName = "ca-certs"
DefaultProxyCredentialsSecret = "proxy-credentials"
DefaultGitSelfSignedCertsConfigMapName = "che-git-self-signed-cert"
Expand Down Expand Up @@ -74,6 +76,7 @@ const (
AccessToken = "access_token"
IdToken = "id_token"
OpenShiftOAuthScope = "user:full"
BitbucketOAuth = "bitbucket"

// Labels
KubernetesComponentLabelKey = "app.kubernetes.io/component"
Expand Down
6 changes: 3 additions & 3 deletions pkg/deploy/ingress.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (c) 2019-2023 Red Hat, Inc.
// Copyright (c) 2019-2026 Red Hat, Inc.
// This program and the accompanying materials are made
// available under the terms of the Eclipse Public License 2.0
// which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down Expand Up @@ -53,7 +53,7 @@ func SyncIngressToCluster(
name string,
path string,
serviceName string,
servicePort int,
servicePort int32,
component string) (endpointUrl string, done bool, err error) {

ingressUrl, ingressSpec := GetIngressSpec(deployContext, name, path, serviceName, servicePort, component)
Expand All @@ -68,7 +68,7 @@ func GetIngressSpec(
name string,
path string,
serviceName string,
servicePort int,
servicePort int32,
component string) (ingressUrl string, i *networking.Ingress) {

ingressDomain := deployContext.CheCluster.Spec.Networking.Domain
Expand Down
12 changes: 5 additions & 7 deletions pkg/deploy/proxy.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (c) 2019-2023 Red Hat, Inc.
// Copyright (c) 2019-2026 Red Hat, Inc.
// This program and the accompanying materials are made
// available under the terms of the Eclipse Public License 2.0
// which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down Expand Up @@ -132,7 +132,7 @@ func MergeNonProxy(noProxy1 string, noProxy2 string) string {
}

// GenerateProxyJavaOpts converts given proxy configuration into Java format.
func GenerateProxyJavaOpts(proxy *chetypes.Proxy, noProxy string) (javaOpts string, err error) {
func GenerateProxyJavaOpts(proxy *chetypes.Proxy, noProxy string) (javaOpts string) {
if noProxy == "" {
noProxy = proxy.NoProxy
}
Expand All @@ -153,11 +153,9 @@ func GenerateProxyJavaOpts(proxy *chetypes.Proxy, noProxy string) (javaOpts stri
" -Djdk.http.auth.tunneling.disabledSchemes= -Djdk.http.auth.proxying.disabledSchemes="
}

javaOpts =
" -Dhttp.proxyHost=" + removeProtocolPrefix(proxy.HttpHost) + " -Dhttp.proxyPort=" + proxy.HttpPort +
" -Dhttps.proxyHost=" + removeProtocolPrefix(proxy.HttpsHost) + " -Dhttps.proxyPort=" + proxy.HttpsPort +
" -Dhttp.nonProxyHosts='" + noProxy + "'" + proxyUserPassword
return javaOpts, nil
return " -Dhttp.proxyHost=" + removeProtocolPrefix(proxy.HttpHost) + " -Dhttp.proxyPort=" + proxy.HttpPort +
" -Dhttps.proxyHost=" + removeProtocolPrefix(proxy.HttpsHost) + " -Dhttps.proxyPort=" + proxy.HttpsPort +
" -Dhttp.nonProxyHosts='" + noProxy + "'" + proxyUserPassword
}

func removeProtocolPrefix(url string) string {
Expand Down
8 changes: 4 additions & 4 deletions pkg/deploy/proxy_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (c) 2019-2025 Red Hat, Inc.
// Copyright (c) 2019-2026 Red Hat, Inc.
// This program and the accompanying materials are made
// available under the terms of the Eclipse Public License 2.0
// which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down Expand Up @@ -48,7 +48,7 @@ func TestGenerateProxyJavaOptsWithUsernameAndPassword(t *testing.T) {
logrus.Errorf("Failed to set env %s", err)
}

javaOpts, _ := GenerateProxyJavaOpts(proxy, "")
javaOpts := GenerateProxyJavaOpts(proxy, "")
expectedJavaOpts := " -Dhttp.proxyHost=myproxy.com -Dhttp.proxyPort=1234 -Dhttps.proxyHost=myproxy.com " +
"-Dhttps.proxyPort=1234 -Dhttp.nonProxyHosts='localhost|myhost.com' -Dhttp.proxyUser=user " +
"-Dhttp.proxyPassword=password -Dhttps.proxyUser=user -Dhttps.proxyPassword=password " +
Expand All @@ -71,7 +71,7 @@ func TestGenerateProxyJavaOptsWithoutAuthentication(t *testing.T) {

NoProxy: "localhost,myhost.com",
}
javaOpts, _ := GenerateProxyJavaOpts(proxy, "test-no-proxy.com")
javaOpts := GenerateProxyJavaOpts(proxy, "test-no-proxy.com")
expectedJavaOptsWithoutUsernamePassword := " -Dhttp.proxyHost=myproxy.com -Dhttp.proxyPort=1234 -Dhttps.proxyHost=myproxy.com " +
"-Dhttps.proxyPort=1234 -Dhttp.nonProxyHosts='test-no-proxy.com'"

Expand All @@ -92,7 +92,7 @@ func TestGenerateProxyJavaOptsWildcardInNonProxyHosts(t *testing.T) {

NoProxy: ".example.com,localhost, *.wildcard.domain.com ,myhost.com , .wildcard.net , 127.* ",
}
javaOpts, _ := GenerateProxyJavaOpts(proxy, "")
javaOpts := GenerateProxyJavaOpts(proxy, "")
expectedJavaOptsWithoutUsernamePassword := " -Dhttp.proxyHost=myproxy.com -Dhttp.proxyPort=1234 -Dhttps.proxyHost=myproxy.com " +
"-Dhttps.proxyPort=1234 -Dhttp.nonProxyHosts='*.example.com|localhost|*.wildcard.domain.com|myhost.com|*.wildcard.net|127.*'"

Expand Down
22 changes: 11 additions & 11 deletions pkg/deploy/server/chehost_reconciler.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (c) 2019-2023 Red Hat, Inc.
// Copyright (c) 2019-2026 Red Hat, Inc.
// This program and the accompanying materials are made
// available under the terms of the Eclipse Public License 2.0
// which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down Expand Up @@ -52,7 +52,7 @@ func (s *CheHostReconciler) Finalize(ctx *chetypes.DeployContext) bool {

func (s *CheHostReconciler) syncCheService(ctx *chetypes.DeployContext) (bool, error) {
portName := []string{"http"}
portNumber := []int32{8080}
portNumber := []int32{constants.DefaultServerPort}

if ctx.CheCluster.Spec.Components.Metrics.Enable {
portName = append(portName, "metrics")
Expand All @@ -64,25 +64,25 @@ func (s *CheHostReconciler) syncCheService(ctx *chetypes.DeployContext) (bool, e
portNumber = append(portNumber, constants.DefaultServerDebugPort)
}

spec := deploy.GetServiceSpec(ctx, deploy.CheServiceName, portName, portNumber, getComponentName(ctx))
spec := deploy.GetServiceSpec(ctx, deploy.CheServiceName, portName, portNumber, getComponentName())
return deploy.Sync(ctx, spec, deploy.ServiceDefaultDiffOpts)
}

func (s CheHostReconciler) exposeCheEndpoint(ctx *chetypes.DeployContext) (string, bool, error) {
if !infrastructure.IsOpenShift() {
_, done, err := deploy.SyncIngressToCluster(
ctx,
getComponentName(ctx),
getComponentName(),
"",
gateway.GatewayServiceName,
8080,
getComponentName(ctx))
constants.DefaultServerPort,
getComponentName())
if !done {
return "", false, err
}

ingress := &networking.Ingress{}
exists, err := deploy.GetNamespacedObject(ctx, getComponentName(ctx), ingress)
exists, err := deploy.GetNamespacedObject(ctx, getComponentName(), ingress)
if !exists {
return "", false, err
}
Expand All @@ -92,17 +92,17 @@ func (s CheHostReconciler) exposeCheEndpoint(ctx *chetypes.DeployContext) (strin

done, err := deploy.SyncRouteToCluster(
ctx,
getComponentName(ctx),
getComponentName(),
"/",
gateway.GatewayServiceName,
8080,
getComponentName(ctx))
constants.DefaultServerPort,
getComponentName())
if !done {
return "", false, err
}

route := &routev1.Route{}
exists, err := deploy.GetNamespacedObject(ctx, getComponentName(ctx), route)
exists, err := deploy.GetNamespacedObject(ctx, getComponentName(), route)
if !exists {
return "", false, err
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/deploy/server/chehost_reconciler_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (c) 2019-2025 Red Hat, Inc.
// Copyright (c) 2019-2026 Red Hat, Inc.
// This program and the accompanying materials are made
// available under the terms of the Eclipse Public License 2.0
// which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down Expand Up @@ -87,7 +87,7 @@ func TestConfiguringLabelsForRoutes(t *testing.T) {
assert.Nil(t, err)

route := &routev1.Route{}
err = ctx.ClusterAPI.Client.Get(context.TODO(), types.NamespacedName{Name: getComponentName(ctx), Namespace: "eclipse-che"}, route)
err = ctx.ClusterAPI.Client.Get(context.TODO(), types.NamespacedName{Name: getComponentName(), Namespace: "eclipse-che"}, route)
assert.Nil(t, err)
assert.Equal(t, route.ObjectMeta.Labels["route"], "one")
}
Expand All @@ -98,6 +98,6 @@ func TestCheHostReconciler(t *testing.T) {
cheHostReconciler := NewCheHostReconciler()
test.EnsureReconcile(t, ctx, cheHostReconciler.Reconcile)

assert.True(t, test.IsObjectExists(ctx.ClusterAPI.Client, types.NamespacedName{Name: getComponentName(ctx), Namespace: "eclipse-che"}, &routev1.Route{}))
assert.True(t, test.IsObjectExists(ctx.ClusterAPI.Client, types.NamespacedName{Name: getComponentName(), Namespace: "eclipse-che"}, &routev1.Route{}))
assert.True(t, test.IsObjectExists(ctx.ClusterAPI.Client, types.NamespacedName{Name: deploy.CheServiceName, Namespace: "eclipse-che"}, &corev1.Service{}))
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (c) 2019-2023 Red Hat, Inc.
// Copyright (c) 2019-2026 Red Hat, Inc.
// This program and the accompanying materials are made
// available under the terms of the Eclipse Public License 2.0
// which is available at https://www.eclipse.org/legal/epl-2.0/
Expand All @@ -22,24 +22,28 @@ import (
corev1 "k8s.io/api/core/v1"
)

func getComponentName(ctx *chetypes.DeployContext) string {
func getComponentName() string {
return defaults.GetCheFlavor()
}

func getOAuthConfig(ctx *chetypes.DeployContext, oauthProvider string) (*corev1.Secret, error) {
secrets, err := deploy.GetSecrets(ctx, map[string]string{
constants.KubernetesPartOfLabelKey: constants.CheEclipseOrg,
constants.KubernetesComponentLabelKey: constants.OAuthScmConfiguration,
}, map[string]string{
constants.CheEclipseOrgOAuthScmServer: oauthProvider,
})
func getOAuthConfigSecret(ctx *chetypes.DeployContext, oauthProvider string) (*corev1.Secret, error) {
secrets, err := deploy.GetSecrets(
ctx,
map[string]string{
constants.KubernetesPartOfLabelKey: constants.CheEclipseOrg,
constants.KubernetesComponentLabelKey: constants.OAuthScmConfiguration,
},
map[string]string{
constants.CheEclipseOrgOAuthScmServer: oauthProvider,
},
)

if err != nil {
return nil, err
} else if len(secrets) == 0 {
return nil, nil
} else if len(secrets) > 1 {
return nil, fmt.Errorf("More than 1 OAuth %s configuration secrets found", oauthProvider)
return nil, fmt.Errorf("more than 1 OAuth %s configuration secrets found", oauthProvider)
}

return &secrets[0], nil
Expand Down
Loading