feat: teach recipe sync to understand new versions
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing

Closes coop-cloud/organising#177.
This commit is contained in:
2021-10-05 10:28:09 +02:00
parent a58cea3e0a
commit c616907b71
2 changed files with 81 additions and 28 deletions

View File

@ -41,6 +41,33 @@ func (r Recipe) UpdateTag(image, tag string) error {
return nil
}
// Tags list the recipe tags
func (r Recipe) Tags() ([]string, error) {
var tags []string
recipeDir := path.Join(config.ABRA_DIR, "apps", r.Name)
repo, err := git.PlainOpen(recipeDir)
if err != nil {
return tags, err
}
gitTags, err := repo.Tags()
if err != nil {
return tags, err
}
if err := gitTags.ForEach(func(ref *plumbing.Reference) (err error) {
tags = append(tags, strings.TrimPrefix(string(ref.Name()), "refs/tags/"))
return nil
}); err != nil {
return tags, err
}
logrus.Debugf("detected '%s' as tags for recipe '%s'", strings.Join(tags, ", "), r.Name)
return tags, nil
}
// Get retrieves a recipe.
func Get(recipeName string) (Recipe, error) {
if err := EnsureExists(recipeName); err != nil {