-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhancement: Add information about environment variables in the notif…
…iciations (#702) * enhancement: Add information about environment variables in the notification plugins * enhancement: concise information
- Loading branch information
1 parent
822424a
commit 9b69424
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,22 @@ CrowdSec rejects the plugins binaries if one of the following is true : | |
|
||
It is possible to set configuration values based on environment variables. | ||
|
||
However, depending on which key is using the environment variable, the syntax is different. | ||
|
||
#### Format | ||
|
||
The `format` key is a string that uses the [go template](https://pkg.go.dev/text/template) syntax. To use an environment variable in the `format` key, you can use the `env` function provided by [sprig](https://masterminds.github.io/sprig/). | ||
|
||
```yaml | ||
format: | | ||
Received {{ len . }} alerts | ||
Environment variable value: {{env "ENV_VAR"}} | ||
``` | ||
#### Other keys | ||
All other keys than `format` can use the typical `${ENV_VAR}` or `$ENV_VAR` syntax. | ||
|
||
For example, if you don't want to store your SMTP host password in the configuration file, you can do this: | ||
|
||
```yaml | ||
|
@@ -40,6 +56,21 @@ sender_email: [email protected] | |
email_subject: "CrowdSec Notification" | ||
``` | ||
|
||
:::warning | ||
Please note that `cscli notifications inspect` command does not interpolate environment variables and will always show the raw value of the key. | ||
::: | ||
|
||
If you wish to use `cscli notifications test` command, you must provide the environment variables in the command line or within your shell environment. | ||
|
||
For example, if you have a `SMTP_PASSWORD` environment variable, you can test the `email_default` plugin with the following command: | ||
|
||
:::warning | ||
Some shells may hold this information in history, so please consult your shell documentation to ensure that the password or other sensitive data is not stored in clear text. | ||
::: | ||
|
||
```bash | ||
SMTP_PASSWORD=your_password cscli notifications test email_default | ||
``` | ||
|
||
### Registering plugin to profile | ||
|
||
|