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 azuredevops_serviceendpoint_gcp_terraform resource #742

Merged
merged 18 commits into from
Jun 15, 2023

Conversation

konturn
Copy link
Contributor

@konturn konturn commented Mar 30, 2023

All Submissions:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • My code follows the code style of this project.
  • I ran lint checks locally prior to submission.
  • Have you checked to ensure there aren't other open PRs for the same update/change?

What about the current behavior has changed?

Issue Number: 675
This PR adds support for creating a GCP Service Endpoint. This resource is analogous to the one that's being provisioned for AWS in the PR here.

Does this introduce a change to go.mod, go.sum or vendor/?

  • Yes
  • No

Does this introduce a breaking change?

  • Yes
  • No

Any relevant logs, error output, etc?

(If it’s long, please paste to https://ghostbin.com/ and insert the link here.)

Other information

@konturn
Copy link
Contributor Author

konturn commented Mar 30, 2023

@microsoft-github-policy-service agree

@microsoft-github-policy-service agree

@konturn konturn closed this Mar 30, 2023
@konturn konturn reopened this Mar 30, 2023
@konturn
Copy link
Contributor Author

konturn commented Mar 30, 2023

@microsoft-github-policy-service agree

@konturn
Copy link
Contributor Author

konturn commented Jun 2, 2023

@xuzhang3 is there any other work required on my end before this can be reviewed?

@xuzhang3
Copy link
Collaborator

xuzhang3 commented Jun 7, 2023

@konturn can you help resolve the conflicts and update to the latest code. We recently upgrade the API from v5/v6 to v7.

Copy link
Collaborator

@xuzhang3 xuzhang3 left a comment

Choose a reason for hiding this comment

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

@konturn Thanks for your contribution. A few changes requested.

  1. website/docs/r/serviceendpoint_gcp.html.markdown need to be documented in azuredevops.erb
  2. Please make sure the acc tests passed.

r.Schema[saSecretHashKey] = saSecretHashSchema
r.Schema["token_uri"] = &schema.Schema{
Type: schema.TypeString,
Optional: false,
Copy link
Collaborator

Choose a reason for hiding this comment

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

if this property is required, use Required: true, and if optional use Optional: true,

}
r.Schema["gcp_project_id"] = &schema.Schema{
Type: schema.TypeString,
Optional: false,
Copy link
Collaborator

Choose a reason for hiding this comment

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

if this property is required, use Required: true, and if optional use Optional: true,

Sensitive: true,
DiffSuppressFunc: tfhelper.DiffFuncSuppressSecretChanged,
}
saSecretHashKey, saSecretHashSchema := tfhelper.GenerateSecreteMemoSchema("private_key")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hash function has been deprecated, can removed.


# azuredevops_serviceendpoint_gcp
Manages a GCP service endpoint within Azure DevOps.

Copy link
Collaborator

Choose a reason for hiding this comment

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

GCP extension is not installed by default. Add note which extension need installed before using this resource.

r := genBaseServiceEndpointResource(flattenServiceEndpointGcp, expandServiceEndpointGcp)
r.Schema["client_email"] = &schema.Schema{
Type: schema.TypeString,
Required: false,
Copy link
Collaborator

Choose a reason for hiding this comment

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

if this property is required, use Required: true, and if optional use Optional: true,

@konturn konturn force-pushed the feat/add-gcp-serviceendpoint branch 2 times, most recently from 128b679 to 8cc051d Compare June 8, 2023 18:48
@konturn konturn force-pushed the feat/add-gcp-serviceendpoint branch from 8fc8726 to f0ace9d Compare June 8, 2023 19:11
@konturn konturn changed the title feat: add gcp serviceendpoint resource Add azuredevops_serviceendpoint_gcp_terraform resource Jun 8, 2023
@konturn
Copy link
Contributor Author

konturn commented Jun 8, 2023

Alrighty @xuzhang3 I've made all the requested changes, and I've also changed the name scheme to make it more clear that this is a GCP Service Endpoint for Terraform (very similar to the PR here).

@xuzhang3
Copy link
Collaborator

xuzhang3 commented Jun 9, 2023

@konturn you need merge/rebase the latest code from https://github.com/microsoft/terraform-provider-azuredevops. And ensure the AccTests passed.

@konturn
Copy link
Contributor Author

konturn commented Jun 9, 2023

My bad, thought I had updated--@xuzhang3 I've merged main into my PR branch, and the pipeline is green.

DefaultFunc: schema.EnvDefaultFunc("AZDO_GCP_SERVICE_CONNECTION_PRIVATE_KEY", nil),
Description: "Private Key for connecting to the endpoint.",
Sensitive: true,
DiffSuppressFunc: tfhelper.DiffFuncSuppressSecretChanged,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should be removed, this function is combined with the hash function

// ResourceServiceEndpointGcp schema and implementation for gcp service endpoint resource
func ResourceServiceEndpointGcp() *schema.Resource {
r := genBaseServiceEndpointResource(flattenServiceEndpointGcp, expandServiceEndpointGcp)
r.Schema["client_email"] = &schema.Schema{
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we simplify the name to email?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could, but I kept it that way since that's what shows up in the ADO GUI and also in the GCP keyfile json.

@konturn konturn force-pushed the feat/add-gcp-serviceendpoint branch from 3f2e129 to 0c27151 Compare June 13, 2023 14:26
@konturn
Copy link
Contributor Author

konturn commented Jun 15, 2023

Alrighty, I think that's everything--@xuzhang3 any other changes that need made?

@xuzhang3
Copy link
Collaborator

=== RUN   TestAccServiceEndpointGcpTerraform_Basic
=== PAUSE TestAccServiceEndpointGcpTerraform_Basic
=== RUN   TestAccServiceEndpointGcpTerraform_Complete
=== PAUSE TestAccServiceEndpointGcpTerraform_Complete
=== RUN   TestAccServiceEndpointGcpTerraform_update
=== PAUSE TestAccServiceEndpointGcpTerraform_update
=== RUN   TestAccServiceEndpointGcpTerraform_requiresImportErrorStep
=== PAUSE TestAccServiceEndpointGcpTerraform_requiresImportErrorStep
=== CONT  TestAccServiceEndpointGcpTerraform_Basic
=== CONT  TestAccServiceEndpointGcpTerraform_update
=== CONT  TestAccServiceEndpointGcpTerraform_requiresImportErrorStep
=== CONT  TestAccServiceEndpointGcpTerraform_Complete
--- PASS: TestAccServiceEndpointGcpTerraform_Complete (75.38s)
--- PASS: TestAccServiceEndpointGcpTerraform_Basic (75.75s)
--- PASS: TestAccServiceEndpointGcpTerraform_requiresImportErrorStep (83.46s)
--- PASS: TestAccServiceEndpointGcpTerraform_update (112.80s)
PASS
ok      github.com/microsoft/terraform-provider-azuredevops/azuredevops/internal/acceptancetests        114.534s

@xuzhang3
Copy link
Collaborator

@konturn LGTM

@xuzhang3 xuzhang3 merged commit 2ed1dba into microsoft:main Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants