From 321dcedc6b1c8e1c7c03ac376bbacf463d4481ca Mon Sep 17 00:00:00 2001 From: Theofanis Petkos Date: Thu, 7 Dec 2023 15:00:09 +0000 Subject: [PATCH] Add only default tags in indexComponent (#193) * Add only default tags in index component (#9) Signed-off-by: thepetk * Update test cases Signed-off-by: thepetk * Fix test cases typo Signed-off-by: thepetk * Fix tags in index_extra.json Signed-off-by: thepetk * Finalize test cases fixes Signed-off-by: thepetk --------- Signed-off-by: thepetk --- index/generator/library/library.go | 11 ++++++----- index/generator/tests/registry/index_main.json | 2 +- index/generator/tests/registry/index_registry.json | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/index/generator/library/library.go b/index/generator/library/library.go index a629d3aca..b77983276 100644 --- a/index/generator/library/library.go +++ b/index/generator/library/library.go @@ -295,12 +295,11 @@ func parseDevfileRegistry(registryDirPath string, force bool) ([]schema.Schema, } } } else { // if stack.yaml not exist, old stack repo struct, directly lookfor & parse devfile.yaml - versionComponent := schema.Version{} + versionComponent := schema.Version{Default: true} err := parseStackDevfile(stackFolderPath, stackFolderDir.Name(), force, &versionComponent, &indexComponent) if err != nil { return nil, err } - versionComponent.Default = true indexComponent.Versions = append(indexComponent.Versions, versionComponent) } indexComponent.Type = schema.StackDevfileType @@ -441,9 +440,11 @@ func parseStackDevfile(devfileDirPath string, stackName string, force bool, vers versionComponent.StarterProjects = append(versionComponent.StarterProjects, starterProject.Name) } - for _, tag := range versionComponent.Tags { - if !inArray(indexComponent.Tags, tag) { - indexComponent.Tags = append(indexComponent.Tags, tag) + if versionComponent.Default { + for _, tag := range versionComponent.Tags { + if !inArray(indexComponent.Tags, tag) { + indexComponent.Tags = append(indexComponent.Tags, tag) + } } } diff --git a/index/generator/tests/registry/index_main.json b/index/generator/tests/registry/index_main.json index 1c7db1634..53cfb7bc9 100644 --- a/index/generator/tests/registry/index_main.json +++ b/index/generator/tests/registry/index_main.json @@ -4,7 +4,7 @@ "displayName": "Go Runtime", "description": "Stack with the latest Go version", "type": "stack", - "tags": ["testtag", "Go"], + "tags": ["Go"], "icon": "https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/golang.svg", "projectType": "go", "language": "go", diff --git a/index/generator/tests/registry/index_registry.json b/index/generator/tests/registry/index_registry.json index d28046533..802f6b9a7 100644 --- a/index/generator/tests/registry/index_registry.json +++ b/index/generator/tests/registry/index_registry.json @@ -4,7 +4,7 @@ "displayName": "Go Runtime", "description": "Stack with the latest Go version", "type": "stack", - "tags": ["testtag", "Go"], + "tags": ["Go"], "icon": "https://raw.githubusercontent.com/devfile-samples/devfile-stack-icons/main/golang.svg", "projectType": "go", "language": "go",