diff --git a/cli/catalogue/catalogue.go b/cli/catalogue/catalogue.go index 7c97372f..0735eed2 100644 --- a/cli/catalogue/catalogue.go +++ b/cli/catalogue/catalogue.go @@ -98,11 +98,6 @@ keys configured on your account. continue } - if _, exists := catalogue.CatalogueSkipList[recipeMeta.Name]; exists { - catlBar.Add(1) - continue - } - versions, err := recipe.GetRecipeVersions(recipeMeta.Name, internal.Offline) if err != nil { logrus.Warn(err) diff --git a/pkg/recipe/recipe.go b/pkg/recipe/recipe.go index 622d24c7..05fb21b2 100644 --- a/pkg/recipe/recipe.go +++ b/pkg/recipe/recipe.go @@ -7,6 +7,7 @@ import ( "os" "path" "path/filepath" + "slices" "sort" "strconv" "strings" @@ -31,7 +32,7 @@ import ( // RecipeCatalogueURL is the only current recipe catalogue available. const RecipeCatalogueURL = "https://recipes.coopcloud.tech/recipes.json" -// ReposMetadataURL is the recipe repository metadata +// ReposMetadataURL is the recipe repository metadata. const ReposMetadataURL = "https://git.coopcloud.tech/api/v1/orgs/coop-cloud/repos" // tag represents a git tag. @@ -63,6 +64,11 @@ type RecipeMeta struct { Website string `json:"website"` } +// TopicMeta represents a list of topics for a repository. +type TopicMeta struct { + Topics []string `json:"topics"` +} + // LatestVersion returns the latest version of a recipe. func (r RecipeMeta) LatestVersion() string { var version string @@ -822,7 +828,18 @@ func ReadReposMetadata() (RepoCatalogue, error) { } for idx, repo := range reposList { - reposMeta[repo.Name] = reposList[idx] + var topicMeta TopicMeta + + topicsURL := getReposTopicUrl(repo.Name) + if err := web.ReadJSON(topicsURL, &topicMeta); err != nil { + return reposMeta, err + } + + fmt.Println(topicMeta) + + if slices.Contains(topicMeta.Topics, "recipe") && repo.Name != "example" { + reposMeta[repo.Name] = reposList[idx] + } } pageIdx++ @@ -1002,14 +1019,8 @@ func UpdateRepositories(repos RepoCatalogue, recipeName string) error { retrieveBar.Add(1) return } - if _, exists := catalogue.CatalogueSkipList[rm.Name]; exists { - ch <- rm.Name - retrieveBar.Add(1) - return - } recipeDir := path.Join(config.RECIPES_DIR, rm.Name) - if err := gitPkg.Clone(recipeDir, rm.CloneURL); err != nil { logrus.Fatal(err) } @@ -1025,3 +1036,8 @@ func UpdateRepositories(repos RepoCatalogue, recipeName string) error { return nil } + +// getReposTopicUrl retrieves the repository specific topic listing. +func getReposTopicUrl(repoName string) string { + return fmt.Sprintf("https://git.coopcloud.tech/api/v1/repos/coop-cloud/%s/topics", repoName) +}