Skip to content

Commit d6897c0

Browse files
authored
Merge pull request #812 from MetaCell/codex/add-environment-variables-to-django-app
Update docs on Codefresh secret transformations
2 parents 1e0d148 + 5d412de commit d6897c0

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

docs/applications/secrets.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,25 @@ Secret editing/maintenance alternatives:
3636
* Using Helm to set/overwrite the secret's value `helm ... --set apps.<appname>.harness.secrets.<secret>=<value>`
3737
* Using kubernetes secret edit `kubectl edit secret <secret>`
3838

39+
## Secrets in Codefresh pipelines
40+
41+
Secrets defined under `harness.secrets` are also exported as deployment variables in the automatically
42+
generated Codefresh pipeline. When the deployment step is assembled, each secret name is transformed
43+
before being referenced in the pipeline:
44+
45+
- Any underscore (`_`) in the secret name is replaced by a double underscore (`__`).
46+
- The resulting string is converted to upper case to form the environment variable name.
47+
48+
For example a secret declared as `db_password` becomes the variable `DB__PASSWORD` in Codefresh and will
49+
appear in the deployment step as:
50+
51+
```
52+
custom_values:
53+
- apps_<appname>_harness_secrets_db__password=${{DB__PASSWORD}}
54+
```
55+
56+
The same underscore replacement is applied to the application name in the `custom_values` entry.
57+
3958
## Secret usage in Python backend apps
4059

4160
The CloudHarness python library (`cloudharness-common`) provides easy access to the CH secrets, just import `get_secrets` from `cloudharness.utils.secrets`.
@@ -47,4 +66,5 @@ secret1_value = get_secret("Secret1")
4766
print(f"Secret1 = {secret1_value}")
4867
```
4968

50-
Hint: make sure the secret's value is read on every use, remember that secrets can be changed "on the fly"
69+
Hint: make sure the secret's value is read on every use, remember that secrets can be changed "on the fly"
70+

0 commit comments

Comments
 (0)