forked from toolshed/abra
@ -3,6 +3,7 @@ package recipe
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"coopcloud.tech/abra/pkg/formatter"
|
||||
@ -350,23 +351,26 @@ func (r Recipe) Tags() ([]string, error) {
|
||||
}
|
||||
|
||||
// GetRecipeVersions retrieves all recipe versions.
|
||||
func (r Recipe) GetRecipeVersions() (RecipeVersions, error) {
|
||||
func (r Recipe) GetRecipeVersions() (RecipeVersions, []string, error) {
|
||||
var warnMsg []string
|
||||
|
||||
versions := RecipeVersions{}
|
||||
log.Debugf("attempting to open git repository in %s", r.Dir)
|
||||
|
||||
log.Debugf("git: opening repository in %s", r.Dir)
|
||||
|
||||
repo, err := git.PlainOpen(r.Dir)
|
||||
if err != nil {
|
||||
return versions, err
|
||||
return versions, warnMsg, nil
|
||||
}
|
||||
|
||||
worktree, err := repo.Worktree()
|
||||
if err != nil {
|
||||
return versions, err
|
||||
return versions, warnMsg, nil
|
||||
}
|
||||
|
||||
gitTags, err := repo.Tags()
|
||||
if err != nil {
|
||||
return versions, err
|
||||
return versions, warnMsg, nil
|
||||
}
|
||||
|
||||
if err := gitTags.ForEach(func(ref *plumbing.Reference) (err error) {
|
||||
@ -384,7 +388,7 @@ func (r Recipe) GetRecipeVersions() (RecipeVersions, error) {
|
||||
return err
|
||||
}
|
||||
|
||||
log.Debugf("successfully checked out %s in %s", ref.Name(), r.Dir)
|
||||
log.Debugf("git checkout: %s in %s", ref.Name(), r.Dir)
|
||||
|
||||
config, err := r.GetComposeConfig(nil)
|
||||
if err != nil {
|
||||
@ -408,7 +412,7 @@ func (r Recipe) GetRecipeVersions() (RecipeVersions, error) {
|
||||
case reference.NamedTagged:
|
||||
tag = img.(reference.NamedTagged).Tag()
|
||||
case reference.Named:
|
||||
log.Warnf("%s service is missing image tag?", path)
|
||||
warnMsg = append(warnMsg, fmt.Sprintf("%s service is missing image tag?", path))
|
||||
continue
|
||||
}
|
||||
|
||||
@ -422,19 +426,26 @@ func (r Recipe) GetRecipeVersions() (RecipeVersions, error) {
|
||||
|
||||
return nil
|
||||
}); err != nil {
|
||||
return versions, err
|
||||
return versions, warnMsg, nil
|
||||
}
|
||||
|
||||
_, err = gitPkg.CheckoutDefaultBranch(repo, r.Dir)
|
||||
if err != nil {
|
||||
return versions, err
|
||||
return versions, warnMsg, nil
|
||||
}
|
||||
|
||||
sortRecipeVersions(versions)
|
||||
|
||||
log.Debugf("collected %s for %s", versions, r.Dir)
|
||||
|
||||
return versions, nil
|
||||
var uniqueWarnings []string
|
||||
for _, w := range warnMsg {
|
||||
if !slices.Contains(uniqueWarnings, w) {
|
||||
uniqueWarnings = append(uniqueWarnings, w)
|
||||
}
|
||||
}
|
||||
|
||||
return versions, uniqueWarnings, nil
|
||||
}
|
||||
|
||||
// Head retrieves latest HEAD metadata.
|
||||
|
Reference in New Issue
Block a user