WIP: filter by topic when building catalogue
See coop-cloud/organising#377
This commit is contained in:
parent
14f2d72aba
commit
76f95fe766
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue