Skip to content

Commit

Permalink
add logic to add in --age parameter on sops commands
Browse files Browse the repository at this point in the history
  • Loading branch information
SayHeyD committed Aug 9, 2023
1 parent c603420 commit b86e6ce
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,28 @@ func executeSops(args []string) {
if wantedEncryptionKey == nil {
log.Printf("Could not find encryption key \"%s\"", appConfig.EncryptionKeyName)
} else {
err = os.Setenv("SOPS_AGE_KEY", wantedEncryptionKey.PrivateKey)
if err != nil {
log.Fatalf("could not set env variable: %v", err)
for index, arg := range args {
if arg == "sops" {
argsUntilSops := make([]string, len(args[:index+1]))
argsAfterSops := make([]string, len(args[index+1:]))

copy(argsUntilSops, args[:index+1])
copy(argsAfterSops, args[index+1:])

firstArgHalf := append(argsUntilSops, "--age", wantedEncryptionKey.PublicKey)
args = append(firstArgHalf, argsAfterSops...)
}
}

}

if wantedDecryptionKey == nil {
log.Printf("Could not find decryption key \"%s\"", appConfig.DecryptionKeyName)
} else {
err = os.Setenv("SOPS_AGE_KEY", wantedDecryptionKey.PrivateKey)
if err != nil {
log.Fatalf("could not set env variable: %v", err)
}
}

var passThroughOut bytes.Buffer
Expand Down

0 comments on commit b86e6ce

Please sign in to comment.