diff --git a/cli/recipe/recipe.go b/cli/recipe/recipe.go index 4bf1d5a43..d59629d9f 100644 --- a/cli/recipe/recipe.go +++ b/cli/recipe/recipe.go @@ -166,22 +166,31 @@ var recipeLintCommand = &cli.Command{ } opts := options.Deploy{Composefiles: composeFiles} - config, err := loader.LoadComposefile(opts) + compose, err := loader.LoadComposefile(opts) if err != nil { logrus.Fatal(err) } expectedVersion := false - if config.Version == "3.8" { + if compose.Version == "3.8" { expectedVersion = true } + envSampleProvided := false + envSample := fmt.Sprintf("%s/%s/.env.sample", config.APPS_DIR, recipe) + if _, err := os.Stat(envSample); !os.IsNotExist(err) { + envSampleProvided = true + } + if err != nil { + logrus.Fatal(err) + } + serviceNamedApp := false traefikEnabled := false healthChecksForAllServices := true allImagesTagged := true noUnstableTags := true - for _, service := range config.Services { + for _, service := range compose.Services { if service.Name == "app" { serviceNamedApp = true } @@ -211,12 +220,10 @@ var recipeLintCommand = &cli.Command{ } } - // TODO - // check for .env.sample - tableCol := []string{"Rule", "Satisfied"} table := formatter.CreateTable(tableCol) table.Append([]string{"Compose files have the expected version", strconv.FormatBool(expectedVersion)}) + table.Append([]string{"Environment configuration is provided", strconv.FormatBool(envSampleProvided)}) table.Append([]string{"Recipe contains a service named 'app'", strconv.FormatBool(serviceNamedApp)}) table.Append([]string{"Traefik routing enabled on at least one service", strconv.FormatBool(traefikEnabled)}) table.Append([]string{"All services have a healthcheck enabled", strconv.FormatBool(healthChecksForAllServices)})