BunnyWay / terraform-provider-bunnynet

bunny.net Terraform provider
https://registry.terraform.io/providers/BunnyWay/bunnynet
Mozilla Public License 2.0
6 stars 1 forks source link

Add pullzoneEdgeruleTriggerTypeMap values to the Terraform docs #17

Open DMeechan opened 1 week ago

DMeechan commented 1 week ago

Hi! Could you add the different values for bunnynet_pullzone_edgerule.triggers.type to the Terraform docs please?

I was getting this panic: value not found in map error:

  Stack trace from the terraform-provider-bunnynet_v0.3.15 plugin:

  panic: value not found in map

  goroutine 113 [running]:
  github.com/bunnyway/terraform-provider-bunnynet/internal/provider.mapValueToKey[...](0x1400022e4f8?, {0x140003442d4?, 0xb})
    github.com/bunnyway/terraform-provider-bunnynet/internal/provider/utils.go:25 +0xac
  github.com/bunnyway/terraform-provider-bunnynet/internal/provider.(*PullzoneEdgeruleResource).convertModelToApi(_, {_, _}, {{0x2, {0x140001c23c0, 0x24}}, {0x2, 0x257583}, {0x2, 0x1}, ...})
    github.com/bunnyway/terraform-provider-bunnynet/internal/provider/resource_pullzone_edgerule.go:438 +0x8c8
  github.com/bunnyway/terraform-provider-bunnynet/internal/provider.(*PullzoneEdgeruleResource).Update(0x14000112028, {0x101613c00, 0x140002110b0}, {{{{0x101617ff0, 0x140002838c0}, {0x101528260, 0x14000282d80}}, {0x1016196f8, 0x140006988c0}}, {{{0x101617ff0, ...}, ...}, ...}, ...}, ...)
    github.com/bunnyway/terraform-provider-bunnynet/internal/provider/resource_pullzone_edgerule.go:303 +0x1c8
  github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).UpdateResource(0x1400013d600, {0x101613c00, 0x140002110b0}, 0x1400022f320, 0x1400022f230)
...etc...

  Error: The terraform-provider-bunnynet_v0.3.15 plugin crashed!

  This is always indicative of a bug within the plugin. It would be immensely
  helpful if you could report the crash with the plugin's maintainers so that it
  can be fixed. The output above should help diagnose the issue.

  exit status 1

Cause:

Turns out I was using an invalid value for the trigger type. I found the correct value in the source code (in my case I needed UrlQueryString)

Thanks!

rafael-at-bunny commented 1 week ago

Hi.

Thank you for reporting this. Unfortunately terraform-plugin-docs doesn't have support for this at the moment.

However, it's also an oversight on my part that there was no validation for the triggers. I've added it via cd530252329dd95d8fb693f947fdb78170b5a196, alongside with some tests to avoid regressions.

│ Error: Trigger type must be valid
│ 
│   with bunnynet_pullzone_edgerule.block_admin,
│   on issue-17.tf line 21, in resource "bunnynet_pullzone_edgerule" "block_admin":
│   21:   triggers = [
│   22:     {
│   23:       type       = "invalid"
│   24:       match_type = "MatchAny"
│   25:       patterns   = ["*"]
│   26:       parameter1 = null
│   27:       parameter2 = null
│   28:     }
│   29:   ]
│ 
│ Trigger "type" must be one of
│ ["ResponseHeader","CountryCode","RemoteIP","RandomChance","StatusCode","CookieValue","Url","RequestHeader","UrlExtension","UrlQueryString","RequestMethod","CountryStateCode"].

I'll keep this issue open until we have upstream support, or at least some workaround implemented.

Thank you.