Skip to content

Conversation

@tanmay-hc
Copy link
Collaborator

@tanmay-hc tanmay-hc commented Apr 9, 2025

This PR adds support for the secrets manager from google cloud.
This implementation is in continuation from the original PR #99

This change allows the user to fetch the secrets from their secret manager in GCP, with an option for specifying:

  • Key of a secret to fetch its value

Closes #29

@tanmay-hc tanmay-hc requested a review from a team as a code owner April 9, 2025 07:19
@tanmay-hc tanmay-hc requested a review from Copilot April 9, 2025 07:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 5 out of 10 changed files in this pull request and generated 2 comments.

Files not reviewed (5)
  • datasource/secretsmanager/test-fixtures/template.pkr.hcl: Language not supported
  • docs-partials/datasource/secretmanager/Config-not-required.mdx: Language not supported
  • docs-partials/datasource/secretmanager/Config-required.mdx: Language not supported
  • docs-partials/datasource/secretmanager/DatasourceOutput.mdx: Language not supported
  • go.mod: Language not supported

// The decoded values from this spec will then be applied to a FlatConfig.
func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
s := map[string]hcldec.Spec{
"project_id": &hcldec.AttrSpec{Name: "project_id", Type: cty.String, Required: false},
Copy link

Copilot AI Apr 9, 2025

Choose a reason for hiding this comment

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

The Config struct marks 'project_id' as required but the HCL2 spec sets it as not required. Consider setting Required to true in the spec to match the Config validation.

Suggested change
"project_id": &hcldec.AttrSpec{Name: "project_id", Type: cty.String, Required: false},
"project_id": &hcldec.AttrSpec{Name: "project_id", Type: cty.String, Required: true},

Copilot uses AI. Check for mistakes.
func (*FlatConfig) HCL2Spec() map[string]hcldec.Spec {
s := map[string]hcldec.Spec{
"project_id": &hcldec.AttrSpec{Name: "project_id", Type: cty.String, Required: false},
"name": &hcldec.AttrSpec{Name: "name", Type: cty.String, Required: false},
Copy link

Copilot AI Apr 9, 2025

Choose a reason for hiding this comment

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

Similarly, 'name' is required in the Config struct but not marked as such in the HCL2 spec. Aligning this by setting Required to true can improve configuration validation.

Suggested change
"name": &hcldec.AttrSpec{Name: "name", Type: cty.String, Required: false},
"name": &hcldec.AttrSpec{Name: "name", Type: cty.String, Required: true},

Copilot uses AI. Check for mistakes.
@tanmay-hc tanmay-hc force-pushed the gce-secret branch 5 times, most recently from 6440ead to dbff7fc Compare April 14, 2025 04:03
Copy link

@anshulsharma-hashicorp anshulsharma-hashicorp left a comment

Choose a reason for hiding this comment

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

LGTM

@kp2099 kp2099 requested a review from Copilot April 17, 2025 06:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for fetching secrets from Google Cloud’s Secret Manager by introducing a new datasource.

  • Registers the new "secretsmanager" datasource in main.go
  • Implements secrets manager configuration, execution, and output logic in datasource/secretsmanager/data.go
  • Adds both unit and acceptance tests to validate behavior for the new secrets manager feature

Reviewed Changes

Copilot reviewed 6 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
main.go Registers the new secretsmanager datasource
datasource/secretsmanager/data.go Implements secrets manager datasource
datasource/secretsmanager/data_test.go Adds unit tests for configuration errors
datasource/secretsmanager/data_acc_test.go Adds acceptance tests for live GCP integration
datasource/secretsmanager/data.hcl2spec.go Auto-generated HCL2 spec mapping for config
Files not reviewed (5)
  • datasource/secretsmanager/test-fixtures/template.pkr.hcl: Language not supported
  • docs-partials/datasource/secretsmanager/Config-not-required.mdx: Language not supported
  • docs-partials/datasource/secretsmanager/Config-required.mdx: Language not supported
  • docs-partials/datasource/secretsmanager/DatasourceOutput.mdx: Language not supported
  • go.mod: Language not supported

@tanmay-hc tanmay-hc merged commit 4aa77a5 into main Apr 21, 2025
12 checks passed
@tanmay-hc tanmay-hc deleted the gce-secret branch April 21, 2025 05:50
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.

Add secrets manager datasource

3 participants