Skip to content

Commit

Permalink
chore(deps): update vendored hcloud-go to 2.0.0
Browse files Browse the repository at this point in the history
Generated by:

```
UPSTREAM_REF=v2.0.0 hack/update-vendor.sh
```
  • Loading branch information
apricote committed Jul 17, 2023
1 parent 8d39bae commit ab0096f
Show file tree
Hide file tree
Showing 55 changed files with 462 additions and 1,102 deletions.
21 changes: 21 additions & 0 deletions cluster-autoscaler/cloudprovider/hetzner/hcloud-go/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018-2020 Hetzner Cloud GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
58 changes: 12 additions & 46 deletions cluster-autoscaler/cloudprovider/hetzner/hcloud-go/hcloud/action.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package hcloud

import (
Expand All @@ -27,7 +11,7 @@ import (

// Action represents an action in the Hetzner Cloud.
type Action struct {
ID int
ID int64
Status ActionStatus
Command string
Progress int
Expand All @@ -50,7 +34,7 @@ const (

// ActionResource references other resources from an action.
type ActionResource struct {
ID int
ID int64
Type ActionResourceType
}

Expand Down Expand Up @@ -92,7 +76,7 @@ type ActionClient struct {
}

// GetByID retrieves an action by its ID. If the action does not exist, nil is returned.
func (c *ActionClient) GetByID(ctx context.Context, id int) (*Action, *Response, error) {
func (c *ActionClient) GetByID(ctx context.Context, id int64) (*Action, *Response, error) {
req, err := c.client.NewRequest(ctx, "GET", fmt.Sprintf("/actions/%d", id), nil)
if err != nil {
return nil, nil, err
Expand All @@ -112,13 +96,13 @@ func (c *ActionClient) GetByID(ctx context.Context, id int) (*Action, *Response,
// ActionListOpts specifies options for listing actions.
type ActionListOpts struct {
ListOpts
ID []int
ID []int64
Status []ActionStatus
Sort []string
}

func (l ActionListOpts) values() url.Values {
vals := l.ListOpts.values()
vals := l.ListOpts.Values()
for _, id := range l.ID {
vals.Add("id", fmt.Sprintf("%d", id))
}
Expand Down Expand Up @@ -156,30 +140,12 @@ func (c *ActionClient) List(ctx context.Context, opts ActionListOpts) ([]*Action

// All returns all actions.
func (c *ActionClient) All(ctx context.Context) ([]*Action, error) {
allActions := []*Action{}

opts := ActionListOpts{}
opts.PerPage = 50

err := c.client.all(func(page int) (*Response, error) {
opts.Page = page
actions, resp, err := c.List(ctx, opts)
if err != nil {
return resp, err
}
allActions = append(allActions, actions...)
return resp, nil
})
if err != nil {
return nil, err
}

return allActions, nil
return c.AllWithOpts(ctx, ActionListOpts{ListOpts: ListOpts{PerPage: 50}})
}

// AllWithOpts returns all actions for the given options.
func (c *ActionClient) AllWithOpts(ctx context.Context, opts ActionListOpts) ([]*Action, error) {
allActions := []*Action{}
var allActions []*Action

err := c.client.all(func(page int) (*Response, error) {
opts.Page = page
Expand Down Expand Up @@ -208,7 +174,7 @@ func (c *ActionClient) AllWithOpts(ctx context.Context, opts ActionListOpts) ([]
// complete successfully, as well as any errors that happened while
// querying the API.
//
// By default the method keeps watching until all actions have finished
// By default, the method keeps watching until all actions have finished
// processing. If you want to be able to cancel the method or configure a
// timeout, use the [context.Context]. Once the method has stopped watching,
// both returned channels are closed.
Expand All @@ -223,8 +189,8 @@ func (c *ActionClient) WatchOverallProgress(ctx context.Context, actions []*Acti
defer close(errCh)
defer close(progressCh)

successIDs := make([]int, 0, len(actions))
watchIDs := make(map[int]struct{}, len(actions))
successIDs := make([]int64, 0, len(actions))
watchIDs := make(map[int64]struct{}, len(actions))
for _, action := range actions {
watchIDs[action.ID] = struct{}{}
}
Expand Down Expand Up @@ -257,7 +223,7 @@ func (c *ActionClient) WatchOverallProgress(ctx context.Context, actions []*Acti
continue
case ActionStatusSuccess:
delete(watchIDs, a.ID)
successIDs := append(successIDs, a.ID)
successIDs = append(successIDs, a.ID)
sendProgress(progressCh, int(float64(len(actions)-len(successIDs))/float64(len(actions))*100))
case ActionStatusError:
delete(watchIDs, a.ID)
Expand Down Expand Up @@ -285,7 +251,7 @@ func (c *ActionClient) WatchOverallProgress(ctx context.Context, actions []*Acti
// API, as well as the error of the action if it did not complete
// successfully, or nil if it did.
//
// By default the method keeps watching until the action has finished
// By default, the method keeps watching until the action has finished
// processing. If you want to be able to cancel the method or configure a
// timeout, use the [context.Context]. Once the method has stopped watching,
// both returned channels are closed.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package hcloud

// Architecture specifies the architecture of the CPU.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package hcloud

import (
Expand Down Expand Up @@ -66,7 +50,7 @@ const (

// CertificateUsedByRef points to a resource that uses this certificate.
type CertificateUsedByRef struct {
ID int
ID int64
Type CertificateUsedByRefType
}

Expand All @@ -84,9 +68,9 @@ func (st *CertificateStatus) IsFailed() bool {
return st.Issuance == CertificateStatusTypeFailed || st.Renewal == CertificateStatusTypeFailed
}

// Certificate represents an certificate in the Hetzner Cloud.
// Certificate represents a certificate in the Hetzner Cloud.
type Certificate struct {
ID int
ID int64
Name string
Labels map[string]string
Type CertificateType
Expand All @@ -112,7 +96,7 @@ type CertificateClient struct {
}

// GetByID retrieves a Certificate by its ID. If the Certificate does not exist, nil is returned.
func (c *CertificateClient) GetByID(ctx context.Context, id int) (*Certificate, *Response, error) {
func (c *CertificateClient) GetByID(ctx context.Context, id int64) (*Certificate, *Response, error) {
req, err := c.client.NewRequest(ctx, "GET", fmt.Sprintf("/certificates/%d", id), nil)
if err != nil {
return nil, nil, err
Expand Down Expand Up @@ -144,8 +128,8 @@ func (c *CertificateClient) GetByName(ctx context.Context, name string) (*Certif
// Get retrieves a Certificate by its ID if the input can be parsed as an integer, otherwise it
// retrieves a Certificate by its name. If the Certificate does not exist, nil is returned.
func (c *CertificateClient) Get(ctx context.Context, idOrName string) (*Certificate, *Response, error) {
if id, err := strconv.Atoi(idOrName); err == nil {
return c.GetByID(ctx, int(id))
if id, err := strconv.ParseInt(idOrName, 10, 64); err == nil {
return c.GetByID(ctx, id)
}
return c.GetByName(ctx, idOrName)
}
Expand All @@ -158,7 +142,7 @@ type CertificateListOpts struct {
}

func (l CertificateListOpts) values() url.Values {
vals := l.ListOpts.values()
vals := l.ListOpts.Values()
if l.Name != "" {
vals.Add("name", l.Name)
}
Expand Down Expand Up @@ -193,25 +177,7 @@ func (c *CertificateClient) List(ctx context.Context, opts CertificateListOpts)

// All returns all Certificates.
func (c *CertificateClient) All(ctx context.Context) ([]*Certificate, error) {
allCertificates := []*Certificate{}

opts := CertificateListOpts{}
opts.PerPage = 50

err := c.client.all(func(page int) (*Response, error) {
opts.Page = page
Certificate, resp, err := c.List(ctx, opts)
if err != nil {
return resp, err
}
allCertificates = append(allCertificates, Certificate...)
return resp, nil
})
if err != nil {
return nil, err
}

return allCertificates, nil
return c.AllWithOpts(ctx, CertificateListOpts{ListOpts: ListOpts{PerPage: 50}})
}

// AllWithOpts returns all Certificates for the given options.
Expand Down Expand Up @@ -276,7 +242,7 @@ func (o CertificateCreateOpts) validateUploaded() error {
return nil
}

// Create creates a new certificate uploaded certificate.
// Create creates a new uploaded certificate.
//
// Create returns an error for certificates of any other type. Use
// CreateCertificate to create such certificates.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package hcloud

import (
Expand Down Expand Up @@ -461,7 +445,8 @@ type ListOpts struct {
LabelSelector string // Label selector for filtering by labels
}

func (l ListOpts) values() url.Values {
// Values returns the ListOpts as URL values.
func (l ListOpts) Values() url.Values {
vals := url.Values{}
if l.Page > 0 {
vals.Add("page", strconv.Itoa(l.Page))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package hcloud

import (
Expand All @@ -27,7 +11,7 @@ import (

// Datacenter represents a datacenter in the Hetzner Cloud.
type Datacenter struct {
ID int
ID int64
Name string
Description string
Location *Location
Expand All @@ -46,7 +30,7 @@ type DatacenterClient struct {
}

// GetByID retrieves a datacenter by its ID. If the datacenter does not exist, nil is returned.
func (c *DatacenterClient) GetByID(ctx context.Context, id int) (*Datacenter, *Response, error) {
func (c *DatacenterClient) GetByID(ctx context.Context, id int64) (*Datacenter, *Response, error) {
req, err := c.client.NewRequest(ctx, "GET", fmt.Sprintf("/datacenters/%d", id), nil)
if err != nil {
return nil, nil, err
Expand All @@ -63,7 +47,7 @@ func (c *DatacenterClient) GetByID(ctx context.Context, id int) (*Datacenter, *R
return DatacenterFromSchema(body.Datacenter), resp, nil
}

// GetByName retrieves an datacenter by its name. If the datacenter does not exist, nil is returned.
// GetByName retrieves a datacenter by its name. If the datacenter does not exist, nil is returned.
func (c *DatacenterClient) GetByName(ctx context.Context, name string) (*Datacenter, *Response, error) {
if name == "" {
return nil, nil, nil
Expand All @@ -78,8 +62,8 @@ func (c *DatacenterClient) GetByName(ctx context.Context, name string) (*Datacen
// Get retrieves a datacenter by its ID if the input can be parsed as an integer, otherwise it
// retrieves a datacenter by its name. If the datacenter does not exist, nil is returned.
func (c *DatacenterClient) Get(ctx context.Context, idOrName string) (*Datacenter, *Response, error) {
if id, err := strconv.Atoi(idOrName); err == nil {
return c.GetByID(ctx, int(id))
if id, err := strconv.ParseInt(idOrName, 10, 64); err == nil {
return c.GetByID(ctx, id)
}
return c.GetByName(ctx, idOrName)
}
Expand All @@ -92,7 +76,7 @@ type DatacenterListOpts struct {
}

func (l DatacenterListOpts) values() url.Values {
vals := l.ListOpts.values()
vals := l.ListOpts.Values()
if l.Name != "" {
vals.Add("name", l.Name)
}
Expand Down Expand Up @@ -127,10 +111,12 @@ func (c *DatacenterClient) List(ctx context.Context, opts DatacenterListOpts) ([

// All returns all datacenters.
func (c *DatacenterClient) All(ctx context.Context) ([]*Datacenter, error) {
allDatacenters := []*Datacenter{}
return c.AllWithOpts(ctx, DatacenterListOpts{ListOpts: ListOpts{PerPage: 50}})
}

opts := DatacenterListOpts{}
opts.PerPage = 50
// AllWithOpts returns all datacenters for the given options.
func (c *DatacenterClient) AllWithOpts(ctx context.Context, opts DatacenterListOpts) ([]*Datacenter, error) {
var allDatacenters []*Datacenter

err := c.client.all(func(page int) (*Response, error) {
opts.Page = page
Expand Down
Loading

0 comments on commit ab0096f

Please sign in to comment.