-
Notifications
You must be signed in to change notification settings - Fork 4
Key vault reference support #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
keyvault.go
Outdated
| // keyVaultReferenceResolver resolves Key Vault references to their actual secret values | ||
| type keyVaultReferenceResolver struct { | ||
| clients map[string]secretClient | ||
| resolver SecretResolver |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to export this interface?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we export SecretResolver interface which need to be implemented by user.
keyvault.go
Outdated
| return nil, fmt.Errorf("failed to create Key Vault client: %w", err) | ||
| } | ||
|
|
||
| r.clients[vaultURL] = client |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolveSecrets would be called concurrently in different routines, hence this resovler.getSecretClient. Becareful of clients, it needs to be multi-routine-safe, too.
41f7d58 to
d783da6
Compare
| // SecretResolver is an interface to resolve secret from key vault reference | ||
| type SecretResolver interface { | ||
| // keyVaultReference: "https://{keyVaultName}.vault.azure.net/secrets/{secretName}/{secretVersion}" | ||
| ResolveSecret(ctx context.Context, keyVaultReference url.URL) (string, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about rename this parameter to secretUrl?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer keyVaultReference since it's widely used in our public docs
jhzhu89
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Maybe you could consider adding some test cases for covering concurrent r/w scenarios, you can run these tests with race enabled. It could help you capture race conditions are not well handled.
No description provided.