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

Implement schema for user secrets management #440

Conversation

anvial
Copy link
Member

@anvial anvial commented Mar 26, 2024

Description

This PR introduces the ability to add, update, and remove user secrets in the schema. This is done through the userSecretResource struct, which has methods for each of these actions.

Fixes:

Type of change

  • Add new resource

QA steps

Check acceptance tests:

TF_ACC=1 TEST_CLOUD=lxd TF_ACC_LOG=TRACE TF_LOG=TRACE TF_ACC_LOG_PATH=/tmp/test.txt go test ./...

Example of TF plan:

terraform {
  required_providers {
    juju = {
      source  = "juju/juju"
      version = "0.11.0"
    }
  }
}
provider "juju" {}

resource "juju_secret" "my_secret" {
  model = "test"
  name  = "my_secret_name"
  value = {
    key1 = "value1"
    key2 = "value2"
  }
  info  = "This is my secret"
}

resource "juju_application" "jameinel-ubuntu-lite" {
  name  = "jameinel-ubuntu-lite"
  model = "test"


  charm {
    name     = "jameinel-ubuntu-lite"
    channel  = "latest/stable"
  }

  units = 1
}
terraform init -upgrade  && terraform plan && terraform apply -auto-approve

@anvial anvial force-pushed the JUJU-5710-schema-for-user-secrets-add-update-remove-resource branch from a6b838b to cd5e57a Compare March 28, 2024 08:18
@hmlanigan hmlanigan added this to the 0.12.0 milestone Apr 2, 2024
@anvial anvial force-pushed the JUJU-5710-schema-for-user-secrets-add-update-remove-resource branch 3 times, most recently from f39fab8 to 9f3261a Compare April 10, 2024 18:19
Copy link
Member

@hmlanigan hmlanigan left a comment

Choose a reason for hiding this comment

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

Some initial thoughts and hints

internal/provider/resource_secret.go Outdated Show resolved Hide resolved
internal/provider/resource_secret.go Outdated Show resolved Hide resolved
internal/provider/resource_secret.go Show resolved Hide resolved
internal/provider/resource_secret.go Outdated Show resolved Hide resolved
internal/provider/resource_secret.go Outdated Show resolved Hide resolved
internal/provider/resource_secret.go Show resolved Hide resolved
internal/provider/resource_secret.go Show resolved Hide resolved
@anvial anvial force-pushed the JUJU-5710-schema-for-user-secrets-add-update-remove-resource branch 4 times, most recently from da78d75 to 7281184 Compare April 11, 2024 13:12
@anvial anvial force-pushed the JUJU-5710-schema-for-user-secrets-add-update-remove-resource branch 4 times, most recently from bd42bb0 to 364a1ca Compare April 11, 2024 17:38
@anvial anvial changed the title [WIP] Implement schema for user secrets management Implement schema for user secrets management Apr 11, 2024
@anvial anvial force-pushed the JUJU-5710-schema-for-user-secrets-add-update-remove-resource branch 5 times, most recently from bf6b60b to ae8fd59 Compare April 11, 2024 19:17
@anvial anvial force-pushed the JUJU-5710-schema-for-user-secrets-add-update-remove-resource branch from 763573d to 48b94fb Compare April 16, 2024 09:40
Copy link
Contributor

@Aflynn50 Aflynn50 left a comment

Choose a reason for hiding this comment

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

Looks good, just a few things.

internal/juju/models.go Outdated Show resolved Hide resolved
internal/provider/resource_secret.go Show resolved Hide resolved
internal/provider/resource_secret.go Show resolved Hide resolved
internal/provider/resource_secret.go Show resolved Hide resolved
internal/provider/resource_secret_test.go Show resolved Hide resolved
Copy link
Contributor

@cderici cderici left a comment

Choose a reason for hiding this comment

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

Couple of small points noted, QA went well. Approving, but the check against 2.9 for the secrets api is needed.

internal/juju/models.go Outdated Show resolved Hide resolved
internal/juju/secrets.go Outdated Show resolved Hide resolved
internal/provider/resource_secret.go Show resolved Hide resolved
internal/provider/resource_secret.go Show resolved Hide resolved
internal/provider/resource_secret.go Show resolved Hide resolved
internal/provider/resource_secret.go Show resolved Hide resolved
internal/provider/resource_secret.go Show resolved Hide resolved
@anvial anvial force-pushed the JUJU-5710-schema-for-user-secrets-add-update-remove-resource branch 3 times, most recently from 967b436 to b31adff Compare April 17, 2024 12:16
This commit introduces internal/juju/userSecret and adds method to add user secrets.

Implement internal Juju secrets add, update, and remove functionality

This commit introduces several changes to the Juju client in the `internal/juju/client.go` file.
It includes the implementation of methods for adding, updating, and removing secrets. Additionally,

Furthermore, the commit includes changes to the `secret.go` file, introducing new types for managinng secrets.
It also includes changes to the `interfaces.go` file, defining new interfaces for the Juju client API.

Add secretURI to UpdateSecret

Add secretURI to DeleteSecret

Add AutoPrunt to UpdateSecret schema

Add SecretId to ReadSecret func instead of name.

Add lost Asserts.

Add secretNotFoundError

Extract mocks creation into separate suite.

Introduce typedError(err) usage in ClientAPI funcs.

Add renaming to UpdateSecret

Use struct raather than pointer for Output structures.

Introcue NewName in Update input struct.

Use pointers in all places in structs where the parameter is not
neccessary.

Implement schema for user secrets management

This commit introduces the ability to add, update, and remove user secrets in the schema.
This is done through the `userSecretResource` struct, which has methods for each of these actions.
The `Add`, `Update`, and `Remove` methods are currently stubbed out and will need to be implemented in future commits.

Add ReadSecret function implementation.

Implement Delete secret function

Add base64 encoding co Create and change Read fucntion to get value with
decode.

Add base64 encoding for values in Update
@anvial anvial force-pushed the JUJU-5710-schema-for-user-secrets-add-update-remove-resource branch from b31adff to d6d2504 Compare April 17, 2024 13:00
@anvial anvial merged commit bd954d9 into juju:main Apr 17, 2024
25 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.

4 participants