refactor(recipe): use method or variable for .env.sample

This commit is contained in:
2024-07-08 11:26:01 +02:00
parent 2f41b6d8b4
commit c861c09cce
11 changed files with 47 additions and 85 deletions

View File

@ -7,7 +7,6 @@ import (
"path"
"coopcloud.tech/abra/pkg/config"
"coopcloud.tech/abra/pkg/envfile"
"coopcloud.tech/abra/pkg/log"
"coopcloud.tech/abra/pkg/recipe"
recipePkg "coopcloud.tech/abra/pkg/recipe"
@ -210,9 +209,9 @@ func LintComposeVersion(recipe recipe.Recipe) (bool, error) {
return true, nil
}
func LintEnvConfigPresent(recipe recipe.Recipe) (bool, error) {
envSample := fmt.Sprintf("%s/%s/.env.sample", config.RECIPES_DIR, recipe.Name)
if _, err := os.Stat(envSample); !os.IsNotExist(err) {
func LintEnvConfigPresent(r recipe.Recipe) (bool, error) {
r2 := recipe.Get2(r.Name)
if _, err := os.Stat(r2.SampleEnvPath); !os.IsNotExist(err) {
return true, nil
}
@ -233,11 +232,11 @@ func LintAppService(recipe recipe.Recipe) (bool, error) {
// confirms that there is no "DOMAIN=..." in the .env.sample configuration of
// the recipe. This typically means that no domain is required to deploy and
// therefore no matching traefik deploy label will be present.
func LintTraefikEnabledSkipCondition(recipe recipe.Recipe) (bool, error) {
envSamplePath := path.Join(config.RECIPES_DIR, recipe.Name, ".env.sample")
sampleEnv, err := envfile.ReadEnv(envSamplePath)
func LintTraefikEnabledSkipCondition(r recipe.Recipe) (bool, error) {
r2 := recipe.Get2(r.Name)
sampleEnv, err := r2.SampleEnv()
if err != nil {
return false, fmt.Errorf("Unable to discover .env.sample for %s", recipe.Name)
return false, fmt.Errorf("Unable to discover .env.sample for %s", r2.Name)
}
if _, ok := sampleEnv["DOMAIN"]; !ok {