From e314bdd63bbc080d1205616a8774b08b6e09048f Mon Sep 17 00:00:00 2001 From: "Alex Ellis (OpenFaaS Ltd)" Date: Wed, 12 Jun 2024 13:04:39 +0100 Subject: [PATCH] Remove Civo and Equinix Metal Signed-off-by: Alex Ellis (OpenFaaS Ltd) --- cmd/go.mod | 72 +++++++++- go.mod | 5 +- go.sum | 7 - provision/civo.go | 267 ------------------------------------- provision/equinix_metal.go | 128 ------------------ 5 files changed, 72 insertions(+), 407 deletions(-) delete mode 100644 provision/civo.go delete mode 100644 provision/equinix_metal.go diff --git a/cmd/go.mod b/cmd/go.mod index c65e386..cd5ce0c 100644 --- a/cmd/go.mod +++ b/cmd/go.mod @@ -1,7 +1,75 @@ module github.com/inlets/cloud-provision/cmd -go 1.16 +go 1.22 -// replace github.com/inlets/cloud-provision/provision => ../ +replace github.com/inlets/cloud-provision/provision => ../ require github.com/inlets/cloud-provision v0.5.5 + +require ( + cloud.google.com/go v0.49.0 // indirect + github.com/Azure/azure-sdk-for-go v39.0.0+incompatible // indirect + github.com/Azure/go-autorest/autorest v0.9.5 // indirect + github.com/Azure/go-autorest/autorest/adal v0.8.2 // indirect + github.com/Azure/go-autorest/autorest/azure/auth v0.4.2 // indirect + github.com/Azure/go-autorest/autorest/azure/cli v0.3.1 // indirect + github.com/Azure/go-autorest/autorest/date v0.2.0 // indirect + github.com/Azure/go-autorest/autorest/to v0.3.0 // indirect + github.com/Azure/go-autorest/autorest/validation v0.2.0 // indirect + github.com/Azure/go-autorest/logger v0.1.0 // indirect + github.com/Azure/go-autorest/tracing v0.5.0 // indirect + github.com/aws/aws-sdk-go v1.26.8 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect + github.com/digitalocean/godo v1.54.0 // indirect + github.com/dimchansky/utfbom v1.1.0 // indirect + github.com/dirien/ovh-go-sdk v0.1.1 // indirect + github.com/go-resty/resty/v2 v2.1.1-0.20191201195748-d7b97669fe48 // indirect + github.com/gogo/protobuf v1.3.1 // indirect + github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9 // indirect + github.com/golang/mock v1.3.1 // indirect + github.com/golang/protobuf v1.3.5 // indirect + github.com/google/go-querystring v1.1.0 // indirect + github.com/google/gofuzz v1.1.0 // indirect + github.com/google/uuid v1.1.1 // indirect + github.com/googleapis/gax-go/v2 v2.0.5 // indirect + github.com/googleapis/gnostic v0.1.0 // indirect + github.com/hashicorp/go-cleanhttp v0.5.1 // indirect + github.com/hashicorp/go-retryablehttp v0.7.0 // indirect + github.com/hetznercloud/hcloud-go v1.18.2 // indirect + github.com/imdario/mergo v0.3.5 // indirect + github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af // indirect + github.com/json-iterator/go v1.1.8 // indirect + github.com/linode/linodego v0.19.0 // indirect + github.com/mitchellh/go-homedir v1.1.0 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.1 // indirect + github.com/ovh/go-ovh v1.1.0 // indirect + github.com/packethost/packngo v0.17.0 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/scaleway/scaleway-sdk-go v1.0.0-beta.4 // indirect + github.com/sethvargo/go-password v0.2.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect + github.com/vultr/govultr/v2 v2.7.1 // indirect + go.opencensus.io v0.22.2 // indirect + golang.org/x/crypto v0.0.0-20200420201142-3c4aac89819a // indirect + golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e // indirect + golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect + golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd // indirect + golang.org/x/text v0.3.2 // indirect + golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect + google.golang.org/api v0.14.0 // indirect + google.golang.org/appengine v1.6.5 // indirect + google.golang.org/genproto v0.0.0-20191115221424-83cc0476cb11 // indirect + google.golang.org/grpc v1.25.1 // indirect + gopkg.in/inf.v0 v0.9.1 // indirect + gopkg.in/ini.v1 v1.57.0 // indirect + gopkg.in/yaml.v2 v2.2.8 // indirect + k8s.io/api v0.18.3 // indirect + k8s.io/apimachinery v0.18.3 // indirect + k8s.io/client-go v0.18.3 // indirect + k8s.io/klog v1.0.0 // indirect + k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89 // indirect + sigs.k8s.io/structured-merge-diff/v3 v3.0.0 // indirect + sigs.k8s.io/yaml v1.2.0 // indirect +) diff --git a/go.mod b/go.mod index 5140738..323ac74 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/inlets/cloud-provision -go 1.21 +go 1.22 require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.1.3 @@ -14,10 +14,8 @@ require ( github.com/dirien/ovh-go-sdk v0.2.0 github.com/golang/mock v1.6.0 github.com/google/uuid v1.5.0 - github.com/hashicorp/go-retryablehttp v0.7.5 github.com/hetznercloud/hcloud-go v1.39.0 github.com/linode/linodego v1.12.0 - github.com/packethost/packngo v0.29.0 github.com/scaleway/scaleway-sdk-go v1.0.0-beta.12 github.com/sethvargo/go-password v0.2.0 github.com/vultr/govultr/v2 v2.17.2 @@ -44,6 +42,7 @@ require ( github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect github.com/googleapis/gax-go/v2 v2.12.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect + github.com/hashicorp/go-retryablehttp v0.7.5 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/kr/text v0.2.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect diff --git a/go.sum b/go.sum index 59df93b..8317705 100644 --- a/go.sum +++ b/go.sum @@ -39,7 +39,6 @@ github.com/dimchansky/utfbom v1.1.1 h1:vV6w1AhK4VMnhBno/TPVCoK9U/LP0PkLCS9tbxHdi github.com/dimchansky/utfbom v1.1.1/go.mod h1:SxdoEBH5qIqFocHMyGOXVAybYJdr71b1Q/j0mACtrfE= github.com/dirien/ovh-go-sdk v0.2.0 h1:hIL39yxXnUNEUw1gn3g2cA9QKj2cHdbbowAyq8tHug4= github.com/dirien/ovh-go-sdk v0.2.0/go.mod h1:kz6dmFoAym8NbdVTdGRzQuTGfRNoMrSuevxvxxBPVjA= -github.com/dnaeon/go-vcr v1.0.1/go.mod h1:aBB1+wY4s93YsC3HHjMBMrwTj2R9FHDzUr9KyGc8n1E= github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -88,7 +87,6 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= @@ -130,8 +128,6 @@ github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQth github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= github.com/ovh/go-ovh v1.3.0 h1:mvZaddk4E4kLcXhzb+cxBsMPYp2pHqiQpWYkInsuZPQ= github.com/ovh/go-ovh v1.3.0/go.mod h1:AxitLZ5HBRPyUd+Zl60Ajaag+rNTdVXWIkzfrVuTXWA= -github.com/packethost/packngo v0.29.0 h1:gRIhciVZQ/zLNrIdIdbOUyB/Tw5IgoaXyhP4bvE+D2s= -github.com/packethost/packngo v0.29.0/go.mod h1:/UHguFdPs6Lf6FOkkSEPnRY5tgS0fsVM+Zv/bvBrmt0= github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -159,7 +155,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= @@ -181,7 +176,6 @@ go.opentelemetry.io/otel/trace v1.21.0 h1:WD9i5gzvoUPuXIXH24ZNBudiarZDKuekPqi/E8 go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200420201142-3c4aac89819a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= @@ -292,7 +286,6 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EV gopkg.in/ini.v1 v1.57.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.66.6 h1:LATuAqN/shcYAOkv3wl2L4rkaKqkcgTBQjOyYDvcPKI= gopkg.in/ini.v1 v1.66.6/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 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= diff --git a/provision/civo.go b/provision/civo.go deleted file mode 100644 index 4763c13..0000000 --- a/provision/civo.go +++ /dev/null @@ -1,267 +0,0 @@ -// Copyright (c) Inlets Author(s) 2019. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -package provision - -import ( - "encoding/json" - "errors" - "fmt" - "io" - "io/ioutil" - "log" - "net/http" - "net/url" - - "strings" - "time" -) - -// CivoProvisioner creates instances on civo.com -type CivoProvisioner struct { - APIKey string -} - -// Network represents a network for civo vm instances to connect to -type Network struct { - ID string `json:"id"` - Name string `json:"name,omitempty"` - Default bool `json:"default,omitempty"` - CIDR string `json:"cidr,omitempty"` - Label string `json:"label,omitempty"` -} - -// NewCivoProvisioner with an accessKey -func NewCivoProvisioner(accessKey string) (*CivoProvisioner, error) { - return &CivoProvisioner{ - APIKey: accessKey, - }, nil -} - -// Status gets the status of the exit node -func (p *CivoProvisioner) Status(id string) (*ProvisionedHost, error) { - host := &ProvisionedHost{} - - apiURL := fmt.Sprint("https://api.civo.com/v2/instances/", id) - - req, err := http.NewRequest(http.MethodGet, apiURL, nil) - if err != nil { - return host, err - } - addAuth(req, p.APIKey) - - req.Header.Add("Accept", "application/json") - instance := createdInstance{} - - res, err := http.DefaultClient.Do(req) - if err != nil { - return host, err - } - - var body []byte - if res.Body != nil { - defer res.Body.Close() - body, _ = ioutil.ReadAll(res.Body) - } - - if res.StatusCode != http.StatusOK { - return host, fmt.Errorf("unexpected HTTP code: %d\n%q", res.StatusCode, string(body)) - } - - unmarshalErr := json.Unmarshal(body, &instance) - if unmarshalErr != nil { - return host, unmarshalErr - } - - return &ProvisionedHost{ - ID: instance.ID, - IP: instance.PublicIP, - Status: strings.ToLower(instance.Status), - }, nil -} - -// Delete terminates the exit node -func (p *CivoProvisioner) Delete(request HostDeleteRequest) error { - var id string - var err error - if len(request.ID) > 0 { - id = request.ID - } else { - id, err = p.lookupID(request) - if err != nil { - return err - } - } - - apiURL := fmt.Sprint("https://api.civo.com/v2/instances/", id) - _, err = apiCall(p.APIKey, http.MethodDelete, apiURL, nil) - if err != nil { - return err - } - return nil -} - -// Provision creates a new exit node -func (p *CivoProvisioner) Provision(host BasicHost) (*ProvisionedHost, error) { - - log.Printf("Provisioning host with Civo\n") - - if host.Region == "" { - host.Region = "lon1" - } - - res, err := provisionCivoInstance(host, p.APIKey) - - if err != nil { - return nil, err - } - - return &ProvisionedHost{ - ID: res.ID, - }, nil -} - -// List returns a list of exit nodes -func (p *CivoProvisioner) List(filter ListFilter) ([]*ProvisionedHost, error) { - var inlets []*ProvisionedHost - apiURL := fmt.Sprintf("https://api.civo.com/v2/instances/?tags=%s", filter.Filter) - body, err := apiCall(p.APIKey, http.MethodGet, apiURL, nil) - if err != nil { - return inlets, err - } - - var resp apiResponse - unmarshalErr := json.Unmarshal(body, &resp) - if unmarshalErr != nil { - return inlets, unmarshalErr - } - - for _, instance := range resp.Items { - host := &ProvisionedHost{ - IP: instance.PublicIP, - ID: instance.ID, - Status: instance.Status, - } - inlets = append(inlets, host) - } - return inlets, nil -} - -func (p *CivoProvisioner) lookupID(request HostDeleteRequest) (string, error) { - inlets, err := p.List(ListFilter{Filter: "inlets"}) - if err != nil { - return "", err - } - for _, inlet := range inlets { - if inlet.IP == request.IP { - return inlet.ID, nil - } - } - return "", fmt.Errorf("no host with ip: %s", request.IP) -} - -// gets the default network for the selected region. -func getDefaultNetwork(key, region string) (*Network, error) { - apiURL := "https://api.civo.com/v2/networks" - values := url.Values{} - values.Add("region", region) - body, err := apiCall(key, http.MethodGet, apiURL, strings.NewReader(values.Encode())) - if err != nil { - return nil, err - } - - networks := []Network{} - if err := json.Unmarshal(body, &networks); err != nil { - return nil, err - } - - for _, network := range networks { - if network.Default { - return &network, nil - } - } - return nil, errors.New("no default network found") -} - -func provisionCivoInstance(host BasicHost, key string) (createdInstance, error) { - instance := createdInstance{} - - network, err := getDefaultNetwork(key, host.Region) - if err != nil { - return instance, err - } - - apiURL := "https://api.civo.com/v2/instances" - - values := url.Values{} - values.Add("hostname", host.Name) - values.Add("size", host.Plan) - values.Add("public_ip", "create") - values.Add("template_id", host.OS) - values.Add("initial_user", "civo") - values.Add("script", host.UserData) - values.Add("region", host.Region) - values.Add("network_id", network.ID) - values.Add("tags", "inlets") - - body, err := apiCall(key, http.MethodPost, apiURL, strings.NewReader(values.Encode())) - if err != nil { - return instance, err - } - - unmarshalErr := json.Unmarshal(body, &instance) - if unmarshalErr != nil { - return instance, unmarshalErr - } - - fmt.Printf("Instance ID: %s\n", instance.ID) - return instance, nil -} - -func apiCall(key, method, url string, requestBody io.Reader) ([]byte, error) { - - req, err := http.NewRequest(method, url, requestBody) - if err != nil { - return nil, err - } - addAuth(req, key) - - req.Header.Add("Accept", "application/json") - req.Header.Add("Content-Type", "application/x-www-form-urlencoded") - - res, err := http.DefaultClient.Do(req) - if err != nil { - return nil, err - } - - var body []byte - if res.Body != nil { - defer res.Body.Close() - body, err = ioutil.ReadAll(res.Body) - if err != nil { - return nil, err - } - } - - if res.StatusCode != http.StatusOK { - return nil, fmt.Errorf("unexpected HTTP code: %d\n%q", res.StatusCode, string(body)) - } - - return body, nil -} - -type apiResponse struct { - Items []createdInstance `json:"items"` -} - -type createdInstance struct { - ID string `json:"id"` - CreatedAt time.Time `json:"created_at"` - PublicIP string `json:"public_ip"` - Status string `json:"status"` -} - -func addAuth(r *http.Request, APIKey string) { - r.Header.Add("Authorization", fmt.Sprintf("bearer %s", APIKey)) - r.Header.Add("User-Agent", "inlets") -} diff --git a/provision/equinix_metal.go b/provision/equinix_metal.go deleted file mode 100644 index b9ce232..0000000 --- a/provision/equinix_metal.go +++ /dev/null @@ -1,128 +0,0 @@ -package provision - -import ( - "fmt" - - "github.com/hashicorp/go-retryablehttp" - "github.com/packethost/packngo" -) - -// EquinixMetalProvisioner provisions a host to Equinix Metal -type EquinixMetalProvisioner struct { - client *packngo.Client -} - -// NewEquinixMetalProvisioner create a EquinixMetalProvisioner with an accessKey -func NewEquinixMetalProvisioner(accessKey string) (*EquinixMetalProvisioner, error) { - httpClient := retryablehttp.NewClient() - - return &EquinixMetalProvisioner{ - client: packngo.NewClientWithAuth("", accessKey, httpClient.HTTPClient), - }, nil -} - -// Status returns the IP, ID and Status of the exit node -func (p *EquinixMetalProvisioner) Status(id string) (*ProvisionedHost, error) { - device, _, err := p.client.Devices.Get(id, nil) - - if err != nil { - return nil, err - } - - state := device.State - - ip := "" - for _, network := range device.Network { - if network.Public { - ip = network.IpAddressCommon.Address - break - } - } - - return &ProvisionedHost{ - ID: device.ID, - Status: state, - IP: ip, - }, nil -} - -// Delete terminates the exit node -func (p *EquinixMetalProvisioner) Delete(request HostDeleteRequest) error { - var id string - var err error - if len(request.ID) > 0 { - id = request.ID - } else { - id, err = p.lookupID(request) - if err != nil { - return err - } - } - force := true - _, err = p.client.Devices.Delete(id, force) - return err -} - -// Provision a host -func (p *EquinixMetalProvisioner) Provision(host BasicHost) (*ProvisionedHost, error) { - if host.Region == "" { - host.Region = "am6" - } - createReq := &packngo.DeviceCreateRequest{ - Plan: host.Plan, - Facility: []string{host.Region}, - Hostname: host.Name, - ProjectID: host.Additional["project_id"], - SpotInstance: false, - OS: host.OS, - BillingCycle: "hourly", - UserData: host.UserData, - Tags: []string{"inlets"}, - NoSSHKeys: true, - } - - device, _, err := p.client.Devices.Create(createReq) - - if err != nil { - return nil, err - } - - return &ProvisionedHost{ - ID: device.ID, - }, nil -} - -// List returns a list of exit nodes -func (p *EquinixMetalProvisioner) List(filter ListFilter) ([]*ProvisionedHost, error) { - var inlets []*ProvisionedHost - devices, _, err := p.client.Devices.List(filter.ProjectID, nil) - if err != nil { - return nil, err - } - for _, device := range devices { - for _, tag := range device.Tags { - if tag == filter.Filter { - net := device.GetNetworkInfo() - host := &ProvisionedHost{ - IP: net.PublicIPv4, - ID: device.ID, - } - inlets = append(inlets, host) - } - } - } - return inlets, nil -} - -func (p *EquinixMetalProvisioner) lookupID(request HostDeleteRequest) (string, error) { - inlets, err := p.List(ListFilter{Filter: "inlets", ProjectID: request.ProjectID}) - if err != nil { - return "", err - } - for _, inlet := range inlets { - if inlet.IP == request.IP { - return inlet.ID, nil - } - } - return "", fmt.Errorf("no host with ip: %s", request.IP) -}