Last active
December 24, 2021 04:15
-
-
Save davidshare/12897d0a64ca9c4c8ed14dcc13ca8b00 to your computer and use it in GitHub Desktop.
A simple bash script that takes a .env file with key and value separated by "=". It base64 encodes the value and produces a key value pair separated by a colon
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
#!/bin/bash | |
input="env_file_path" | |
secret_name="my-secret_name" | |
rm ./deployment_env.yaml ./secret_pair.txt | |
while IFS='=' read -r key value | |
do | |
if [[ ! -z "$key" && ! -z "$value" && "$key" != "#"* ]] | |
then | |
encoded=$(echo -n "$value" | base64 -w0) | |
echo "$key: $encoded" >> secret_pair.txt | |
var_block=" | |
- name: $key | |
valueFrom: | |
secretKeyRef: | |
name: $secret_name | |
key: $key" | |
echo "$var_block">> deployment_env.yaml | |
fi | |
done < "$input" |
New modification to the scripts allows you to define the env blocks for the deployments too.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The format for the .env file should be:
KEY=value