refactor(recipe): move Tags method to new struct
This commit is contained in:
parent
6f90fc3025
commit
eb62e0ecc3
@ -97,7 +97,7 @@ your SSH keys configured on your account.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tags, err := recipe.Tags()
|
tags, err := r.Tags()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ local file system.
|
|||||||
|
|
||||||
mainAppVersion := imagesTmp[mainApp]
|
mainAppVersion := imagesTmp[mainApp]
|
||||||
|
|
||||||
tags, err := recipe.Tags()
|
tags, err := r.Tags()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -262,3 +262,29 @@ func (r Recipe2) Push(dryRun bool) error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tags list the recipe tags
|
||||||
|
func (r Recipe2) Tags() ([]string, error) {
|
||||||
|
var tags []string
|
||||||
|
|
||||||
|
repo, err := git.PlainOpen(r.Dir)
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugf("detected %s as tags for recipe %s", strings.Join(tags, ", "), r.Name)
|
||||||
|
|
||||||
|
return tags, nil
|
||||||
|
}
|
||||||
|
@ -141,32 +141,6 @@ func (r Recipe) Dir() string {
|
|||||||
return path.Join(config.RECIPES_DIR, r.Name)
|
return path.Join(config.RECIPES_DIR, r.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tags list the recipe tags
|
|
||||||
func (r Recipe) Tags() ([]string, error) {
|
|
||||||
var tags []string
|
|
||||||
|
|
||||||
repo, err := git.PlainOpen(r.Dir())
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Debugf("detected %s as tags for recipe %s", strings.Join(tags, ", "), r.Name)
|
|
||||||
|
|
||||||
return tags, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get retrieves a recipe.
|
// Get retrieves a recipe.
|
||||||
func Get(recipeName string, offline bool) (Recipe, error) {
|
func Get(recipeName string, offline bool) (Recipe, error) {
|
||||||
r := Get2(recipeName)
|
r := Get2(recipeName)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user