From 4ba5140dce14060300a6e91042bb3dd12f3b1e7f Mon Sep 17 00:00:00 2001 From: Matthew Sanabria Date: Mon, 16 Feb 2026 15:11:05 -0500 Subject: [PATCH] misc(deps): update `oxide.go` Updated `oxide.go` to a release 18 compatible version. Relates to SSE-142. Amp-Thread: https://ampcode.com/threads/T-019c6814-2d54-7558-90cd-19d7da5d1172 --- .../builder/instance/step_image_create.go | 5 +- .../builder/instance/step_instance_create.go | 76 ++++++++++--------- .../step_instance_external_ip_list.go | 25 ++++-- .../data-source/image/data_source_test.go | 15 ++-- go.mod | 2 +- go.sum | 10 +-- 6 files changed, 75 insertions(+), 58 deletions(-) diff --git a/component/builder/instance/step_image_create.go b/component/builder/instance/step_image_create.go index 3e398b0..89e8309 100644 --- a/component/builder/instance/step_image_create.go +++ b/component/builder/instance/step_image_create.go @@ -37,8 +37,9 @@ func (s *stepImageCreate) Run( Name: oxide.Name(config.ArtifactName), Os: config.ArtifactOS, Source: oxide.ImageSource{ - Type: oxide.ImageSourceTypeSnapshot, - Id: snapshotID, + Value: &oxide.ImageSourceSnapshot{ + Id: snapshotID, + }, }, Version: config.ArtifactVersion, }, diff --git a/component/builder/instance/step_instance_create.go b/component/builder/instance/step_instance_create.go index 26700c8..c6cae84 100644 --- a/component/builder/instance/step_instance_create.go +++ b/component/builder/instance/step_instance_create.go @@ -34,37 +34,42 @@ func (o *stepInstanceCreate) Run( Project: oxide.NameOrId(config.Project), Body: &oxide.InstanceCreate{ AntiAffinityGroups: []oxide.NameOrId{}, - BootDisk: &oxide.InstanceDiskAttachment{ - Type: oxide.InstanceDiskAttachmentTypeCreate, - Name: oxide.Name(config.Name), - Description: "Created by Packer.", - Size: oxide.ByteCount(config.BootDiskSize), - DiskBackend: oxide.DiskBackend{ - Type: oxide.DiskBackendTypeDistributed, - DiskSource: oxide.DiskSource{ - Type: oxide.DiskSourceTypeImage, - ImageId: config.BootDiskImageID, + BootDisk: oxide.InstanceDiskAttachment{ + Value: &oxide.InstanceDiskAttachmentCreate{ + Name: oxide.Name(config.Name), + Description: "Created by Packer.", + Size: oxide.ByteCount(config.BootDiskSize), + DiskBackend: oxide.DiskBackend{ + Value: &oxide.DiskBackendDistributed{ + DiskSource: oxide.DiskSource{ + Value: &oxide.DiskSourceImage{ + ImageId: config.BootDiskImageID, + }, + }, + }, }, }, }, Description: "Created by Packer.", ExternalIps: []oxide.ExternalIpCreate{ { - Type: oxide.ExternalIpCreateTypeEphemeral, - PoolSelector: func() oxide.PoolSelector { - if config.IPPool == "" { + Value: &oxide.ExternalIpCreateEphemeral{ + PoolSelector: func() oxide.PoolSelector { + if config.IPPool == "" { + return oxide.PoolSelector{ + Value: &oxide.PoolSelectorAuto{ + IpVersion: oxide.IpVersionV4, + }, + } + } + return oxide.PoolSelector{ - Type: oxide.PoolSelectorTypeAuto, - IpVersion: oxide.IpVersionV4, + Value: &oxide.PoolSelectorExplicit{ + Pool: oxide.NameOrId(config.IPPool), + }, } - } - - return oxide.PoolSelector{ - Pool: oxide.NameOrId(config.IPPool), - Type: oxide.PoolSelectorTypeExplicit, - IpVersion: oxide.IpVersionV4, - } - }(), + }(), + }, }, }, Hostname: oxide.Hostname(config.Hostname), @@ -72,18 +77,19 @@ func (o *stepInstanceCreate) Run( Name: oxide.Name(config.Name), Ncpus: oxide.InstanceCpuCount(config.CPUs), NetworkInterfaces: oxide.InstanceNetworkInterfaceAttachment{ - Type: oxide.InstanceNetworkInterfaceAttachmentTypeCreate, - Params: []oxide.InstanceNetworkInterfaceCreate{ - { - Name: oxide.Name(config.Name), - Description: "Created by Packer.", - SubnetName: oxide.Name(config.Subnet), - VpcName: oxide.Name(config.VPC), - IpConfig: oxide.PrivateIpStackCreate{ - Value: oxide.PrivateIpStackCreateV4{ - Value: oxide.PrivateIpv4StackCreate{ - Ip: oxide.Ipv4Assignment{ - Type: oxide.Ipv4AssignmentTypeAuto, + Value: &oxide.InstanceNetworkInterfaceAttachmentCreate{ + Params: []oxide.InstanceNetworkInterfaceCreate{ + { + Name: oxide.Name(config.Name), + Description: "Created by Packer.", + SubnetName: oxide.Name(config.Subnet), + VpcName: oxide.Name(config.VPC), + IpConfig: oxide.PrivateIpStackCreate{ + Value: oxide.PrivateIpStackCreateV4{ + Value: oxide.PrivateIpv4StackCreate{ + Ip: oxide.Ipv4Assignment{ + Value: &oxide.Ipv4AssignmentAuto{}, + }, }, }, }, diff --git a/component/builder/instance/step_instance_external_ip_list.go b/component/builder/instance/step_instance_external_ip_list.go index 34608dc..1ea36cb 100644 --- a/component/builder/instance/step_instance_external_ip_list.go +++ b/component/builder/instance/step_instance_external_ip_list.go @@ -45,23 +45,32 @@ func (s *stepInstanceExternalIPList) Run( return multistep.ActionHalt } - // Filter out invalid external IPs (e.g., SNAT). - validExternalIPs := make([]oxide.ExternalIp, 0, len(results.Items)) - for _, externalIP := range results.Items { - switch externalIP.Kind { - case oxide.ExternalIpKindEphemeral, oxide.ExternalIpKindFloating: - validExternalIPs = append(validExternalIPs, externalIP) + // Filter out invalid external IPs (e.g., SNAT) and extract the IP. + var externalIP string + for _, eip := range results.Items { + switch eip.Kind() { + case oxide.ExternalIpKindEphemeral: + if v, ok := eip.AsEphemeral(); ok { + externalIP = v.Ip + } + case oxide.ExternalIpKindFloating: + if v, ok := eip.AsFloating(); ok { + externalIP = v.Ip + } + } + if externalIP != "" { + break } } - if len(validExternalIPs) == 0 { + if externalIP == "" { ui.Error( "Instance does not have any valid external IPs. Packer will be unable to connect to this instance.", ) return multistep.ActionHalt } - stateBag.Put("external_ip", validExternalIPs[0].Ip) + stateBag.Put("external_ip", externalIP) return multistep.ActionContinue } diff --git a/component/data-source/image/data_source_test.go b/component/data-source/image/data_source_test.go index b14df13..cadcd64 100644 --- a/component/data-source/image/data_source_test.go +++ b/component/data-source/image/data_source_test.go @@ -186,10 +186,12 @@ func TestAccDataSource_Image(t *testing.T) { testID, ), DiskBackend: oxide.DiskBackend{ - Type: oxide.DiskBackendTypeDistributed, - DiskSource: oxide.DiskSource{ - BlockSize: 4096, - Type: oxide.DiskSourceTypeBlank, + Value: &oxide.DiskBackendDistributed{ + DiskSource: oxide.DiskSource{ + Value: &oxide.DiskSourceBlank{ + BlockSize: 4096, + }, + }, }, }, Size: 1024 * 1024 * 1024, // 1 GiB. @@ -230,8 +232,9 @@ func TestAccDataSource_Image(t *testing.T) { Os: "Blank", Version: "0.0.0", Source: oxide.ImageSource{ - Id: snapshot.Id, - Type: oxide.ImageSourceTypeSnapshot, + Value: &oxide.ImageSourceSnapshot{ + Id: snapshot.Id, + }, }, }, }) diff --git a/go.mod b/go.mod index 4809a5e..8c268ad 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/hashicorp/hcl/v2 v2.19.1 github.com/hashicorp/packer-plugin-sdk v0.6.1 github.com/mitchellh/mapstructure v1.5.0 - github.com/oxidecomputer/oxide.go v0.7.1-0.20260130172517-b8910e7a3002 + github.com/oxidecomputer/oxide.go v0.7.1-0.20260216192632-3a774965bc83 github.com/zclconf/go-cty v1.13.3 ) diff --git a/go.sum b/go.sum index 1017755..d453254 100644 --- a/go.sum +++ b/go.sum @@ -270,8 +270,8 @@ github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/ github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U= github.com/nywilken/go-cty v1.13.3 h1:03U99oXf3j3g9xgqAE3YGpixCjM8Mg09KZ0Ji9LzX0o= github.com/nywilken/go-cty v1.13.3/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= -github.com/oxidecomputer/oxide.go v0.7.1-0.20260130172517-b8910e7a3002 h1:mYQNT/LQMuWDJE35jFeR3ohY3bAH9A4x08pTiPXRND0= -github.com/oxidecomputer/oxide.go v0.7.1-0.20260130172517-b8910e7a3002/go.mod h1:ZlG5ri4a6ClA/yhDCbQN6m/F3d/m41XHx5s9WbfFLWc= +github.com/oxidecomputer/oxide.go v0.7.1-0.20260216192632-3a774965bc83 h1:oO9JyCkZHu4jX6Aqm8bn1VYz0MUEWYdqZQbAeG8C0Es= +github.com/oxidecomputer/oxide.go v0.7.1-0.20260216192632-3a774965bc83/go.mod h1:pL9BcSmHMyhR8Utxr2AcV6wG59OIrcSV3dNduIzGGdo= github.com/packer-community/winrmcp v0.0.0-20180921211025-c76d91c1e7db h1:9uViuKtx1jrlXLBW/pMnhOfzn3iSEdLase/But/IZRU= github.com/packer-community/winrmcp v0.0.0-20180921211025-c76d91c1e7db/go.mod h1:f6Izs6JvFTdnRbziASagjZ2vmf55NSIkC/weStxCHqk= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= @@ -315,9 +315,8 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= -github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -477,9 +476,8 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=