fix: error out if missing "deploy.labels"

See toolshed/organising#643
This commit is contained in:
decentral1se 2024-12-28 21:55:02 +01:00
parent 03000c25e0
commit 8ac31330be
Signed by: decentral1se
GPG Key ID: 03789458B3D0C410

View File

@ -137,6 +137,13 @@ var LintRules = map[string][]LintRule{
HowToResolve: "name a servce 'app'",
Function: LintAppService,
},
{
Ref: "R015",
Level: "error",
Description: "deploy labels stanza present",
HowToResolve: "include \"deploy: labels: ...\" stanza",
Function: LintDeployLabelsPresent,
},
{
Ref: "R010",
Level: "error",
@ -269,6 +276,21 @@ func LintTraefikEnabled(recipe recipe.Recipe) (bool, error) {
return false, nil
}
func LintDeployLabelsPresent(recipe recipe.Recipe) (bool, error) {
config, err := recipe.GetComposeConfig(nil)
if err != nil {
return false, err
}
for _, service := range config.Services {
if service.Name == "app" && service.Deploy.Labels != nil {
return true, nil
}
}
return false, nil
}
func LintHealthchecks(recipe recipe.Recipe) (bool, error) {
config, err := recipe.GetComposeConfig(nil)
if err != nil {