refactor(recipe): move SampleEnv method to new struct
This commit is contained in:
parent
f268e5893b
commit
73e9b818b4
@ -132,7 +132,7 @@ var appNewCommand = cli.Command{
|
|||||||
var secrets AppSecrets
|
var secrets AppSecrets
|
||||||
var secretTable *jsontable.JSONTable
|
var secretTable *jsontable.JSONTable
|
||||||
if internal.Secrets {
|
if internal.Secrets {
|
||||||
sampleEnv, err := recipe.SampleEnv()
|
sampleEnv, err := r.SampleEnv()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
18
pkg/recipe/files.go
Normal file
18
pkg/recipe/files.go
Normal 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
|
||||||
|
}
|
@ -238,15 +238,6 @@ func Get(recipeName string, offline bool) (Recipe, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r Recipe) 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
|
|
||||||
}
|
|
||||||
|
|
||||||
func Get2(name string) Recipe2 {
|
func Get2(name string) Recipe2 {
|
||||||
return Recipe2{
|
return Recipe2{
|
||||||
Name: name,
|
Name: name,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user