Skip to content
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

Add support for azure keyvault backend #87

Merged
merged 23 commits into from
Apr 8, 2022
Merged

Add support for azure keyvault backend #87

merged 23 commits into from
Apr 8, 2022

Conversation

Wiston999
Copy link
Contributor

Status

READY/

Migrations

NO

Description

Add support Azure KeyVault secrets backend.

List of fixes # (issue)

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Provide instructions so we can reproduce.

Please also list any relevant details for your test configuration

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

// There below line was added to access the azure data plane
// Which is required to access secrets in keyvault

clientCredentialConfig.Resource = "https://vault.azure.net"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we make vault.azure.net a constant, kind of:

azureKVEndpoint = "vault.azure.net"


func (c *azureKVClient) ReadSecret(path string, key string) (string, error) {
data := ""
uri := fmt.Sprintf("https://%s.vault.azure.net", c.keyvaultName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my comment above about the constant and lmk what do you think

errors/errors.go Outdated
@@ -7,6 +7,7 @@ const (
UnknownErrorType = "UnknownError"
BackendNotImplementedErrorType = "BackendNotImplementedError"
BackendSecretNotFoundErrorType = "BackendSecretNotFoundError"
BackendSecretForbiddenErrorType = "BackendSecretForbiddenError"
K8sSecretNotFoundErrorType = "K8sSecretNotFoundError"
InvalidConfigmapNameErrorType = "InvalidConfigmapNameError"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be a leftover from the migration from configmap to CRDs?

uri := fmt.Sprintf("https://%s.%s", c.keyvaultName, azureKVEndpoint)

// TODO: Add support for secret version?
result, err := c.client.GetSecret(context.Background(), uri, path, "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's inject the context that we create in main ?

Comment on lines 11 to 12
const vaultBackendName = "vault"
const azureKVBackendName = "azure-kv"
Copy link
Contributor

@fcgravalos fcgravalos Apr 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const (
  vaultBackendName   = "vault"
  azureKVBackendName = "azure-kv"
)

@codecov-commenter
Copy link

Codecov Report

Merging #87 (5490e83) into master (c293ef2) will decrease coverage by 4.07%.
The diff coverage is 57.69%.

@@            Coverage Diff             @@
##           master      #87      +/-   ##
==========================================
- Coverage   85.26%   81.19%   -4.08%     
==========================================
  Files           9       11       +2     
  Lines         482      553      +71     
==========================================
+ Hits          411      449      +38     
- Misses         53       86      +33     
  Partials       18       18              
Impacted Files Coverage Δ
errors/errors.go 100.00% <ø> (ø)
backend/backend.go 76.00% <33.33%> (-24.00%) ⬇️
backend/azure_kv.go 47.05% <47.05%> (ø)
backend/azure_kv_metrics.go 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c293ef2...5490e83. Read the comment docs.

fcgravalos
fcgravalos previously approved these changes Apr 8, 2022
Copy link
Contributor

@fcgravalos fcgravalos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool stuff 👍 !

LGTM

@Wiston999 Wiston999 merged commit f412074 into master Apr 8, 2022
@Wiston999 Wiston999 deleted the azure-keyvault branch April 8, 2022 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants