Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #283 from packethost/packngo-0.5.0
Browse files Browse the repository at this point in the history
packngo v0.5.0
  • Loading branch information
displague authored Nov 11, 2020
2 parents a54939e + 5888173 commit f61f79d
Show file tree
Hide file tree
Showing 13 changed files with 236 additions and 155 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
## 3.1.0 (Unreleased)

BREAKING CHANGES:
- packngo updated to v0.4.1, changing the API endpoint from api.packet.net to api.equinix.com/metal/v1
- packngo updated to v0.4.1+, changing the API endpoint from api.packet.net to api.equinix.com/metal/v1

FEATURES:
- [#249](https://github.com/packethost/terraform-provider-packet/pull/249) New datasource `packet_project_ssh_key`

IMPROVEMENTS:
- `packet_device` datasource should query by hostname much faster
- `packet_device_network_type` conversions should be more reliable
- Test sweeper added for SSH keys
- Acceptance testing moved to Github Actions
- Improved logging when resources are not found and removed from state
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/hashicorp/go-retryablehttp v0.6.6
github.com/hashicorp/terraform-plugin-sdk v1.0.0
github.com/mattn/go-colorable v0.1.1 // indirect
github.com/packethost/packngo v0.4.1
github.com/packethost/packngo v0.5.0
github.com/vmihailenco/msgpack v4.0.1+incompatible // indirect
golang.org/x/net v0.0.0-20200822124328-c89045814202 // indirect
gopkg.in/yaml.v2 v2.2.8 // indirect
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,8 @@ github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQ
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/packethost/packngo v0.3.0 h1:mE5UHyhr5sKN1Qa0GtExRG9ECUX/muazI0f53gSrt5E=
github.com/packethost/packngo v0.3.0/go.mod h1:aRxUEV1TprXVcWr35v8tNYgZMjv7FHaInXx224vF2fc=
github.com/packethost/packngo v0.4.1 h1:HWeO3y3xvGIhdaW15VLz7uswKE27YRvXtONDjcMqvqk=
github.com/packethost/packngo v0.4.1/go.mod h1:aRxUEV1TprXVcWr35v8tNYgZMjv7FHaInXx224vF2fc=
github.com/packethost/packngo v0.5.0 h1:WGpfeRMstPqgyXGUXl6b9xFsbUudXU3p0+JlYri290U=
github.com/packethost/packngo v0.5.0/go.mod h1:aRxUEV1TprXVcWr35v8tNYgZMjv7FHaInXx224vF2fc=
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down
9 changes: 3 additions & 6 deletions packet/datasource_packet_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func dataSourcePacketDeviceRead(d *schema.ResourceData, meta interface{}) error
hostname := hostnameRaw.(string)
projectId := projectIdRaw.(string)

ds, _, err := client.Devices.List(projectId, nil)
ds, _, err := client.Devices.List(projectId, &packngo.ListOptions{Search: hostname})
if err != nil {
return err
}
Expand Down Expand Up @@ -225,18 +225,15 @@ func dataSourcePacketDeviceRead(d *schema.ResourceData, meta interface{}) error

storageString, err := structure.NormalizeJsonString(string(rawStorageBytes))
if err != nil {
return fmt.Errorf("[ERR] Errori normalizing storage JSON string for device (%s): %s", d.Id(), err)
return fmt.Errorf("[ERR] Error normalizing storage JSON string for device (%s): %s", d.Id(), err)
}
d.Set("storage", storageString)
}

if len(device.HardwareReservation.Href) > 0 {
d.Set("hardware_reservation_id", path.Base(device.HardwareReservation.Href))
}
networkType, err := device.GetNetworkType()
if err != nil {
return err
}
networkType := device.GetNetworkType()

d.Set("network_type", networkType)

Expand Down
5 changes: 1 addition & 4 deletions packet/helpers_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,7 @@ func waitForDeviceAttribute(d *schema.ResourceData, targets []string, pending []
if err == nil {
retAttrVal := device.State
if attribute == "network_type" {
networkType, nterr := device.GetNetworkType()
if nterr != nil {
return "error", "error", nterr
}
networkType := device.GetNetworkType()
retAttrVal = networkType
}
return retAttrVal, retAttrVal, nil
Expand Down
5 changes: 1 addition & 4 deletions packet/resource_packet_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,10 +465,7 @@ func resourcePacketDeviceRead(d *schema.ResourceData, meta interface{}) error {
if len(device.HardwareReservation.Href) > 0 {
d.Set("hardware_reservation_id", path.Base(device.HardwareReservation.Href))
}
networkType, err := device.GetNetworkType()
if err != nil {
return err
}
networkType := device.GetNetworkType()
d.Set("network_type", networkType)

wfrd := "wait_for_reservation_deprovision"
Expand Down
6 changes: 2 additions & 4 deletions packet/resource_packet_device_network_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ func getDevIDandNetworkType(d *schema.ResourceData, c *packngo.Client) (string,
if err != nil {
return "", "", err
}
devType, err := dev.GetNetworkType()
if err != nil {
return "", "", err
}
devType := dev.GetNetworkType()

return dev.ID, devType, nil
}

Expand Down
2 changes: 1 addition & 1 deletion vendor/github.com/packethost/packngo/Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/github.com/packethost/packngo/OWNERS.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

86 changes: 67 additions & 19 deletions vendor/github.com/packethost/packngo/devices.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 53 additions & 12 deletions vendor/github.com/packethost/packngo/packngo.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f61f79d

Please sign in to comment.