Skip to content

Commit

Permalink
Add only default tags in indexComponent (#193)
Browse files Browse the repository at this point in the history
* Add only default tags in index component (#9)

Signed-off-by: thepetk <[email protected]>

* Update test cases

Signed-off-by: thepetk <[email protected]>

* Fix test cases typo

Signed-off-by: thepetk <[email protected]>

* Fix tags in index_extra.json

Signed-off-by: thepetk <[email protected]>

* Finalize test cases fixes

Signed-off-by: thepetk <[email protected]>

---------

Signed-off-by: thepetk <[email protected]>
  • Loading branch information
thepetk authored Dec 7, 2023
1 parent 7ad160f commit 321dced
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions index/generator/library/library.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion index/generator/tests/registry/index_main.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion index/generator/tests/registry/index_registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 321dced

Please sign in to comment.