#3 Remove superfluous lines from filter scripts, switch sops creation rules to apply to all

This commit is contained in:
Joey Hafner 2024-08-23 18:09:27 -07:00
parent bb26fe060e
commit 79af6f5c2d
No known key found for this signature in database
3 changed files with 4 additions and 14 deletions

View File

@ -1,5 +1,5 @@
creation_rules:
- path_regex: secrets.env
- path_regex: .*
shamir_threshold: 2
key_groups:
- age: # Author keys

View File

@ -3,9 +3,6 @@
# Takes encrypted file contents from /dev/stdin
# Outputs to stdout
SOPS_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
REPO_ROOT=$(realpath "$SOPS_DIR/../../")
if [[ -f $HOME/.age/key ]]; then
export SOPS_AGE_KEY_FILE=$HOME/.age/key
else

View File

@ -3,19 +3,12 @@
# Takes file contents from stdin
# Outputs to stdout
# Set up directory variables and default age recipients
SOPS_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
SOPS_AGE_RECIPIENTS="$(<$SOPS_DIR/age-author-pubkeys)"
HOST_AGE_PUBKEY_PATH="$(echo $1 | cut -d'/' -f -2)/.age-pubkey"
if [[ -f "$HOST_AGE_PUBKEY_PATH" ]]; then
SOPS_AGE_RECIPIENTS="$SOPS_AGE_RECIPIENTS,$(<$HOST_AGE_PUBKEY_PATH)"
fi
if [[ -f $HOME/.age/key ]]; then
export SOPS_AGE_KEY_FILE=$HOME/.age/key
else
echo "SOPS_AGE_KEY_FILE not found at $HOME/.age/key"
echo "Cannot encrypt secrets."
exit 1
fi
# Set input/output type
@ -33,7 +26,7 @@ case $FILE_EXT in
esac
if [[ -z ${FILE_TYPE+x} ]]; then
sops --encrypt --age ${SOPS_AGE_RECIPIENTS} /dev/stdin
sops --encrypt --config ../.sops.yaml /dev/stdin
else
sops --encrypt --input-type $FILE_TYPE --output-type $FILE_TYPE --age ${SOPS_AGE_RECIPIENTS} /dev/stdin
sops --encrypt --config ../.sops.yaml --input-type $FILE_TYPE --output-type json /dev/stdin
fi