diff --git a/cli/catalogue/catalogue.go b/cli/catalogue/catalogue.go index 9a54342c..b7d09ccc 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/catalogue/catalogue.go b/pkg/catalogue/catalogue.go index e65a8aa1..80e54885 100644 --- a/pkg/catalogue/catalogue.go +++ b/pkg/catalogue/catalogue.go @@ -12,46 +12,6 @@ import ( "github.com/sirupsen/logrus" ) -// CatalogueSkipList is all the repos that are not recipes. -var CatalogueSkipList = map[string]bool{ - "abra": true, - "abra-apps": true, - "abra-aur": true, - "abra-bash": true, - "abra-capsul": true, - "abra-gandi": true, - "abra-hetzner": true, - "abra-test-recipe": true, - "apps": true, - "aur-abra-git": true, - "auto-mirror": true, - "auto-recipes-catalogue-json": true, - "backup-bot": true, - "backup-bot-two": true, - "beta.coopcloud.tech": true, - "comrade-renovate-bot": true, - "coopcloud.tech": true, - "coturn": true, - "docker-cp-deploy": true, - "docker-dind-bats-kcov": true, - "docs.coopcloud.tech": true, - "drone-abra": true, - "example": true, - "gardening": true, - "go-abra": true, - "organising": true, - "pyabra": true, - "radicle-seed-node": true, - "recipes-catalogue-json": true, - "recipes-wishlist": true, - "recipes.coopcloud.tech": true, - "stack-ssh-deploy": true, - "swarm-cronjob": true, - "tagcmp": true, - "traefik-cert-dumper": true, - "tyop": true, -} - // EnsureCatalogue ensures that the catalogue is cloned locally & present. func EnsureCatalogue() error { catalogueDir := path.Join(config.ABRA_DIR, "catalogue") diff --git a/pkg/recipe/recipe.go b/pkg/recipe/recipe.go index 9ddf7d02..6e47e029 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,16 @@ 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 + } + + if slices.Contains(topicMeta.Topics, "recipe") && repo.Name != "example" { + reposMeta[repo.Name] = reposList[idx] + } } pageIdx++ @@ -1002,14 +1017,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 +1034,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) +}