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

chore: don't allow nil credential store #1514

Merged
merged 4 commits into from
Jan 10, 2025

Conversation

kian99
Copy link
Contributor

@kian99 kian99 commented Jan 9, 2025

Description

Currently we allow a nil credential store for legacy functionality to store secrets in Postgres or Vault. Nowadays secrets go to the CredentialStore interface which can use an underlying Vault/Postgres/Other. In addition, secrets/sensitive data are no longer in dbmodel types.

Fixes JUJU-7285

Engineering checklist

  • Documentation updated
  • Covered by unit tests
  • Covered by integration tests

@kian99 kian99 requested a review from a team as a code owner January 9, 2025 08:17
Currently we allow a nil credential store for legacy functionality to store secrets in Postgres or Vault. Nowadays secrets go to the CredentialStore interface which can be Vault/Postgres/Other.
Secrets/sensitive data are now no longer in dbmodel types.
@kian99 kian99 force-pushed the no-nil-credential-store branch 2 times, most recently from 4ef374a to f59ab3a Compare January 9, 2025 11:54
@kian99 kian99 force-pushed the no-nil-credential-store branch from f59ab3a to de3895e Compare January 9, 2025 13:35
Copy link
Collaborator

@alesstimec alesstimec left a comment

Choose a reason for hiding this comment

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

LGTM with a few nitpicks. thanks

@@ -126,6 +126,9 @@ func (d *Database) Get(ctx context.Context, tag names.CloudCredentialTag) (_ map
secret := dbmodel.NewSecret(tag.Kind(), tag.String(), nil)
err = d.GetSecret(ctx, &secret)
if err != nil {
if errors.ErrorCode(err) == errors.CodeNotFound {
return nil, nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

why are we returning no error if it is not found?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the behaviour of our Vault client, that test where I set it to run against Postgres and Vault showed that our Postgres implementation was not consistent with our Vault implementation. So I've changed the Postgres implementation to match Vault.

internal/jimm/cloudcredential.go Outdated Show resolved Hide resolved
internal/jimm/types.go Show resolved Hide resolved
internal/jimm/types.go Show resolved Hide resolved
internal/testutils/jimmtest/gorm.go Show resolved Hide resolved
Copy link
Contributor

@SimoneDutto SimoneDutto left a comment

Choose a reason for hiding this comment

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

lgtm, but i think we should go back to small prs. These latest prs (min included) are becoming difficult to review properly

@kian99
Copy link
Contributor Author

kian99 commented Jan 10, 2025

lgtm, but i think we should go back to small prs

Yeah it will hopefully be better with the other managers because we can move whole files over and make changes rather than extracting bits and creating more lines changed than necessary.

@kian99 kian99 merged commit 8c6df2a into canonical:v3 Jan 10, 2025
4 checks passed
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.

3 participants