feat: finalise recipe lint command

This commit is contained in:
decentral1se 2021-08-04 00:07:23 +02:00
parent 327e2afcd0
commit efb9d6f6a5
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
1 changed files with 13 additions and 6 deletions

View File

@ -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)})