AzBuilder / terraform-provider-terrakube

Terraform provider for Terrakube
Apache License 2.0
4 stars 3 forks source link

feat: add `terrakube_vcs` resource #59

Closed stanleyz closed 1 month ago

stanleyz commented 1 month ago

Additional changes:

  1. Rename file name organization_template_data_resource.go to organization_template_data_source.go to be consistent with other file names
stanleyz commented 1 month ago

@alfespa17 can you please review this one? Thanks.

It's a little bit primitive, I tried to add some default values to the attributes, but because of how it handles in the new terraform-plugin-framework compared with SDK v2, I gave up for now.

alfespa17 commented 1 month ago

Hello @stanleyz

This looks good, I just have a few comments:

  1. Even if you create the vcs connection you will still need to go the the complete the setup(there is a redirect in the ui to do that), maybe you can add some comment about that inside the vcs.md file
  2. In the future you can add a "calculated" property to show the URL where you can complete the connection like here.
  3. There are some default values for the API URL and endpoint depending of what VCS type you are using here and here maybe adding a few comments inside vcs.md will be a good idea
alfespa17 commented 1 month ago

By the way once I merge this one I think I can create a new release you already add a couple of new features to the provider

stanleyz commented 1 month ago

@alfespa17 please take a look. yeah, those are all good points, I was in a rush and didn't bother to add those defaults stuff.

I've now added default values and some checks in the schema. However one thing I need your help is that the update always returns 400 however for any fields, but I don't see reasons in code, can you possibly point a direction here? Thanks.

alfespa17 commented 1 month ago

Sure @stanleyz I can check this afternoon when I have some free time

alfespa17 commented 1 month ago

@stanleyz I found that the body for the update does not include the ID as you can see in this example

2024-08-01T11:23:32.661-0600 [INFO]  provider.terraform-provider-terrakube: Body Update Request: {"data":{"type":"vcs","attributes":{"apiUrl":"https://localhost","clientId":"1","clientSecret":"1234asfasf5","description":"1231234","endpoint":"https://localhost","name":"testasdfasdfasf","status":"PENDING","vcsType":"GITHUB"}}}
: tf_req_id=0e3f4532-a65b-33bb-fb58-e7e8f709c0a7 tf_resource_type=terrakube_vcs tf_rpc=ApplyResourceChange tf_provider_addr=registry.terraform.io/AzBuilder/terrakube @module=terrakube @caller=/home/user/git/pr/terraform-provider-terrakube/internal/provider/vcs_resource.go:340 timestamp=2024-08-01T11:23:32.661-0600
2024-08-01T11:23:35.032-0600 [INFO]  provider.terraform-provider-terrakube: VCS Response: @module=terrakube tf_provider_addr=registry.terraform.io/AzBuilder/terrakube tf_rpc=ApplyResourceChange @caller=/home/user/git/pr/terraform-provider-terrakube/internal/provider/vcs_resource.go:361 success="{"errors":[{"detail":"Bad Request Body'Id in response body does not match requested id to update from path'"}]}" tf_req_id=0e3f4532-a65b-33bb-fb58-e7e8f709c0a7 tf_resource_type=terrakube_vcs timestamp=2024-08-01T11:23:35.032-0600