bright-policeman-43626
05/21/2024, 4:13 AMapiVersion: garden.io/v1
kind: Project
name: project
defaultEnvironment: local
dotIgnoreFile: .gitignore
variables:
POSTGRES_USERNAME: postgres
POSTGRES_DATABASE: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_CONNECTION_STRING: postgres://${var.POSTGRES_USERNAME}:${var.POSTGRES_PASSWORD}@postgres-edge-api-cc:5432/${var.POSTGRES_DATABASE}?schema=public
This used to work in Garden 0.12 which was nice because I could build variables on the flight in the project level variables; now I can't because of the following error
garden validate
Validate βοΈ
βΉ garden β Initializing...
βΉ garden-dashboard β You are not logged in. To use the Garden dashboard, log in with the garden login command.
βΉ garden-dashboard β Learn more at: https://docs.garden.io/using-garden/dashboard
Failed to resolve project configuration.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Invalid template string (postgres://${var.POSTGRES_USERNAME}:${var.POSTGRES_PASSWORD}@postgres-edge-api-cc:5432/${var.POSTGRES_DATABASE}?schema=public) at path variables.POSTGRES_CONNECTION_STRING: Could not find key var. Available keys: command, datetime, git, local, project and secrets.
Which is pretty sad; I don't see a reason why this should have been removed? I tested doing the string templating in the environment level and it worked; which is pretty bad for my use case because I would need to repeat variables in N environments where the value is always going to be the same....
Workaround:
Not use variable substitution on the project level but just hardcode the valuess. π’chilly-gigabyte-83853
05/22/2024, 2:28 PMbright-policeman-43626
05/22/2024, 9:12 PMchilly-gigabyte-83853
05/28/2024, 12:50 PMPOSTGRES_USERNAME: postgres
POSTGRES_DATABASE: postgres
POSTGRES_PASSWORD: postgres
on the project.variables
level and POSTGRES_CONNECTION_STRING
as defined above in the action's variable
block.
If the connections parameters change across environments, you could also move the definitions above under environments[].variables
so you can tweak those based on your env.big-spring-14945
05/28/2024, 1:24 PMRunning task test πββοΈ
Invalid template string (postgres://${var.POSTGRES_USERNAMEβ¦): Could not find key var. Available keys: command, datetime, git, local,
project and secrets.
0.12.71-edge-acorn-992156f3d