fresh-yak-35965
07/18/2024, 11:14 PMvar.sshkey is not set. How?microscopic-river-74022
07/18/2024, 11:14 PMmicroscopic-river-74022
07/18/2024, 11:14 PMdisabled configuration key to true. You can use conditional template strings to enable or disable services based on certain conditions. In your case, you want to disable a service if var.sshkey is not set. You can achieve this by using a conditional template string like so:
yaml
services:
- name: my-service
disabled: ${var.sshkey == undefined}
In this example, my-service will be disabled if var.sshkey is not set.
Please note that disabling a service means that it will not be deployed, and will also be ignored if it is declared as a runtime dependency for another service, test or task. Also, template strings referencing the service's outputs will fail to resolve when the service is disabled, so you need to make sure to provide alternate values for those if you're using them, using conditional expressions.
For more information, you can refer to the Garden documentation on exec services (), container services (), and jib-container services ().
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------microscopic-river-74022
07/18/2024, 11:14 PMfresh-yak-35965
07/18/2024, 11:27 PMInvalid template string (${var.sshkey == undefined || var.cluster == undefined}?) at path disabled: Could not find key sshkey under var. Available keys: apphost, baseHostName and mode. Could not find key undefined. Available keys: command, datetime, environment, git, inputs, local, parent, project, secrets, template, this, var and variables.microscopic-river-74022
07/18/2024, 11:27 PMmicroscopic-river-74022
07/18/2024, 11:28 PMsshkey is not found under var. This means that sshkey is not defined in your Garden configuration.
In Garden, variables are defined in the variables field in your project configuration or in a varfile. If sshkey is not defined, you will get an error when you try to reference it.
To fix this, you need to ensure that sshkey is defined in your Garden configuration. Here is an example of how to define variables in your project configuration:
yaml
kind: Project
name: my-project
variables:
sshkey: your-ssh-key
In this example, sshkey is defined and set to your-ssh-key. You can replace your-ssh-key with your actual SSH key.
Once sshkey is defined, you should be able to use it in your conditional template string.
However, please note that Garden does not currently support checking if a variable is undefined directly in the template string. You might need to ensure that all variables are defined, possibly with a default value, before using them in a template string.
For more information, you can refer to the Garden documentation on variables ().
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------microscopic-river-74022
07/18/2024, 11:28 PMfresh-yak-35965
07/18/2024, 11:31 PM--var in the garden command?microscopic-river-74022
07/18/2024, 11:31 PMmicroscopic-river-74022
07/18/2024, 11:32 PM--var flag in the Garden command.
You can define default values for your variables in the variables field in your project configuration. Here is an example:
yaml
kind: Project
name: my-project
variables:
my-variable: default-value
In this example, my-variable is set to default-value by default.
You can then override this default value by using the --var flag in the Garden command. Here is an example:
bash
garden run my-task --var my-variable=custom-value
In this example, my-variable is set to custom-value, overriding the default value.
Please note that variables set with --var CLI flags have the highest precedence, meaning they will override any values set in your project configuration or in a varfile.
For more information, you can refer to the Garden documentation on variables () and CLI commands ().
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------microscopic-river-74022
07/18/2024, 11:32 PM