forked from toolshed/abra
WIP: use repo metadata not existing catalogue
This commit is contained in:
@ -4,7 +4,6 @@ import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"coopcloud.tech/abra/pkg/catalogue"
|
||||
"coopcloud.tech/abra/pkg/config"
|
||||
@ -50,53 +49,47 @@ var catalogueGenerateCommand = &cli.Command{
|
||||
ArgsUsage: "[<recipe>]",
|
||||
BashComplete: func(c *cli.Context) {},
|
||||
Action: func(c *cli.Context) error {
|
||||
recipes, err := catalogue.ReadRecipeCatalogue()
|
||||
recipeName := c.Args().First()
|
||||
|
||||
repos, err := catalogue.ReadReposMetadata()
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
recipeName := c.Args().First()
|
||||
if recipeName != "" {
|
||||
recipeMeta, exists := recipes[recipeName]
|
||||
if !exists {
|
||||
logrus.Fatalf("'%s' does not exist?", recipeName)
|
||||
}
|
||||
recipes = map[string]catalogue.RecipeMeta{recipeName: recipeMeta}
|
||||
}
|
||||
logrus.Debugf("ensuring '%v' recipe(s) are locally present and up-to-date", len(repos))
|
||||
|
||||
logrus.Debugf("ensuring '%v' recipe(s) are locally present and up-to-date", len(recipes))
|
||||
|
||||
ch := make(chan string, len(recipes))
|
||||
for recipeName, recipeMeta := range recipes {
|
||||
go func(rn string, rm catalogue.RecipeMeta) {
|
||||
if _, exists := CatalogueSkipList[rn]; exists {
|
||||
ch <- rn
|
||||
ch := make(chan string, len(repos))
|
||||
for _, repoMeta := range repos {
|
||||
go func(rm catalogue.RepoMeta) {
|
||||
if recipeName != "" && recipeName != rm.Name {
|
||||
ch <- rm.Name
|
||||
return
|
||||
}
|
||||
if rm.Repository == "" {
|
||||
logrus.Warnf("'%s' has no git clone URL, skipping", rn)
|
||||
ch <- rn
|
||||
if _, exists := CatalogueSkipList[rm.Name]; exists {
|
||||
ch <- rm.Name
|
||||
return
|
||||
}
|
||||
|
||||
recipeDir := path.Join(config.ABRA_DIR, "apps", strings.ToLower(rn))
|
||||
if err := git.Clone(recipeDir, rm.Repository); err != nil {
|
||||
recipeDir := path.Join(config.ABRA_DIR, "apps", rm.Name)
|
||||
|
||||
if err := git.Clone(recipeDir, rm.SSHURL); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
if err := git.EnsureUpToDate(recipeDir); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
ch <- rn
|
||||
}(recipeName, recipeMeta)
|
||||
|
||||
ch <- rm.Name
|
||||
}(repoMeta)
|
||||
}
|
||||
|
||||
for range recipes {
|
||||
for range repos {
|
||||
<-ch // wait for everything
|
||||
}
|
||||
|
||||
catl := make(catalogue.RecipeCatalogue)
|
||||
for recipeName := range recipes {
|
||||
for recipeName := range repos {
|
||||
// TODO: gather more metadata
|
||||
catl[recipeName] = catalogue.RecipeMeta{
|
||||
Name: recipeName,
|
||||
|
Reference in New Issue
Block a user