Skip to content

Commit

Permalink
fix: Update based on field (#1506)
Browse files Browse the repository at this point in the history
Signed-off-by: Anatolii Bazko <abazko@redhat.com>

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
  • Loading branch information
tolusha authored Sep 2, 2022
1 parent e09b27e commit c67e776
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
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

0 comments on commit c67e776

Please sign in to comment.