Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update CHE_WORKSPACE_PLUGIN__REGISTRY__URL based on externalPluginRegistry field #1506

Merged
merged 1 commit into from
Sep 2, 2022
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
7 changes: 7 additions & 0 deletions pkg/deploy/server/server_configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ func (s *CheServerReconciler) getCheConfigMapData(ctx *chetypes.DeployContext) (
devfileRegistryURL = strings.TrimSpace(devfileRegistryURL)

pluginRegistryURL := ctx.CheCluster.Status.PluginRegistryURL
for _, r := range ctx.CheCluster.Spec.Components.PluginRegistry.ExternalPluginRegistries {
if strings.Index(pluginRegistryURL, r.Url) == -1 {
pluginRegistryURL += " " + r.Url
}
}
pluginRegistryURL = strings.TrimSpace(pluginRegistryURL)

cheLogLevel := utils.GetValue(ctx.CheCluster.Spec.Components.CheServer.LogLevel, constants.DefaultServerLogLevel)
cheDebug := "false"
if ctx.CheCluster.Spec.Components.CheServer.Debug != nil {
Expand Down
32 changes: 17 additions & 15 deletions pkg/deploy/server/server_configmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ func TestShouldSetUpCorrectlyDevfileRegistryURL(t *testing.T) {

testCases := []testCase{
{
name: "Test devfile registry urls #1",
name: "Test #1",
cheCluster: &chev2.CheCluster{
ObjectMeta: metav1.ObjectMeta{
Namespace: "eclipse-che",
Expand All @@ -331,19 +331,19 @@ func TestShouldSetUpCorrectlyDevfileRegistryURL(t *testing.T) {
DevfileRegistry: chev2.DevfileRegistry{
DisableInternalRegistry: true,
ExternalDevfileRegistries: []chev2.ExternalDevfileRegistry{
{Url: "http://devfile-registry.external.1"},
{Url: "external-plugin-registry"},
},
},
},
},
},
expectedData: map[string]string{
"CHE_WORKSPACE_DEVFILE__REGISTRY__URL": "http://devfile-registry.external.1",
"CHE_WORKSPACE_DEVFILE__REGISTRY__URL": "external-plugin-registry",
"CHE_WORKSPACE_DEVFILE__REGISTRY__INTERNAL__URL": "",
},
},
{
name: "Test devfile registry urls #2",
name: "Test #2",
cheCluster: &chev2.CheCluster{
ObjectMeta: metav1.ObjectMeta{
Namespace: "eclipse-che",
Expand All @@ -352,17 +352,17 @@ func TestShouldSetUpCorrectlyDevfileRegistryURL(t *testing.T) {
Components: chev2.CheClusterComponents{
DevfileRegistry: chev2.DevfileRegistry{
ExternalDevfileRegistries: []chev2.ExternalDevfileRegistry{
{Url: "http://devfile-registry.external.2"},
{Url: "external-plugin-registry"},
},
},
},
},
Status: chev2.CheClusterStatus{
DevfileRegistryURL: "http://devfile-registry.internal.1",
DevfileRegistryURL: "internal-plugin-registry",
},
},
expectedData: map[string]string{
"CHE_WORKSPACE_DEVFILE__REGISTRY__URL": "http://devfile-registry.internal.1 http://devfile-registry.external.2",
"CHE_WORKSPACE_DEVFILE__REGISTRY__URL": "internal-plugin-registry external-plugin-registry",
"CHE_WORKSPACE_DEVFILE__REGISTRY__INTERNAL__URL": "http://devfile-registry.eclipse-che.svc:8080",
},
},
Expand All @@ -373,12 +373,12 @@ func TestShouldSetUpCorrectlyDevfileRegistryURL(t *testing.T) {
Namespace: "eclipse-che",
},
Status: chev2.CheClusterStatus{
DevfileRegistryURL: "http://devfile-registry.internal",
DevfileRegistryURL: "internal-plugin-registry",
},
},
expectedData: map[string]string{
"CHE_WORKSPACE_DEVFILE__REGISTRY__INTERNAL__URL": "http://devfile-registry.eclipse-che.svc:8080",
"CHE_WORKSPACE_DEVFILE__REGISTRY__URL": "http://devfile-registry.internal",
"CHE_WORKSPACE_DEVFILE__REGISTRY__URL": "internal-plugin-registry",
},
},
}
Expand All @@ -395,7 +395,7 @@ func TestShouldSetUpCorrectlyDevfileRegistryURL(t *testing.T) {
}
}

func TestShouldSetUpCorrectlyInternalPluginRegistryServiceURL(t *testing.T) {
func TestShouldSetUpCorrectlyPluginRegistryURL(t *testing.T) {
type testCase struct {
name string
initObjects []runtime.Object
Expand All @@ -405,7 +405,7 @@ func TestShouldSetUpCorrectlyInternalPluginRegistryServiceURL(t *testing.T) {

testCases := []testCase{
{
name: "Test CHE_WORKSPACE_PLUGIN__REGISTRY__INTERNAL__URL #1",
name: "Test #1",
cheCluster: &chev2.CheCluster{
ObjectMeta: metav1.ObjectMeta{
Namespace: "eclipse-che",
Expand All @@ -414,15 +414,16 @@ func TestShouldSetUpCorrectlyInternalPluginRegistryServiceURL(t *testing.T) {
Components: chev2.CheClusterComponents{
PluginRegistry: chev2.PluginRegistry{
DisableInternalRegistry: true,
ExternalPluginRegistries: []chev2.ExternalPluginRegistry{
{Url: "external-plugin-registry"},
},
},
},
},
Status: chev2.CheClusterStatus{
PluginRegistryURL: "http://external-plugin-registry",
},
},
expectedData: map[string]string{
"CHE_WORKSPACE_PLUGIN__REGISTRY__INTERNAL__URL": "",
"CHE_WORKSPACE_PLUGIN__REGISTRY__URL": "external-plugin-registry",
},
},
{
Expand All @@ -432,11 +433,12 @@ func TestShouldSetUpCorrectlyInternalPluginRegistryServiceURL(t *testing.T) {
Namespace: "eclipse-che",
},
Status: chev2.CheClusterStatus{
PluginRegistryURL: "http://external-plugin-registry",
PluginRegistryURL: "internal-plugin-registry",
},
},
expectedData: map[string]string{
"CHE_WORKSPACE_PLUGIN__REGISTRY__INTERNAL__URL": "http://plugin-registry.eclipse-che.svc:8080/v3",
"CHE_WORKSPACE_PLUGIN__REGISTRY__URL": "internal-plugin-registry",
},
},
}
Expand Down