Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
Signed-off-by: Anatolii Bazko <[email protected]>
  • Loading branch information
tolusha committed Oct 8, 2024
1 parent eb7cb57 commit dff6d61
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 11 deletions.
4 changes: 4 additions & 0 deletions api/v2/checluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,10 @@ func (c *CheCluster) IsEmbeddedOpenVSXRegistryConfigured() bool {
return defaults.GetPluginRegistryOpenVSXURL() == ""
}

func (c *CheCluster) IsInternalPluginRegistryDisabled() bool {
return c.Spec.Components.PluginRegistry.DisableInternalRegistry || !c.IsEmbeddedOpenVSXRegistryConfigured()
}

// IsCheBeingInstalled returns true if the Che version is not set in the status.
// Basically it means that the Che is being installed since the Che version is set only after the installation.
func (c *CheCluster) IsCheBeingInstalled() bool {
Expand Down
7 changes: 0 additions & 7 deletions pkg/deploy/dashboard/dashboard_deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,6 @@ func TestDashboardDeploymentEnvVars(t *testing.T) {
Name: "CHE_DASHBOARD_INTERNAL_URL",
Value: fmt.Sprintf("http://%s-dashboard.eclipse-che.svc:8080", defaults.GetCheFlavor()),
})
assert.Contains(
t,
deployment.Spec.Template.Spec.Containers[0].Env,
corev1.EnvVar{
Name: "CHE_WORKSPACE_PLUGIN__REGISTRY__INTERNAL__URL",
Value: "http://plugin-registry.eclipse-che.svc:8080/v3",
})
assert.Contains(
t,
deployment.Spec.Template.Spec.Containers[0].Env,
Expand Down
2 changes: 1 addition & 1 deletion pkg/deploy/dashboard/deployment_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (d *DashboardReconciler) getDashboardDeploymentSpec(ctx *chetypes.DeployCon
Value: fmt.Sprintf("http://%s.%s.svc:8080/api", deploy.CheServiceName, ctx.CheCluster.Namespace)},
)

if !ctx.CheCluster.Spec.Components.PluginRegistry.DisableInternalRegistry {
if !ctx.CheCluster.IsInternalPluginRegistryDisabled() {
envVars = append(envVars,
corev1.EnvVar{
Name: "CHE_WORKSPACE_PLUGIN__REGISTRY__INTERNAL__URL",
Expand Down
3 changes: 3 additions & 0 deletions pkg/deploy/gateway/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"strings"
"testing"

"k8s.io/utils/pointer"

"github.com/devfile/devworkspace-operator/pkg/infrastructure"
chev2 "github.com/eclipse-che/che-operator/api/v2"
"github.com/eclipse-che/che-operator/pkg/common/chetypes"
Expand Down Expand Up @@ -170,6 +172,7 @@ func TestOauthProxyConfigUnauthorizedPaths(t *testing.T) {
Components: chev2.CheClusterComponents{
PluginRegistry: chev2.PluginRegistry{
DisableInternalRegistry: false,
OpenVSXURL: pointer.String(""),
},
}},
}, nil)
Expand Down
2 changes: 1 addition & 1 deletion pkg/deploy/gateway/oauth_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ cookie_domains = "%s"

func skipAuthConfig(instance *chev2.CheCluster) string {
var skipAuthPaths []string
if !instance.Spec.Components.PluginRegistry.DisableInternalRegistry {
if !instance.IsInternalPluginRegistryDisabled() {
skipAuthPaths = append(skipAuthPaths, "^/"+constants.PluginRegistryName)
}
skipAuthPaths = append(skipAuthPaths, "^/$")
Expand Down
2 changes: 1 addition & 1 deletion pkg/deploy/pluginregistry/pluginregistry.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func NewPluginRegistryReconciler() *PluginRegistryReconciler {
}

func (p *PluginRegistryReconciler) Reconcile(ctx *chetypes.DeployContext) (reconcile.Result, bool, error) {
if ctx.CheCluster.Spec.Components.PluginRegistry.DisableInternalRegistry || !ctx.CheCluster.IsEmbeddedOpenVSXRegistryConfigured() {
if ctx.CheCluster.IsInternalPluginRegistryDisabled() {
_, _ = deploy.DeleteNamespacedObject(ctx, constants.PluginRegistryName, &corev1.Service{})
_, _ = deploy.DeleteNamespacedObject(ctx, constants.PluginRegistryName, &corev1.ConfigMap{})
_, _ = deploy.DeleteNamespacedObject(ctx, gateway.GatewayConfigMapNamePrefix+constants.PluginRegistryName, &corev1.ConfigMap{})
Expand Down
2 changes: 1 addition & 1 deletion pkg/deploy/server/server_configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func (s *CheServerReconciler) getCheConfigMapData(ctx *chetypes.DeployContext) (
cheAPI := "https://" + ctx.CheHost + "/api"
var pluginRegistryInternalURL string

if !ctx.CheCluster.Spec.Components.PluginRegistry.DisableInternalRegistry {
if !ctx.CheCluster.IsInternalPluginRegistryDisabled() {
pluginRegistryInternalURL = fmt.Sprintf("http://%s.%s.svc:8080/v3", constants.PluginRegistryName, ctx.CheCluster.Namespace)
}

Expand Down
10 changes: 10 additions & 0 deletions pkg/deploy/server/server_configmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ package server
import (
"testing"

"k8s.io/utils/pointer"

"github.com/devfile/devworkspace-operator/pkg/infrastructure"
"github.com/eclipse-che/che-operator/pkg/common/test"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -349,6 +351,14 @@ func TestShouldSetUpCorrectlyPluginRegistryURL(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{
Namespace: "eclipse-che",
},
Spec: chev2.CheClusterSpec{
Components: chev2.CheClusterComponents{
PluginRegistry: chev2.PluginRegistry{
DisableInternalRegistry: false,
OpenVSXURL: pointer.String(""),
},
},
},
Status: chev2.CheClusterStatus{
PluginRegistryURL: "internal-plugin-registry",
},
Expand Down

0 comments on commit dff6d61

Please sign in to comment.