feat: finalise recipe lint command
This commit is contained in:
parent
327e2afcd0
commit
efb9d6f6a5
|
@ -166,22 +166,31 @@ var recipeLintCommand = &cli.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
opts := options.Deploy{Composefiles: composeFiles}
|
opts := options.Deploy{Composefiles: composeFiles}
|
||||||
config, err := loader.LoadComposefile(opts)
|
compose, err := loader.LoadComposefile(opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
expectedVersion := false
|
expectedVersion := false
|
||||||
if config.Version == "3.8" {
|
if compose.Version == "3.8" {
|
||||||
expectedVersion = true
|
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
|
serviceNamedApp := false
|
||||||
traefikEnabled := false
|
traefikEnabled := false
|
||||||
healthChecksForAllServices := true
|
healthChecksForAllServices := true
|
||||||
allImagesTagged := true
|
allImagesTagged := true
|
||||||
noUnstableTags := true
|
noUnstableTags := true
|
||||||
for _, service := range config.Services {
|
for _, service := range compose.Services {
|
||||||
if service.Name == "app" {
|
if service.Name == "app" {
|
||||||
serviceNamedApp = true
|
serviceNamedApp = true
|
||||||
}
|
}
|
||||||
|
@ -211,12 +220,10 @@ var recipeLintCommand = &cli.Command{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
|
||||||
// check for .env.sample
|
|
||||||
|
|
||||||
tableCol := []string{"Rule", "Satisfied"}
|
tableCol := []string{"Rule", "Satisfied"}
|
||||||
table := formatter.CreateTable(tableCol)
|
table := formatter.CreateTable(tableCol)
|
||||||
table.Append([]string{"Compose files have the expected version", strconv.FormatBool(expectedVersion)})
|
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{"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{"Traefik routing enabled on at least one service", strconv.FormatBool(traefikEnabled)})
|
||||||
table.Append([]string{"All services have a healthcheck enabled", strconv.FormatBool(healthChecksForAllServices)})
|
table.Append([]string{"All services have a healthcheck enabled", strconv.FormatBool(healthChecksForAllServices)})
|
||||||
|
|
Loading…
Reference in New Issue