refactor: filter by topic when building catalogue
See coop-cloud/organising#377
This commit is contained in:
parent
7f7f7224c6
commit
6a673ef101
|
@ -98,11 +98,6 @@ keys configured on your account.
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, exists := catalogue.CatalogueSkipList[recipeMeta.Name]; exists {
|
|
||||||
catlBar.Add(1)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
versions, err := recipe.GetRecipeVersions(recipeMeta.Name, internal.Offline)
|
versions, err := recipe.GetRecipeVersions(recipeMeta.Name, internal.Offline)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Warn(err)
|
logrus.Warn(err)
|
||||||
|
|
|
@ -12,46 +12,6 @@ import (
|
||||||
"github.com/sirupsen/logrus"
|
"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.
|
// EnsureCatalogue ensures that the catalogue is cloned locally & present.
|
||||||
func EnsureCatalogue() error {
|
func EnsureCatalogue() error {
|
||||||
catalogueDir := path.Join(config.ABRA_DIR, "catalogue")
|
catalogueDir := path.Join(config.ABRA_DIR, "catalogue")
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"slices"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -31,7 +32,7 @@ import (
|
||||||
// RecipeCatalogueURL is the only current recipe catalogue available.
|
// RecipeCatalogueURL is the only current recipe catalogue available.
|
||||||
const RecipeCatalogueURL = "https://recipes.coopcloud.tech/recipes.json"
|
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"
|
const ReposMetadataURL = "https://git.coopcloud.tech/api/v1/orgs/coop-cloud/repos"
|
||||||
|
|
||||||
// tag represents a git tag.
|
// tag represents a git tag.
|
||||||
|
@ -63,6 +64,11 @@ type RecipeMeta struct {
|
||||||
Website string `json:"website"`
|
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.
|
// LatestVersion returns the latest version of a recipe.
|
||||||
func (r RecipeMeta) LatestVersion() string {
|
func (r RecipeMeta) LatestVersion() string {
|
||||||
var version string
|
var version string
|
||||||
|
@ -822,8 +828,17 @@ func ReadReposMetadata() (RepoCatalogue, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for idx, repo := range reposList {
|
for idx, repo := range reposList {
|
||||||
|
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]
|
reposMeta[repo.Name] = reposList[idx]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pageIdx++
|
pageIdx++
|
||||||
bar.Add(1)
|
bar.Add(1)
|
||||||
|
@ -1002,14 +1017,8 @@ func UpdateRepositories(repos RepoCatalogue, recipeName string) error {
|
||||||
retrieveBar.Add(1)
|
retrieveBar.Add(1)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if _, exists := catalogue.CatalogueSkipList[rm.Name]; exists {
|
|
||||||
ch <- rm.Name
|
|
||||||
retrieveBar.Add(1)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
recipeDir := path.Join(config.RECIPES_DIR, rm.Name)
|
recipeDir := path.Join(config.RECIPES_DIR, rm.Name)
|
||||||
|
|
||||||
if err := gitPkg.Clone(recipeDir, rm.CloneURL); err != nil {
|
if err := gitPkg.Clone(recipeDir, rm.CloneURL); err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -1025,3 +1034,8 @@ func UpdateRepositories(repos RepoCatalogue, recipeName string) error {
|
||||||
|
|
||||||
return nil
|
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)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue