refactor(recipe): remove direct usage of config.RECIPE_DIR

This commit is contained in:
2024-07-08 13:38:29 +02:00
parent f14d49cc64
commit 87ecc05962
17 changed files with 82 additions and 117 deletions

View File

@ -2,6 +2,8 @@ package recipe
import (
"fmt"
"os"
"path"
"coopcloud.tech/abra/pkg/envfile"
)
@ -13,3 +15,23 @@ func (r Recipe) SampleEnv() (map[string]string, error) {
}
return sampleEnv, nil
}
// GetReleaseNotes prints release notes for the recipe version
func (r Recipe) GetReleaseNotes(version string) (string, error) {
if version == "" {
return "", nil
}
fpath := path.Join(r.Dir, "release", version)
if _, err := os.Stat(fpath); !os.IsNotExist(err) {
releaseNotes, err := os.ReadFile(fpath)
if err != nil {
return "", err
}
withTitle := fmt.Sprintf("%s release notes:\n%s", version, string(releaseNotes))
return withTitle, nil
}
return "", nil
}