handle missing secrets

Missing secrets will give a blank string instead of exploding.

Also, an example of a custom property
This commit is contained in:
Jonathan Bennett 2019-11-27 11:30:27 -05:00
parent d3dd7498e6
commit 544daf5756

View File

@ -18,11 +18,11 @@ def snake_to_camel(snake_str):
salt = [ord(byte) for byte in os.urandom(64)]
}%
enum Secrets {
% for secret in secrets:
static var ${snake_to_camel(secret)}: String {
let encoded: [UInt8] = [
% for chunk in chunks(encode(os.environ.get(secret), salt), 8):
% for chunk in chunks(encode(os.environ.get(secret) or "", salt), 8):
${"".join(["0x%02x, " % byte for byte in chunk])}
% end
]
@ -31,6 +31,9 @@ enum Secrets {
}
% end
%{
# custom example: static let myVariable = "${os.environ.get('MY_CUSTOM_VARIABLE')}"
}%
}
private extension Secrets {