Add lint if compose.yml version is below 3.8 #350

Closed
opened 2022-09-29 15:31:58 +00:00 by Frando · 1 comment
Member

If you write a recipe and put version: 3.7 or anything below 3.8 in the compose.yml, and you also have a config section with template_driver: golang, all abra app commands for that fail with the rather cryptic error message

FATA[0000] configs.config_toml Additional property template_driver is not allowed

The solution is to set version: 3.8 or higher in your compose.yml.

People writing recipes can easily run into that issue when adapting a 3rd party docker-compose.yml file into an abra compose.yml and forget / oversee that it has a lower version number.

Instead of failing with the error message above, abra could tell the user to set the version number to 3.8 instead.

If you write a recipe and put `version: 3.7` or anything below `3.8` in the `compose.yml`, and you also have a config section with `template_driver: golang`, all `abra app` commands for that fail with the rather cryptic error message ``` FATA[0000] configs.config_toml Additional property template_driver is not allowed ``` The solution is to set `version: 3.8` or higher in your `compose.yml`. People writing recipes can easily run into that issue when adapting a 3rd party `docker-compose.yml` file into an abra `compose.yml` and forget / oversee that it has a lower version number. Instead of failing with the error message above, `abra` could tell the user to set the version number to `3.8` instead.
Frando added the
enhancement
abra
labels 2022-09-29 15:31:58 +00:00
Owner

We do have 32de2ee5de/pkg/lint/recipe.go (L31-L38) but I realise that it doesn't even get a chance to run before it hits this error.

Yeh, it'd be great to fix this with a nice error message.

./abra recipe lint gitea -d
DEBU[0000] read map[COMPOSE_FILE:compose.yml:compose.mariadb.yml DOMAIN:gitea.example.com GITEA_ALLOW_ONLY_EXTERNAL_REGISTRATION:true GITEA_APP_NAME:Git with solidaritea GITEA_AUTO_WATCH_NEW_REPOS:false GITEA_DISABLE_GRAVATAR:false GITEA_DISABLE_REGISTRATION:false GITEA_DOMAIN:git.example.com GITEA_ENABLE_FEDERATED_AVATAR:true GITEA_ENABLE_NOTIFY_MAIL:true GITEA_ENABLE_OPENID_SIGNIN:true GITEA_ENABLE_OPENID_SIGNUP:true GITEA_MAILER_FROM:noreply@example.com GITEA_MAILER_USER:noreply@example.com GITEA_SSH_ENABLED:1 GITEA_SSH_PORT:2222 LETS_ENCRYPT_ENV:production SECRET_DB_PASSWORD_VERSION:v1 SECRET_DB_ROOT_PASSWORD_VERSION:v1 SECRET_INTERNAL_TOKEN_VERSION:v1 # length=105 SECRET_JWT_SECRET_VERSION:v1 # length=43 SECRET_SECRET_KEY_VERSION:v1 # length=64 TYPE:gitea] from /home/d/.abra/recipes/gitea/.env.sample caller="/home/d/work/coop-cloud/abra/pkg/config/env.go:51 ReadEnv"
FATA[0000] configs.docker_setup_sh Additional property template_driver is not allowed caller="/home/d/work/coop-cloud/abra/cli/internal/validate.go:37 ValidateRecipe" stack="/home/d/work/coop-cloud/abra/cli/internal/validate.go:37 ValidateRecipe\n/home/d/work/coop-cloud/abra/cli/recipe/lint.go:27 glob..func1\n/home/d/go/pkg/mod/github.com/urfave/cli@v1.22.9/app.go:524 HandleAction\n/home/d/go/pkg/mod/github.com/urfave/cli@v1.22.9/command.go:173 Command.Run\n/home/d/go/pkg/mod/github.com/urfave/cli@v1.22.9/app.go:405 (*App).RunAsSubcommand\n/home/d/go/pkg/mod/github.com/urfave/cli@v1.22.9/command.go:378 Command.startApp\n/home/d/go/pkg/mod/github.com/urfave/cli@v1.22.9/command.go:102 Command.Run\n/home/d/go/pkg/mod/github.com/urfave/cli@v1.22.9/app.go:277 (*App).Run\n/home/d/work/coop-cloud/abra/cli/cli.go:199 RunApp\n/home/d/work/coop-cloud/abra/cmd/abra/main.go:22 main\n/usr/local/go/src/runtime/proc.go:250 main\n/usr/local/go/src/runtime/asm_amd64.s:1571

We do have https://git.coopcloud.tech/coop-cloud/abra/src/commit/32de2ee5def378cca6ca4a92b08662ecc51d65bd/pkg/lint/recipe.go#L31-L38 but I realise that it doesn't even get a chance to run before it hits this error. Yeh, it'd be great to fix this with a nice error message. > ./abra recipe lint gitea -d > DEBU[0000] read map[COMPOSE_FILE:compose.yml:compose.mariadb.yml DOMAIN:gitea.example.com GITEA_ALLOW_ONLY_EXTERNAL_REGISTRATION:true GITEA_APP_NAME:Git with solidaritea GITEA_AUTO_WATCH_NEW_REPOS:false GITEA_DISABLE_GRAVATAR:false GITEA_DISABLE_REGISTRATION:false GITEA_DOMAIN:git.example.com GITEA_ENABLE_FEDERATED_AVATAR:true GITEA_ENABLE_NOTIFY_MAIL:true GITEA_ENABLE_OPENID_SIGNIN:true GITEA_ENABLE_OPENID_SIGNUP:true GITEA_MAILER_FROM:noreply@example.com GITEA_MAILER_USER:noreply@example.com GITEA_SSH_ENABLED:1 GITEA_SSH_PORT:2222 LETS_ENCRYPT_ENV:production SECRET_DB_PASSWORD_VERSION:v1 SECRET_DB_ROOT_PASSWORD_VERSION:v1 SECRET_INTERNAL_TOKEN_VERSION:v1 # length=105 SECRET_JWT_SECRET_VERSION:v1 # length=43 SECRET_SECRET_KEY_VERSION:v1 # length=64 TYPE:gitea] from /home/d/.abra/recipes/gitea/.env.sample caller="/home/d/work/coop-cloud/abra/pkg/config/env.go:51 ReadEnv" > FATA[0000] configs.docker_setup_sh Additional property template_driver is not allowed caller="/home/d/work/coop-cloud/abra/cli/internal/validate.go:37 ValidateRecipe" stack="/home/d/work/coop-cloud/abra/cli/internal/validate.go:37 ValidateRecipe\n/home/d/work/coop-cloud/abra/cli/recipe/lint.go:27 glob..func1\n/home/d/go/pkg/mod/github.com/urfave/cli@v1.22.9/app.go:524 HandleAction\n/home/d/go/pkg/mod/github.com/urfave/cli@v1.22.9/command.go:173 Command.Run\n/home/d/go/pkg/mod/github.com/urfave/cli@v1.22.9/app.go:405 (*App).RunAsSubcommand\n/home/d/go/pkg/mod/github.com/urfave/cli@v1.22.9/command.go:378 Command.startApp\n/home/d/go/pkg/mod/github.com/urfave/cli@v1.22.9/command.go:102 Command.Run\n/home/d/go/pkg/mod/github.com/urfave/cli@v1.22.9/app.go:277 (*App).Run\n/home/d/work/coop-cloud/abra/cli/cli.go:199 RunApp\n/home/d/work/coop-cloud/abra/cmd/abra/main.go:22 main\n/usr/local/go/src/runtime/proc.go:250 main\n/usr/local/go/src/runtime/asm_amd64.s:1571
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: coop-cloud/organising#350
No description provided.