From 1ffdcf503c7e6a9ad44a898b50e385517061b6dd Mon Sep 17 00:00:00 2001 From: samcday Date: Thu, 16 Feb 2023 11:43:07 +0100 Subject: [PATCH] chore: remove unused hcapi.DataCenterClient (#443) --- internal/hcapi/datacenter.go | 32 -------------------------------- internal/state/helpers.go | 8 -------- internal/state/state.go | 1 - 3 files changed, 41 deletions(-) delete mode 100644 internal/hcapi/datacenter.go diff --git a/internal/hcapi/datacenter.go b/internal/hcapi/datacenter.go deleted file mode 100644 index fe1a59af..00000000 --- a/internal/hcapi/datacenter.go +++ /dev/null @@ -1,32 +0,0 @@ -package hcapi - -import ( - "context" - "strconv" - - "github.com/hetznercloud/hcloud-go/hcloud" -) - -// DataCenterClient embeds the Hetzner Cloud DataCenter client and provides some -// additional helper functions. -type DataCenterClient struct { - *hcloud.DatacenterClient -} - -// DataCenterNames obtains a list of available data centers. It returns nil if -// data center names could not be fetched. -func (c *DataCenterClient) DataCenterNames() []string { - dcs, err := c.All(context.Background()) - if err != nil || len(dcs) == 0 { - return nil - } - names := make([]string, len(dcs)) - for i, dc := range dcs { - name := dc.Name - if name == "" { - name = strconv.Itoa(dc.ID) - } - names[i] = name - } - return names -} diff --git a/internal/state/helpers.go b/internal/state/helpers.go index 62096231..df2f53c0 100644 --- a/internal/state/helpers.go +++ b/internal/state/helpers.go @@ -127,14 +127,6 @@ func (c *State) NetworkZoneNames() []string { return c.locationClient.NetworkZoneNames() } -func (c *State) DataCenterNames() []string { - if c.dataCenterClient == nil { - client := c.Client() - c.dataCenterClient = &hcapi.DataCenterClient{DatacenterClient: &client.Datacenter} - } - return c.dataCenterClient.DataCenterNames() -} - func (c *State) SSHKeyNames() []string { if c.sshKeyClient == nil { client := c.Client() diff --git a/internal/state/state.go b/internal/state/state.go index f1cee01a..a84936a2 100644 --- a/internal/state/state.go +++ b/internal/state/state.go @@ -25,7 +25,6 @@ type State struct { isoClient *hcapi.ISOClient imageClient *hcapi.ImageClient locationClient *hcapi.LocationClient - dataCenterClient *hcapi.DataCenterClient sshKeyClient *hcapi.SSHKeyClient volumeClient *hcapi.VolumeClient floatingIPClient *hcapi.FloatingIPClient