Best Naming Style for ConfigMaps and Secrets?
Asked by
CuriousCoder57
I'm working on a Bash script that incorporates environment variables from ConfigMaps and Secrets, and I'm wondering if I should standardize the naming conventions for these variables. Right now, my naming is a bit all over the place. For instance, I have variables from Secrets using camelCase and those from ConfigMaps in UPPER_SNAKE_CASE. Here's how it looks:
```bash
# secret - camelCase
export AWS_ACCESS_KEY_ID="${awsAccessKeyId:-}"
export AWS_SECRET_ACCESS_KEY="${awsSecretAccessKey:-}"
export RESTIC_PASSWORD="${resticPassword:-}"
# configmap - UPPER_SNAKE_CASE
export RESTIC_REPOSITORY="${RESTIC_REPOSITORY:-}"
```
Should I unify these styles for better clarity?
Answers
It's generally a good idea to stick with a consistent naming style across your project. Using uppercase snake case for both Secrets and ConfigMaps can reduce confusion. You can import the environment variables directly from them without extra mapping, which simplifies your deployment configuration too.
Reply to this answer
Honestly, it doesn't matter as long as it works! But if you're looking for clarity and ease of use for others, standardizing makes sense.
Reply to this answer
I also recommend keeping it consistent with UPPER_SNAKE_CASE. It makes everything look uniform, and it's easier for anyone else reading your code to understand. Plus, it looks more professional!
Reply to this answer
I actually have a convention where I only use Secrets for environment variables and keep ConfigMaps for mounted files. It simplifies things a lot for developers, as they often mix them otherwise. I find it easier to manage, especially when you have external secrets involved!
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions