refactor(recipe): move SampleEnv method to new struct

This commit is contained in:
2024-07-08 11:02:43 +02:00
parent f268e5893b
commit 73e9b818b4
3 changed files with 19 additions and 10 deletions

18
pkg/recipe/files.go Normal file
View File

@ -0,0 +1,18 @@
package recipe
import (
"fmt"
"path"
"coopcloud.tech/abra/pkg/config"
"coopcloud.tech/abra/pkg/envfile"
)
func (r Recipe2) SampleEnv() (map[string]string, error) {
envSamplePath := path.Join(config.RECIPES_DIR, r.Name, ".env.sample")
sampleEnv, err := envfile.ReadEnv(envSamplePath)
if err != nil {
return sampleEnv, fmt.Errorf("unable to discover .env.sample for %s", r.Name)
}
return sampleEnv, nil
}