Skip to content

Conversation

@sudomateo
Copy link
Collaborator

Set omitzero on the following types to allow clients to set an empty slice and have it serialized to [], which is required by Oxide APIs to unset a value.

  • []VpcFirewallRuleUpdate
  • []NameOrId

The previous behavior would omit an empty slice entirely during serialization, causing the Oxide APIs to respond with an error.

Copy link
Collaborator

@karencfv karencfv left a comment

Choose a reason for hiding this comment

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

Looks good! Anyone using the client will need to update to Go 1.24 though, no? We should definitely note that as a breaking change in the changelog.

Maybe this will sound like overkill, but can we test these by updating the terraform provider and running the acceptance tests for the instance and VPC firewall rules resources? I've been bitten by this API before and am paranoid now 😅

@sudomateo sudomateo force-pushed the sudomateo/omitzero-exceptions branch from 434972e to 6e0b217 Compare May 29, 2025 03:40
@sudomateo
Copy link
Collaborator Author

Looks good! Anyone using the client will need to update to Go 1.24 though, no? We should definitely note that as a breaking change in the changelog.

Done! Let me know if you want me to separate the changelog notes or otherwise do the Go 1.24 update and the addition of omitzero in different pull requests.

Maybe this will sound like overkill, but can we test these by updating the terraform provider and running the acceptance tests for the instance and VPC firewall rules resources? I've been bitten by this API before and am paranoid now 😅

Yep, I will! I'll test it tomorrow. My tomorrow haha.

@sudomateo
Copy link
Collaborator Author

I split out the Go 1.24 update to #291.

@karencfv
Copy link
Collaborator

Done! Let me know if you want me to separate the changelog notes or otherwise do the Go 1.24 update and the addition of omitzero in different pull requests.

Looks like it's already in two PRs 😄 Sounds good to me!

@sudomateo sudomateo force-pushed the sudomateo/omitzero-exceptions branch from c2f5cf5 to 040010f Compare May 29, 2025 14:13
@sudomateo
Copy link
Collaborator Author

I checked out the changes in oxidecomputer/terraform-provider-oxide#432.

> jj log -r '@-::' --template 'builtin_log_oneline'
@  utyxtwkl matthew.sanabria 2025-05-29 10:39:35 afeeb5f6 (no description set)
○  soyvuztz karencfv 2025-05-15 22:29:07 fw-rules-update git_head() 5739d40f In-place update for VPC firewall rules
│
~

Updated it to use the Go SDK changes in this pull request.

diff --git a/go.mod b/go.mod
index adfd4f53ff..62fce3208f 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
 module github.com/oxidecomputer/terraform-provider-oxide

-go 1.23.0
+go 1.24.3

 require (
        github.com/google/uuid v1.6.0
@@ -11,7 +11,7 @@
        github.com/hashicorp/terraform-plugin-log v0.9.0
        github.com/hashicorp/terraform-plugin-sdk/v2 v2.36.1
        github.com/hashicorp/terraform-plugin-testing v1.12.0
-       github.com/oxidecomputer/oxide.go v0.4.1-0.20250423011427-65b1d0f6b391
+       github.com/oxidecomputer/oxide.go v0.4.1-0.20250529141328-040010f4ebec
        github.com/stretchr/testify v1.10.0
 )

diff --git a/go.sum b/go.sum
index d2db5e7c90..2cdde56808 100644
--- a/go.sum
+++ b/go.sum
@@ -138,6 +138,8 @@
 github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
 github.com/oxidecomputer/oxide.go v0.4.1-0.20250423011427-65b1d0f6b391 h1:q/ebxcSiqQrrdmDsd+w7gwqZUcGhpHmY9Bu2uYKNGL8=
 github.com/oxidecomputer/oxide.go v0.4.1-0.20250423011427-65b1d0f6b391/go.mod h1:yNLdQdroM42/yDIFlCsLAR9PawAdeJZDgHdAx+wcywg=
