All checks were successful
continuous-integration/drone/push Build is passing
See #483
44 lines
956 B
Go
44 lines
956 B
Go
package recipe
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"os"
|
|
"path"
|
|
|
|
"coopcloud.tech/abra/pkg/envfile"
|
|
"coopcloud.tech/abra/pkg/formatter"
|
|
"github.com/leonelquinteros/gotext"
|
|
)
|
|
|
|
func (r Recipe) SampleEnv() (map[string]string, error) {
|
|
sampleEnv, err := envfile.ReadEnv(r.SampleEnvPath)
|
|
if err != nil {
|
|
return sampleEnv, errors.New(gotext.Get("unable to discover .env.sample for %s", r.Name))
|
|
}
|
|
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
|
|
}
|
|
|
|
title := formatter.BoldStyle.Render(gotext.Get("%s release notes:", version))
|
|
withTitle := fmt.Sprintf("%s\n%s\n", title, releaseNotes)
|
|
|
|
return withTitle, nil
|
|
}
|
|
|
|
return "", nil
|
|
}
|