Ortus-Solutions / docker-commandbox

Official CommandBox Docker Image for ColdFusion/CFML/Java applications
62 stars 41 forks source link

_FILE Suffix conventions break when env contains multiple underscores #66

Closed mjclemente closed 2 years ago

mjclemente commented 2 years ago

When an env contains multiple underscores, such as AWS_ACCESS_KEY_ID, the _FILE suffix convention breaks.

That is, when I set the environment variable equal to a secret (AWS_ACCESS_KEY_ID_FILE: /run/secrets/aws.access_key_id), the actual environment variable that gets set is just named AWS.

I think this is because of the use of cut here, which appears to be only expecting a single underscore. You can test the syntax used there in the terminal:

export var=AWS_ACCESS_KEY_ID_FILE
echo $var| cut -d'_' -f 1
// AWS

If the script is switched to #!/bin/bash, I think updating that portion of the script to echo ${var%_FILE} should resolve it.

export var=AWS_ACCESS_KEY_ID_FILE
echo ${var%_FILE}
// AWS_ACCESS_KEY_ID

Happy to add a PR for this if acceptable. Cheers!

wphampton commented 2 years ago

Somehow I didn't see this issue when I was searching the past couple of days, and I filed an issue as well #67 and also PR #68

jclausen commented 2 years ago

This should be resolved by PR 68. Let me know if there are any outstanding issues @mjclemente