Cache secrets and concurrent decryption (#790)

Related to #782 and #444 

- Allows concurrent decryption of different secrets files
- Caches decrypted secrets by original file path and returns decrypted results from memory
- Secrets being run through an instance of helmexec will be cached and run as fast as possible concurrently

NB: This particular PR doesn't make _all_ calls to secrets cached and concurrent.  Environment Secrets in particular seem to not be evaluated with a ScatterGather(), and doesn't use the same helmexec instance as other parts of the code, so it doesn't take advantage of these changes.  Some reworking of the plumbing there would be needed.
This commit is contained in:
Travis Groth
2019-08-07 23:00:19 +09:00
committed by KUOKA Yusuke
parent bce2f4728b
commit 6baad71b1f
2 changed files with 75 additions and 50 deletions
+8 -2
View File
@@ -228,10 +228,16 @@ func Test_DecryptSecret(t *testing.T) {
if err != nil {
t.Errorf("Error: %v", err)
}
expected := fmt.Sprintf(`Decrypting secret %s/secretName
// Run again for caching
helm.DecryptSecret(HelmContext{}, "secretName")
expected := fmt.Sprintf(`Preparing to decrypt secret %v/secretName
Decrypting secret %s/secretName
exec: helm secrets dec %s/secretName --kube-context dev
exec: helm secrets dec %s/secretName --kube-context dev:
`, cwd, cwd, cwd)
Preparing to decrypt secret %s/secretName
Found secret in cache %s/secretName
`, cwd, cwd, cwd, cwd, cwd, cwd)
if buffer.String() != expected {
t.Errorf("helmexec.DecryptSecret()\nactual = %v\nexpect = %v", buffer.String(), expected)
}