fix: ensure catalogue cloned for catalogue reliant commands

This commit is contained in:
2022-01-18 11:19:33 +01:00
parent 88f9796aaf
commit 7733637767
4 changed files with 19 additions and 26 deletions

View File

@ -698,6 +698,10 @@ func recipeCatalogueFSIsLatest() (bool, error) {
func ReadRecipeCatalogue() (RecipeCatalogue, error) {
recipes := make(RecipeCatalogue)
if err := EnsureCatalogue(); err != nil {
return nil, err
}
recipeFSIsLatest, err := recipeCatalogueFSIsLatest()
if err != nil {
return nil, err
@ -1064,3 +1068,18 @@ func StripTagMeta(image string) string {
return image
}
// EnsureCatalogue ensures that the catalogue is cloned locally & present.
func EnsureCatalogue() error {
catalogueDir := path.Join(config.ABRA_DIR, "catalogue")
if _, err := os.Stat(catalogueDir); err != nil && os.IsNotExist(err) {
url := fmt.Sprintf("%s/%s.git", config.REPOS_BASE_URL, "recipes")
if err := gitPkg.Clone(catalogueDir, url); err != nil {
return err
}
logrus.Debugf("cloned catalogue repository to %s", catalogueDir)
}
return nil
}