Skip to content

Commit

Permalink
fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigo-hcp committed Feb 13, 2025
1 parent 7580642 commit 5648962
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .changelog/1196.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ Add support for sync resource in HCP Vault Secrets
```

```release-note:improvement
Associate a sync with an HCP Vault Secrets App
Allow users to assign one or more syncs with an HCP Vault Secrets App
```
20 changes: 16 additions & 4 deletions examples/resources/hcp_vault_secrets_sync/resource.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# the provider is derived from the integration name
resource "hcp_vault_secrets_sync" "example_aws_sync" {
name = "my-aws-1"
integration_name = "my-integration-1"
resource "hcp_vault_secrets_integration" "example_gitlab_integration" {
name = "gitlab-integration"
capabilities = ["SYNC"]
provider_type = "gitlab"
gitlab_access = {
token = "myaccesstoken"
}
}

resource "hcp_vault_secrets_sync" "example_gitlab_project_sync" {
name = "gitlab-proj-sync"
integration_name = hcp_vault_secrets_integration.example_gitlab_integration.name
gitlab_config = {
scope = "PROJECT"
project_id = "123456"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestAccVaultSecretsResourceApp(t *testing.T) {
integration_name = hcp_vault_secrets_integration.acc_test.name
gitlab_config = {
scope = "GROUP"
project_id = "987654321"
group_id = "987654321"
}
}
resource "hcp_vault_secrets_app" "acc_test_app" {
Expand Down
5 changes: 2 additions & 3 deletions internal/provider/vaultsecrets/resource_vault_secrets_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package vaultsecrets
import (
"context"
"fmt"
"github.com/hashicorp/terraform-plugin-framework/attr"

"golang.org/x/exp/maps"

"github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/client/secret_service"
secretmodels "github.com/hashicorp/hcp-sdk-go/clients/cloud-vault-secrets/stable/2023-11-28/models"
"github.com/hashicorp/terraform-plugin-framework-validators/objectvalidator"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
Expand Down Expand Up @@ -177,12 +178,10 @@ func (r *resourceVaultSecretsSync) Schema(_ context.Context, _ resource.SchemaRe
},
"group_id": schema.StringAttribute{
Description: "ID of the group, if the scope is GROUP",
Sensitive: false,
Optional: true,
},
"project_id": schema.StringAttribute{
Description: "ID of the project, if the scope is PROJECT",
Sensitive: false,
Optional: true,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,23 @@ func TestAccVaultSecretsResourceSync(t *testing.T) {
{
Config: syncConfig(syncName, integrationName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet("hcp_vault_secrets_sync.acc_test_gitlab", "organization_id"),
resource.TestCheckResourceAttr("hcp_vault_secrets_sync.acc_test_gitlab", "project_id", os.Getenv("HCP_PROJECT_ID")),
resource.TestCheckResourceAttr("hcp_vault_secrets_sync.acc_test_gitlab", "name", syncName),
resource.TestCheckResourceAttr("hcp_vault_secrets_sync.acc_test_gitlab", "integration_name", integrationName)),
resource.TestCheckResourceAttrSet("hcp_vault_secrets_sync.acc_test_gitlab_group", "organization_id"),
resource.TestCheckResourceAttr("hcp_vault_secrets_sync.acc_test_gitlab_group", "project_id", os.Getenv("HCP_PROJECT_ID")),
resource.TestCheckResourceAttr("hcp_vault_secrets_sync.acc_test_gitlab_group", "name", syncName),
resource.TestCheckResourceAttr("hcp_vault_secrets_sync.acc_test_gitlab_group", "integration_name", integrationName)),
},
},
})
}

func syncConfig(syncName, integrationName string) string {
return fmt.Sprintf(`
resource "hcp_vault_secrets_sync" "acc_test_gitlab" {
resource "hcp_vault_secrets_sync" "acc_test_gitlab_group" {
name = %q
integration_name = %q
gitlab_config = {
scope = "GROUP"
group_id = 123456
}
}`, syncName, integrationName)
}

0 comments on commit 5648962

Please sign in to comment.