+github.com/oxidecomputer/oxide.go v0.4.1-0.20250529141328-040010f4ebec h1:iqdsaEnS+y8Crfy0EJlRCI1YAyZMc3vQxL28ZDBUYHo=
+github.com/oxidecomputer/oxide.go v0.4.1-0.20250529141328-040010f4ebec/go.mod h1:4gfHlxdBQLs/34UbChPvINd+pGNAnGlASRGEd4xIz1Y=
 github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
 github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
 github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4=

And ran the acceptance tests.

> TEST_ACC_NAME=TestAccCloudResourceFirewallRules make testacc
-> Running terraform acceptance tests
=== RUN   TestAccCloudResourceFirewallRules_full
=== PAUSE TestAccCloudResourceFirewallRules_full
=== CONT  TestAccCloudResourceFirewallRules_full
--- PASS: TestAccCloudResourceFirewallRules_full (9.43s)
PASS
ok      github.com/oxidecomputer/terraform-provider-oxide/internal/provider     9.437s
> TEST_ACC_NAME=TestAccCloudResourceInstance make testacc
-> Running terraform acceptance tests
=== RUN   TestAccCloudResourceInstance_full
=== PAUSE TestAccCloudResourceInstance_full
=== RUN   TestAccCloudResourceInstance_extIPs
=== PAUSE TestAccCloudResourceInstance_extIPs
=== RUN   TestAccCloudResourceInstance_sshKeys
=== PAUSE TestAccCloudResourceInstance_sshKeys
=== RUN   TestAccCloudResourceInstance_nic
=== PAUSE TestAccCloudResourceInstance_nic
=== RUN   TestAccCloudResourceInstance_disk
=== PAUSE TestAccCloudResourceInstance_disk
=== RUN   TestAccCloudResourceInstance_update
=== PAUSE TestAccCloudResourceInstance_update
=== RUN   TestAccCloudResourceInstance_antiAffinityGroups
=== PAUSE TestAccCloudResourceInstance_antiAffinityGroups
=== CONT  TestAccCloudResourceInstance_full
=== CONT  TestAccCloudResourceInstance_disk
=== CONT  TestAccCloudResourceInstance_sshKeys
=== CONT  TestAccCloudResourceInstance_antiAffinityGroups
=== CONT  TestAccCloudResourceInstance_nic
=== CONT  TestAccCloudResourceInstance_extIPs
--- PASS: TestAccCloudResourceInstance_extIPs (10.80s)
=== CONT  TestAccCloudResourceInstance_update
--- PASS: TestAccCloudResourceInstance_sshKeys (12.22s)
--- PASS: TestAccCloudResourceInstance_full (42.16s)
--- PASS: TestAccCloudResourceInstance_antiAffinityGroups (49.75s)
--- PASS: TestAccCloudResourceInstance_nic (53.92s)
--- PASS: TestAccCloudResourceInstance_disk (69.78s)
--- PASS: TestAccCloudResourceInstance_update (68.64s)
PASS
ok      github.com/oxidecomputer/terraform-provider-oxide/internal/provider     79.454s

Set `omitzero` on the following types to allow clients to set an empty
slice and have it serialized to `[]`, which is required by Oxide APIs to
unset a value.

* `[]VpcFirewallRuleUpdate`
* `[]NameOrId`

The previous behavior would omit an empty slice entirely during
serialization, causing the Oxide APIs to respond with an error.
@sudomateo sudomateo force-pushed the sudomateo/omitzero-exceptions branch from 040010f to c6dcf55 Compare May 29, 2025 21:00
Copy link
Collaborator

@karencfv karencfv left a comment

Choose a reason for hiding this comment

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

Thanks for running the tests!!! Looks great

@sudomateo sudomateo merged commit ecfa72d into main May 30, 2025
1 check passed
@sudomateo sudomateo deleted the sudomateo/omitzero-exceptions branch May 30, 2025 02:39
@jmcarp jmcarp mentioned this pull request Dec 5, 2025
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.

3 participants