diff --git a/go.mod b/go.mod index c6c056f5a8fc92bdc29b9dbf5dc42a47b14338ec..eef435a896102fa60454eef829991c607cd09b3c 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/hetznercloud/hcloud-cloud-controller-manager go 1.20 require ( - github.com/hetznercloud/hcloud-go v1.46.1 + github.com/hetznercloud/hcloud-go/v2 v2.0.0 github.com/prometheus/client_golang v1.16.0 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.8.4 @@ -82,13 +82,13 @@ require ( go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.19.0 // indirect - golang.org/x/crypto v0.10.0 // indirect - golang.org/x/net v0.11.0 // indirect + golang.org/x/crypto v0.11.0 // indirect + golang.org/x/net v0.12.0 // indirect golang.org/x/oauth2 v0.5.0 // indirect golang.org/x/sync v0.2.0 // indirect - golang.org/x/sys v0.9.0 // indirect - golang.org/x/term v0.9.0 // indirect - golang.org/x/text v0.10.0 // indirect + golang.org/x/sys v0.10.0 // indirect + golang.org/x/term v0.10.0 // indirect + golang.org/x/text v0.11.0 // indirect golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20221202195650-67e5cbc046fd // indirect diff --git a/go.sum b/go.sum index 7295f53f31a03c4bd31b7e42b6b3432a085caee0..abeae176d7a0b4e0585de5a458a9a503c2875a2d 100644 --- a/go.sum +++ b/go.sum @@ -201,10 +201,8 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 h1:BZHcxBETFHIdVyhyEfOvn/RdU/QG github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4ZsPv9hVvWI6+ch50m39Pf2Ks= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hetznercloud/hcloud-go v1.45.1 h1:nl0OOklFfQT5J6AaNIOhl5Ruh3fhmGmhvZEqHbibVuk= -github.com/hetznercloud/hcloud-go v1.45.1/go.mod h1:aAUGxSfSnB8/lVXHNEDxtCT1jykaul8kqjD7f5KQXF8= -github.com/hetznercloud/hcloud-go v1.46.1 h1:uX5SC+tnwy+0ouCkgravx8oIrddRFsJdUkQBxZk/tCQ= -github.com/hetznercloud/hcloud-go v1.46.1/go.mod h1:aQ19P39nEahvh4kQgyCgYUaglFGMe5KJO7sI418YdFI= +github.com/hetznercloud/hcloud-go/v2 v2.0.0 h1:Sg1DJ+MAKvbYAqaBaq9tPbwXBS2ckPIaMtVdUjKu+4g= +github.com/hetznercloud/hcloud-go/v2 v2.0.0/go.mod h1:4iUG2NG8b61IAwNx6UsMWQ6IfIf/i1RsG0BbsKAyR5Q= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28= github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= @@ -260,7 +258,7 @@ github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+Pymzi github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/soheilhy/cmux v0.1.5 h1:jjzc5WVemNEDTLwv9tlmemhC73tI08BNOIGwBOo10Js= @@ -340,10 +338,8 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= -golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= -golang.org/x/crypto v0.10.0 h1:LKqV2xt9+kDzSTfOhx4FrkEBcMrAgHSYgzywV9zcGmM= -golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= +golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= +golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -402,10 +398,8 @@ golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU= -golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= +golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= +golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -456,25 +450,19 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= -golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= +golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols= -golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= -golang.org/x/term v0.9.0 h1:GRRCnKYhdQrD8kfRAdQ6Zcw1P0OcELxGLKJvtjVMZ28= -golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo= +golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c= +golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58= -golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= +golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/hcloud/cloud.go b/hcloud/cloud.go index d5b4d06ecd9559a4d56eb071d85e5ca89ab0c143..f427db683eecc1eaa28287af963c000bbbb3039d 100644 --- a/hcloud/cloud.go +++ b/hcloud/cloud.go @@ -30,8 +30,8 @@ import ( "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/hcops" "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/metrics" - "github.com/hetznercloud/hcloud-go/hcloud" - "github.com/hetznercloud/hcloud-go/hcloud/metadata" + "github.com/hetznercloud/hcloud-go/v2/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud/metadata" ) const ( @@ -63,7 +63,7 @@ type cloud struct { instances *instances routes *routes loadBalancer *loadBalancers - networkID int + networkID int64 } func newCloud(_ io.Reader) (cloudprovider.Interface, error) { @@ -103,7 +103,7 @@ func newCloud(_ io.Reader) (cloudprovider.Interface, error) { client := hcloud.NewClient(opts...) metadataClient := metadata.NewClient() - var networkID int + var networkID int64 if v, ok := os.LookupEnv(hcloudNetworkENVVar); ok { n, _, err := client.Network.Get(context.Background(), v) if err != nil { @@ -253,7 +253,7 @@ func loadBalancerDefaultsFromEnv() (hcops.LoadBalancerDefaults, bool, bool, erro // serverIsAttachedToNetwork checks if the server where the master is running on is attached to the configured private network // We use this measurement to protect users against some parts of misconfiguration, like configuring a master in a not attached // network. -func serverIsAttachedToNetwork(metadataClient *metadata.Client, networkID int) (bool, error) { +func serverIsAttachedToNetwork(metadataClient *metadata.Client, networkID int64) (bool, error) { const op = "serverIsAttachedToNetwork" metrics.OperationCalled.WithLabelValues(op).Inc() diff --git a/hcloud/cloud_test.go b/hcloud/cloud_test.go index 67c88fa44154e0b0cb105c1e4ac14b55e871ae66..e04f6b1b95b0bad9eadb3e17d5e2ec79dca32d65 100644 --- a/hcloud/cloud_test.go +++ b/hcloud/cloud_test.go @@ -28,8 +28,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/hcops" - "github.com/hetznercloud/hcloud-go/hcloud" - "github.com/hetznercloud/hcloud-go/hcloud/schema" + "github.com/hetznercloud/hcloud-go/v2/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud/schema" ) type testEnv struct { diff --git a/hcloud/instances.go b/hcloud/instances.go index 5794283fde288ce280f640906f2d30e7b63c9d66..caa00d322e994405317cc0c20630306c1acaf9db 100644 --- a/hcloud/instances.go +++ b/hcloud/instances.go @@ -24,7 +24,7 @@ import ( cloudprovider "k8s.io/cloud-provider" "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/metrics" - "github.com/hetznercloud/hcloud-go/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud" ) type addressFamily int @@ -38,10 +38,10 @@ const ( type instances struct { client *hcloud.Client addressFamily addressFamily - networkID int + networkID int64 } -func newInstances(client *hcloud.Client, addressFamily addressFamily, networkID int) *instances { +func newInstances(client *hcloud.Client, addressFamily addressFamily, networkID int64) *instances { return &instances{client, addressFamily, networkID} } @@ -118,7 +118,7 @@ func (i *instances) InstanceMetadata(ctx context.Context, node *corev1.Node) (*c }, nil } -func nodeAddresses(addressFamily addressFamily, networkID int, server *hcloud.Server) []corev1.NodeAddress { +func nodeAddresses(addressFamily addressFamily, networkID int64, server *hcloud.Server) []corev1.NodeAddress { var addresses []corev1.NodeAddress addresses = append( addresses, diff --git a/hcloud/instances_test.go b/hcloud/instances_test.go index cd221ddd83f4538e66aa001f26e517919445976b..5276f99ea324d650db05db8eb22688d765d8177e 100644 --- a/hcloud/instances_test.go +++ b/hcloud/instances_test.go @@ -28,8 +28,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" cloudprovider "k8s.io/cloud-provider" - "github.com/hetznercloud/hcloud-go/hcloud" - "github.com/hetznercloud/hcloud-go/hcloud/schema" + "github.com/hetznercloud/hcloud-go/v2/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud/schema" ) // TestInstances_InstanceExists also tests [lookupServer]. The other tests @@ -218,7 +218,7 @@ func TestNodeAddresses(t *testing.T) { name string addressFamily addressFamily server *hcloud.Server - privateNetwork int + privateNetwork int64 expected []corev1.NodeAddress }{ { diff --git a/hcloud/load_balancers.go b/hcloud/load_balancers.go index 9783b5bff1b396ab21b1e3cb2cbae450a38f0ed1..a60a3163019094fa8d3349a98328658d80c3c3e1 100644 --- a/hcloud/load_balancers.go +++ b/hcloud/load_balancers.go @@ -12,14 +12,14 @@ import ( "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/annotation" "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/hcops" "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/metrics" - "github.com/hetznercloud/hcloud-go/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud" ) // LoadBalancerOps defines the Load Balancer related operations required by // the hcloud-cloud-controller-manager. type LoadBalancerOps interface { GetByName(ctx context.Context, name string) (*hcloud.LoadBalancer, error) - GetByID(ctx context.Context, id int) (*hcloud.LoadBalancer, error) + GetByID(ctx context.Context, id int64) (*hcloud.LoadBalancer, error) GetByK8SServiceUID(ctx context.Context, svc *corev1.Service) (*hcloud.LoadBalancer, error) Create(ctx context.Context, lbName string, service *corev1.Service) (*hcloud.LoadBalancer, error) Delete(ctx context.Context, lb *hcloud.LoadBalancer) error diff --git a/hcloud/load_balancers_test.go b/hcloud/load_balancers_test.go index 574c0590be6e8a71609b8877ab8443e0aec3abf2..db6de804498d1cf48407142ba204931bc67704db 100644 --- a/hcloud/load_balancers_test.go +++ b/hcloud/load_balancers_test.go @@ -10,7 +10,7 @@ import ( "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/annotation" "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/hcops" - "github.com/hetznercloud/hcloud-go/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud" ) func TestLoadBalancers_GetLoadBalancer(t *testing.T) { diff --git a/hcloud/routes.go b/hcloud/routes.go index 424efcb38a045c219a681c798987d9566b2be219..4883dcd19e8a3098c4bd9405780bc09305ddaca0 100644 --- a/hcloud/routes.go +++ b/hcloud/routes.go @@ -13,7 +13,7 @@ import ( "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/hcops" "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/metrics" - "github.com/hetznercloud/hcloud-go/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud" ) type routes struct { @@ -22,7 +22,7 @@ type routes struct { serverCache *hcops.AllServersCache } -func newRoutes(client *hcloud.Client, networkID int) (*routes, error) { +func newRoutes(client *hcloud.Client, networkID int64) (*routes, error) { const op = "hcloud/newRoutes" metrics.OperationCalled.WithLabelValues(op).Inc() @@ -262,7 +262,7 @@ func (r *routes) checkIfRouteAlreadyExists(ctx context.Context, route *cloudprov return false, nil } -func findServerPrivateNetByID(srv *hcloud.Server, id int) (hcloud.ServerPrivateNet, bool) { +func findServerPrivateNetByID(srv *hcloud.Server, id int64) (hcloud.ServerPrivateNet, bool) { for _, n := range srv.PrivateNet { if n.Network.ID == id { return n, true diff --git a/hcloud/routes_test.go b/hcloud/routes_test.go index 69f49e3c5633d53b0cee05446d3fab73e9a7aa76..a0f67e18a76aefc15a9bdf96ce722d0d5324043b 100644 --- a/hcloud/routes_test.go +++ b/hcloud/routes_test.go @@ -8,8 +8,8 @@ import ( cloudprovider "k8s.io/cloud-provider" - "github.com/hetznercloud/hcloud-go/hcloud" - "github.com/hetznercloud/hcloud-go/hcloud/schema" + "github.com/hetznercloud/hcloud-go/v2/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud/schema" ) func TestRoutes_CreateRoute(t *testing.T) { diff --git a/hcloud/testing.go b/hcloud/testing.go index c04b9133f455509687576932cef7ed6cdf92736f..1d05321b035ea7abacb13b58a98b961262d3f698 100644 --- a/hcloud/testing.go +++ b/hcloud/testing.go @@ -12,7 +12,7 @@ import ( "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/annotation" "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/hcops" "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/mocks" - "github.com/hetznercloud/hcloud-go/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud" ) // Setenv prepares the environment for testing the diff --git a/hcloud/util.go b/hcloud/util.go index 5364c34f96e215ed29ce67623858b3e6584583d7..dca2ea88dcce3a53ea4d60d40c7a9f819dd55493 100644 --- a/hcloud/util.go +++ b/hcloud/util.go @@ -26,7 +26,7 @@ import ( "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/metrics" ) -func providerIDToServerID(providerID string) (int, error) { +func providerIDToServerID(providerID string) (int64, error) { const op = "hcloud/providerIDToServerID" metrics.OperationCalled.WithLabelValues(op).Inc() @@ -41,13 +41,13 @@ func providerIDToServerID(providerID string) (int, error) { return 0, fmt.Errorf("%s: missing serverID: %s", op, providerID) } - id, err := strconv.Atoi(idString) + id, err := strconv.ParseInt(idString, 10, 64) if err != nil { return 0, fmt.Errorf("%s: invalid serverID: %s", op, providerID) } return id, nil } -func serverIDToProviderID(serverID int) string { +func serverIDToProviderID(serverID int64) string { return fmt.Sprintf("%s://%d", providerName, serverID) } diff --git a/internal/annotation/load_balancer.go b/internal/annotation/load_balancer.go index 95237a54e17a74c02026ef1953c8ce9bb1da685b..016f57026ca80aee3ddcd98360b4f059571c9560 100644 --- a/internal/annotation/load_balancer.go +++ b/internal/annotation/load_balancer.go @@ -6,7 +6,7 @@ import ( corev1 "k8s.io/api/core/v1" "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/metrics" - "github.com/hetznercloud/hcloud-go/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud" ) const ( diff --git a/internal/annotation/load_balancer_test.go b/internal/annotation/load_balancer_test.go index 17a8714b73d00bc92e4c8d37fe83cdbdc077d261..d8ee624abc7259fafc9e5565bd639899ae9db96e 100644 --- a/internal/annotation/load_balancer_test.go +++ b/internal/annotation/load_balancer_test.go @@ -9,7 +9,7 @@ import ( corev1 "k8s.io/api/core/v1" "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/annotation" - "github.com/hetznercloud/hcloud-go/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud" ) func TestLBToService_AddAnnotations(t *testing.T) { diff --git a/internal/annotation/name.go b/internal/annotation/name.go index a25dd48c3733df339c9657db7d1bb4067e51e3af..814ea0619f1c9e5fa90a900f304a1792a9312d1a 100644 --- a/internal/annotation/name.go +++ b/internal/annotation/name.go @@ -11,7 +11,7 @@ import ( corev1 "k8s.io/api/core/v1" "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/metrics" - "github.com/hetznercloud/hcloud-go/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud" ) // ErrNotSet signals that an annotation was not set. @@ -36,6 +36,8 @@ func (s Name) AnnotateService(svc *corev1.Service, v interface{}) error { svc.ObjectMeta.Annotations[k] = strconv.FormatBool(vt) case int: svc.ObjectMeta.Annotations[k] = strconv.Itoa(vt) + case int64: + svc.ObjectMeta.Annotations[k] = strconv.FormatInt(vt, 10) case string: svc.ObjectMeta.Annotations[k] = vt case []string: @@ -49,7 +51,7 @@ func (s Name) AnnotateService(svc *corev1.Service, v interface{}) error { idsOrNames[i] = c.Name continue } - idsOrNames[i] = strconv.Itoa(c.ID) + idsOrNames[i] = strconv.FormatInt(c.ID, 10) } svc.ObjectMeta.Annotations[k] = strings.Join(idsOrNames, ",") case hcloud.NetworkZone: @@ -289,7 +291,7 @@ func (s Name) CertificatesFromService(svc *corev1.Service) ([]*hcloud.Certificat cs = make([]*hcloud.Certificate, len(ss)) for i, s := range ss { - id, err := strconv.Atoi(s) + id, err := strconv.ParseInt(s, 10, 64) if err != nil { // If we could not parse the string as an integer we assume it // is a name not an id. diff --git a/internal/annotation/name_test.go b/internal/annotation/name_test.go index cdb1421d3d96906927afacd9b78e049b9b3c7e24..2d57e28db64b59a6b51bfc600564573f9b299ded 100644 --- a/internal/annotation/name_test.go +++ b/internal/annotation/name_test.go @@ -13,7 +13,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/annotation" - "github.com/hetznercloud/hcloud-go/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud" ) const ann annotation.Name = "some/annotation" diff --git a/internal/annotation/testing.go b/internal/annotation/testing.go index 5c9b66dc7471cb26b5125a43bbd3075ed66a4252..320d8de0a908421ff8e5ae30d24b8d0b40ecc833 100644 --- a/internal/annotation/testing.go +++ b/internal/annotation/testing.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" - "github.com/hetznercloud/hcloud-go/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud" ) // AssertServiceAnnotated asserts that svc has been annotated with all diff --git a/internal/hcops/action.go b/internal/hcops/action.go index f02c34415198deb73f16b9856ca1052273f1bacc..ed67aefcf142b5f3ab6c072be490e43ae23901e9 100644 --- a/internal/hcops/action.go +++ b/internal/hcops/action.go @@ -3,7 +3,7 @@ package hcops import ( "context" - "github.com/hetznercloud/hcloud-go/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud" ) type HCloudActionClient interface { diff --git a/internal/hcops/certificates.go b/internal/hcops/certificates.go index d946ddb189b03cf0457771ae013410b6ffc36397..83311c108e4d0643ecde71e6798da4dfe760b4b3 100644 --- a/internal/hcops/certificates.go +++ b/internal/hcops/certificates.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/metrics" - "github.com/hetznercloud/hcloud-go/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud" ) // HCloudCertificateClient defines the hcloud-go function related to diff --git a/internal/hcops/certificates_test.go b/internal/hcops/certificates_test.go index 35a03b707af55cd00d7ff3e7bed358ea0e5c22cc..3eeabe22f2babde228899b5b76045f7f9989e66e 100644 --- a/internal/hcops/certificates_test.go +++ b/internal/hcops/certificates_test.go @@ -11,7 +11,7 @@ import ( "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/hcops" "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/mocks" - "github.com/hetznercloud/hcloud-go/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud" ) func TestCertificateOps_GetCertificateByNameOrID(t *testing.T) { diff --git a/internal/hcops/load_balancer.go b/internal/hcops/load_balancer.go index a186db552779e24ccb739b92edbdab89cc44d66c..ee420f641c159d6a61cf51547fb1c7e9ec5ad0f1 100644 --- a/internal/hcops/load_balancer.go +++ b/internal/hcops/load_balancer.go @@ -14,7 +14,7 @@ import ( "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/annotation" "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/metrics" - "github.com/hetznercloud/hcloud-go/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud" ) // LabelServiceUID is a label added to the Hetzner Cloud backend to uniquely @@ -24,7 +24,7 @@ const LabelServiceUID = "hcloud-ccm/service-uid" // HCloudLoadBalancerClient defines the hcloud-go functions required by the // Load Balancer operations type. type HCloudLoadBalancerClient interface { - GetByID(ctx context.Context, id int) (*hcloud.LoadBalancer, *hcloud.Response, error) + GetByID(ctx context.Context, id int64) (*hcloud.LoadBalancer, *hcloud.Response, error) GetByName(ctx context.Context, name string) (*hcloud.LoadBalancer, *hcloud.Response, error) Create(ctx context.Context, opts hcloud.LoadBalancerCreateOpts) (hcloud.LoadBalancerCreateResult, *hcloud.Response, error) @@ -70,7 +70,7 @@ type LoadBalancerOps struct { NetworkClient HCloudNetworkClient CertOps *CertificateOps RetryDelay time.Duration - NetworkID int + NetworkID int64 Defaults LoadBalancerDefaults } @@ -135,7 +135,7 @@ func (l *LoadBalancerOps) GetByName(ctx context.Context, name string) (*hcloud.L // // If no Load Balancer with id could be found, a wrapped ErrNotFound is // returned. -func (l *LoadBalancerOps) GetByID(ctx context.Context, id int) (*hcloud.LoadBalancer, error) { +func (l *LoadBalancerOps) GetByID(ctx context.Context, id int64) (*hcloud.LoadBalancer, error) { const op = "hcops/LoadBalancerOps.GetByName" metrics.OperationCalled.WithLabelValues(op).Inc() @@ -572,14 +572,14 @@ func (l *LoadBalancerOps) ReconcileHCLBTargets( var ( // Set of all K8S server IDs currently assigned as nodes to this // cluster. - k8sNodeIDs = make(map[int]bool) - k8sNodeNames = make(map[int]string) + k8sNodeIDs = make(map[int64]bool) + k8sNodeNames = make(map[int64]string) // Set of server IDs assigned as targets to the HC Load Balancer. Some // of the entries may get deleted during reconcilement. In this case // the hclbTargetIDs[id] is always false. If hclbTargetIDs[id] is true, // the node with this server id is assigned to the K8S cluster. - hclbTargetIDs = make(map[int]bool) + hclbTargetIDs = make(map[int64]bool) changed bool ) @@ -1205,7 +1205,7 @@ func (b *hclbServiceOptsBuilder) buildUpdateServiceOpts() (hcloud.LoadBalancerUp } // TODO this is a copy of the function in hcloud/utils.go => refactor. -func providerIDToServerID(providerID string) (int, error) { +func providerIDToServerID(providerID string) (int64, error) { const op = "hcops/providerIDToServerID" metrics.OperationCalled.WithLabelValues(op).Inc() @@ -1219,14 +1219,14 @@ func providerIDToServerID(providerID string) (int, error) { return 0, fmt.Errorf("%s: missing serverID: %s", op, providerID) } - id, err := strconv.Atoi(idString) + id, err := strconv.ParseInt(idString, 10, 64) if err != nil { return 0, fmt.Errorf("%s: invalid serverID: %s", op, providerID) } return id, nil } -func lbAttached(lb *hcloud.LoadBalancer, nwID int) bool { +func lbAttached(lb *hcloud.LoadBalancer, nwID int64) bool { for _, nw := range lb.PrivateNet { if nw.Network.ID == nwID { return true diff --git a/internal/hcops/load_balancer_internal_test.go b/internal/hcops/load_balancer_internal_test.go index e8792adba2fa441616142b835988e725114c02cd..d0955e6d897f0be9a949bf65cc95467051ea0b88 100644 --- a/internal/hcops/load_balancer_internal_test.go +++ b/internal/hcops/load_balancer_internal_test.go @@ -13,7 +13,7 @@ import ( "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/annotation" "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/mocks" - "github.com/hetznercloud/hcloud-go/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud" ) func TestHCLBServiceOptsBuilder(t *testing.T) { diff --git a/internal/hcops/load_balancer_test.go b/internal/hcops/load_balancer_test.go index 35723446aa60cf118e4be3cce31a5a59d27f95c7..e220be6c93ccaf64c5ec584bba0eb607d943fce2 100644 --- a/internal/hcops/load_balancer_test.go +++ b/internal/hcops/load_balancer_test.go @@ -16,7 +16,7 @@ import ( "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/annotation" "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/hcops" - "github.com/hetznercloud/hcloud-go/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud" ) var errTestLbClient = errors.New("lb client failed") @@ -94,7 +94,7 @@ func TestLoadBalancerOps_GetByName(t *testing.T) { func TestLoadBalancerOps_GetByID(t *testing.T) { tests := []struct { name string - lbID int + lbID int64 mock func(t *testing.T, fx *hcops.LoadBalancerOpsFixture) lb *hcloud.LoadBalancer err error @@ -105,7 +105,7 @@ func TestLoadBalancerOps_GetByID(t *testing.T) { mock: func(t *testing.T, fx *hcops.LoadBalancerOpsFixture) { err := hcloud.Error{Code: hcloud.ErrorCodeNotFound} fx.LBClient. - On("GetByID", fx.Ctx, 1). + On("GetByID", fx.Ctx, int64(1)). Return(nil, nil, err) }, err: hcops.ErrNotFound, @@ -115,7 +115,7 @@ func TestLoadBalancerOps_GetByID(t *testing.T) { lbID: 2, mock: func(t *testing.T, fx *hcops.LoadBalancerOpsFixture) { fx.LBClient. - On("GetByID", fx.Ctx, 2). + On("GetByID", fx.Ctx, int64(2)). Return(nil, nil, nil) }, err: hcops.ErrNotFound, @@ -126,7 +126,7 @@ func TestLoadBalancerOps_GetByID(t *testing.T) { mock: func(t *testing.T, fx *hcops.LoadBalancerOpsFixture) { lb := &hcloud.LoadBalancer{ID: 3} fx.LBClient. - On("GetByID", fx.Ctx, 3). + On("GetByID", fx.Ctx, int64(3)). Return(lb, nil, nil) }, lb: &hcloud.LoadBalancer{ID: 3}, @@ -136,7 +136,7 @@ func TestLoadBalancerOps_GetByID(t *testing.T) { lbID: 4, mock: func(t *testing.T, fx *hcops.LoadBalancerOpsFixture) { fx.LBClient. - On("GetByID", fx.Ctx, 4). + On("GetByID", fx.Ctx, int64(4)). Return(nil, nil, errTestLbClient) }, err: errTestLbClient, @@ -771,7 +771,7 @@ func TestLoadBalancerOps_ReconcileHCLB(t *testing.T) { }, }, mock: func(t *testing.T, tt *LBReconcilementTestCase) { - action := &hcloud.Action{ID: rand.Int()} + action := &hcloud.Action{ID: rand.Int63()} newRDNS := "new-name-lb.example.com" tt.fx.LBClient.On("ChangeDNSPtr", tt.fx.Ctx, tt.initialLB, net.ParseIP("1.2.3.4").String(), &newRDNS).Return(action, nil, nil) tt.fx.MockWatchProgress(action, nil) @@ -818,7 +818,7 @@ func TestLoadBalancerOps_ReconcileHCLB(t *testing.T) { }, }, mock: func(t *testing.T, tt *LBReconcilementTestCase) { - action := &hcloud.Action{ID: rand.Int()} + action := &hcloud.Action{ID: rand.Int63()} newRDNS := "new-name-lb.example.com" tt.fx.LBClient.On("ChangeDNSPtr", tt.fx.Ctx, tt.initialLB, net.ParseIP("fe80::1").String(), &newRDNS).Return(action, nil, nil) tt.fx.MockWatchProgress(action, nil) @@ -843,7 +843,7 @@ func TestLoadBalancerOps_ReconcileHCLB(t *testing.T) { opts := hcloud.LoadBalancerDetachFromNetworkOpts{ Network: &hcloud.Network{ID: 14, Name: "some-network"}, } - action := &hcloud.Action{ID: rand.Int()} + action := &hcloud.Action{ID: rand.Int63()} tt.fx.LBClient.On("DetachFromNetwork", tt.fx.Ctx, tt.initialLB, opts).Return(action, nil, nil) tt.fx.MockWatchProgress(action, nil) }, @@ -882,7 +882,7 @@ func TestLoadBalancerOps_ReconcileHCLB(t *testing.T) { tt.fx.LBOps.NetworkID = nw.ID opts := hcloud.LoadBalancerAttachToNetworkOpts{Network: nw} - action := &hcloud.Action{ID: rand.Int()} + action := &hcloud.Action{ID: rand.Int63()} tt.fx.LBClient.On("AttachToNetwork", tt.fx.Ctx, tt.initialLB, opts).Return(action, nil, nil) tt.fx.MockWatchProgress(action, nil) }, @@ -907,7 +907,7 @@ func TestLoadBalancerOps_ReconcileHCLB(t *testing.T) { Return(nil, nil, hcloud.Error{Code: hcloud.ErrorCodeConflict}). Once() - action := &hcloud.Action{ID: rand.Int()} + action := &hcloud.Action{ID: rand.Int63()} tt.fx.LBClient. On("AttachToNetwork", tt.fx.Ctx, tt.initialLB, opts). Return(action, nil, nil). @@ -936,7 +936,7 @@ func TestLoadBalancerOps_ReconcileHCLB(t *testing.T) { Return(nil, nil, hcloud.Error{Code: hcloud.ErrorCodeLocked}). Once() - action := &hcloud.Action{ID: rand.Int()} + action := &hcloud.Action{ID: rand.Int63()} tt.fx.LBClient. On("AttachToNetwork", tt.fx.Ctx, tt.initialLB, opts). Return(action, nil, nil). @@ -981,7 +981,7 @@ func TestLoadBalancerOps_ReconcileHCLB(t *testing.T) { }, }, mock: func(t *testing.T, tt *LBReconcilementTestCase) { - action := &hcloud.Action{ID: rand.Int()} + action := &hcloud.Action{ID: rand.Int63()} tt.fx.LBClient. On("DisablePublicInterface", tt.fx.Ctx, tt.initialLB). Return(action, nil, nil) @@ -1022,7 +1022,7 @@ func TestLoadBalancerOps_ReconcileHCLB(t *testing.T) { }, }, mock: func(t *testing.T, tt *LBReconcilementTestCase) { - action := &hcloud.Action{ID: rand.Int()} + action := &hcloud.Action{ID: rand.Int63()} tt.fx.LBClient. On("EnablePublicInterface", tt.fx.Ctx, tt.initialLB). Return(action, nil, nil) diff --git a/internal/hcops/mocks.go b/internal/hcops/mocks.go index f0cde9e99d26c68bed08520b86b7cc7d5c7d1782..77deff677e5a71171ef7c21bc4feeaeda90e8b90 100644 --- a/internal/hcops/mocks.go +++ b/internal/hcops/mocks.go @@ -7,7 +7,7 @@ import ( corev1 "k8s.io/api/core/v1" "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/mocks" - "github.com/hetznercloud/hcloud-go/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud" ) type MockLoadBalancerOps struct { @@ -19,7 +19,7 @@ func (m *MockLoadBalancerOps) GetByName(ctx context.Context, name string) (*hclo return mocks.GetLoadBalancerPtr(args, 0), args.Error(1) } -func (m *MockLoadBalancerOps) GetByID(ctx context.Context, id int) (*hcloud.LoadBalancer, error) { +func (m *MockLoadBalancerOps) GetByID(ctx context.Context, id int64) (*hcloud.LoadBalancer, error) { args := m.Called(ctx, id) return mocks.GetLoadBalancerPtr(args, 0), args.Error(1) } diff --git a/internal/hcops/network.go b/internal/hcops/network.go index f41636476bcc05fcc12c7de79008f13a737be815..831eb2ba1e34de4b6a0e1a3880b3b9f1832c75e8 100644 --- a/internal/hcops/network.go +++ b/internal/hcops/network.go @@ -3,9 +3,9 @@ package hcops import ( "context" - "github.com/hetznercloud/hcloud-go/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud" ) type HCloudNetworkClient interface { - GetByID(ctx context.Context, id int) (*hcloud.Network, *hcloud.Response, error) + GetByID(ctx context.Context, id int64) (*hcloud.Network, *hcloud.Response, error) } diff --git a/internal/hcops/server.go b/internal/hcops/server.go index 1e25fc497893b60ea5038cfb98045c5d16986a98..6a38031ad5ce68add2e914ebff9d2e981040cc61 100644 --- a/internal/hcops/server.go +++ b/internal/hcops/server.go @@ -8,7 +8,7 @@ import ( "time" "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/metrics" - "github.com/hetznercloud/hcloud-go/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud" ) // AllServersCache caches the result of the LoadFunc and provides random access diff --git a/internal/hcops/server_test.go b/internal/hcops/server_test.go index 45cd98e96c298410e2550ad3dece60d30f638175..53c5b9b5ac2a6d0ee3283cc978d6b78032f7bd26 100644 --- a/internal/hcops/server_test.go +++ b/internal/hcops/server_test.go @@ -12,7 +12,7 @@ import ( "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/hcops" "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/mocks" - "github.com/hetznercloud/hcloud-go/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud" ) func TestAllServersCache_CacheMiss(t *testing.T) { diff --git a/internal/hcops/testing.go b/internal/hcops/testing.go index fa8ca65438bc9eedc58400488f3d07b1ef45a798..2ed223cb7acae82a94a9874659c87f03b37ac67b 100644 --- a/internal/hcops/testing.go +++ b/internal/hcops/testing.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/mocks" - "github.com/hetznercloud/hcloud-go/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud" ) type LoadBalancerOpsFixture struct { @@ -54,7 +54,7 @@ func (fx *LoadBalancerOpsFixture) MockGetByID(lb *hcloud.LoadBalancer, err error func (fx *LoadBalancerOpsFixture) MockCreate( opts hcloud.LoadBalancerCreateOpts, lb *hcloud.LoadBalancer, err error, ) *hcloud.Action { - action := &hcloud.Action{ID: rand.Int()} + action := &hcloud.Action{ID: rand.Int63()} createResult := hcloud.LoadBalancerCreateResult{Action: action, LoadBalancer: lb} fx.LBClient.On("Create", fx.Ctx, opts).Return(createResult, nil, err) return action @@ -63,7 +63,7 @@ func (fx *LoadBalancerOpsFixture) MockCreate( func (fx *LoadBalancerOpsFixture) MockAddService( opts hcloud.LoadBalancerAddServiceOpts, lb *hcloud.LoadBalancer, err error, ) *hcloud.Action { - action := &hcloud.Action{ID: rand.Int()} + action := &hcloud.Action{ID: rand.Int63()} fx.LBClient.On("AddService", fx.Ctx, lb, opts).Return(action, nil, err) return action } @@ -71,13 +71,13 @@ func (fx *LoadBalancerOpsFixture) MockAddService( func (fx *LoadBalancerOpsFixture) MockUpdateService( opts hcloud.LoadBalancerUpdateServiceOpts, lb *hcloud.LoadBalancer, listenPort int, err error, ) *hcloud.Action { - action := &hcloud.Action{ID: rand.Int()} + action := &hcloud.Action{ID: rand.Int63()} fx.LBClient.On("UpdateService", fx.Ctx, lb, listenPort, opts).Return(action, nil, err) return action } func (fx *LoadBalancerOpsFixture) MockDeleteService(lb *hcloud.LoadBalancer, port int, err error) *hcloud.Action { - action := &hcloud.Action{ID: rand.Int()} + action := &hcloud.Action{ID: rand.Int63()} fx.LBClient.On("DeleteService", fx.Ctx, lb, port).Return(action, nil, err) return action } @@ -85,7 +85,7 @@ func (fx *LoadBalancerOpsFixture) MockDeleteService(lb *hcloud.LoadBalancer, por func (fx *LoadBalancerOpsFixture) MockAddServerTarget( lb *hcloud.LoadBalancer, opts hcloud.LoadBalancerAddServerTargetOpts, err error, ) *hcloud.Action { - action := &hcloud.Action{ID: rand.Int()} + action := &hcloud.Action{ID: rand.Int63()} fx.LBClient.On("AddServerTarget", fx.Ctx, lb, opts).Return(action, nil, err) return action } @@ -93,7 +93,7 @@ func (fx *LoadBalancerOpsFixture) MockAddServerTarget( func (fx *LoadBalancerOpsFixture) MockRemoveServerTarget( lb *hcloud.LoadBalancer, s *hcloud.Server, err error, ) *hcloud.Action { - action := &hcloud.Action{ID: rand.Int()} + action := &hcloud.Action{ID: rand.Int63()} fx.LBClient.On("RemoveServerTarget", fx.Ctx, lb, s).Return(action, nil, err) return action } diff --git a/internal/mocks/action.go b/internal/mocks/action.go index 53bb3f52527e3bc3b289fb7e6080cb17296325bb..ef6d71bfa4bc07abf39b1f9caddaa89a0517d2b1 100644 --- a/internal/mocks/action.go +++ b/internal/mocks/action.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/mock" - "github.com/hetznercloud/hcloud-go/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud" ) type ActionClient struct { diff --git a/internal/mocks/casts.go b/internal/mocks/casts.go index 04d9dace545d3a2e33a6f0e9ed7f9d9154834d10..8757463e137a11604dfb34c82370277018aa31c7 100644 --- a/internal/mocks/casts.go +++ b/internal/mocks/casts.go @@ -3,7 +3,7 @@ package mocks import ( "github.com/stretchr/testify/mock" - "github.com/hetznercloud/hcloud-go/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud" ) func getResponsePtr(args mock.Arguments, i int) *hcloud.Response { diff --git a/internal/mocks/certificates.go b/internal/mocks/certificates.go index e42d2ebdd76d7c6e8ce6d316abbbcdd4af39fde0..8b6ec8b2e472d5f82bafd74fe6bf2a76fa35baee 100644 --- a/internal/mocks/certificates.go +++ b/internal/mocks/certificates.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/mock" - "github.com/hetznercloud/hcloud-go/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud" ) type CertificateClient struct { diff --git a/internal/mocks/loadbalancer.go b/internal/mocks/loadbalancer.go index c3cda588b81cf75ab6c5ae8ab3fc59ec43fc291b..643da086775253af803d8d76c8cae0af8bd14e06 100644 --- a/internal/mocks/loadbalancer.go +++ b/internal/mocks/loadbalancer.go @@ -5,14 +5,14 @@ import ( "github.com/stretchr/testify/mock" - "github.com/hetznercloud/hcloud-go/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud" ) type LoadBalancerClient struct { mock.Mock } -func (m *LoadBalancerClient) GetByID(ctx context.Context, id int) (*hcloud.LoadBalancer, *hcloud.Response, error) { +func (m *LoadBalancerClient) GetByID(ctx context.Context, id int64) (*hcloud.LoadBalancer, *hcloud.Response, error) { args := m.Called(ctx, id) return GetLoadBalancerPtr(args, 0), getResponsePtr(args, 1), args.Error(2) } diff --git a/internal/mocks/network.go b/internal/mocks/network.go index 022350200260c66217cb5b7d6bc57d40401a7b8e..5d36893357b481c3751d0d849718b3fc5bb0c706 100644 --- a/internal/mocks/network.go +++ b/internal/mocks/network.go @@ -5,14 +5,14 @@ import ( "github.com/stretchr/testify/mock" - "github.com/hetznercloud/hcloud-go/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud" ) type NetworkClient struct { mock.Mock } -func (m *NetworkClient) GetByID(ctx context.Context, id int) (*hcloud.Network, *hcloud.Response, error) { +func (m *NetworkClient) GetByID(ctx context.Context, id int64) (*hcloud.Network, *hcloud.Response, error) { args := m.Called(ctx, id) return getNetworkPtr(args, 0), getResponsePtr(args, 1), args.Error(2) } diff --git a/internal/mocks/server.go b/internal/mocks/server.go index 8e6e48c500b64c69ed2a0170a334c5c2f1e66065..e178f51a764478266c8c16714c7b531fe56d18ab 100644 --- a/internal/mocks/server.go +++ b/internal/mocks/server.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/mock" - "github.com/hetznercloud/hcloud-go/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud" ) // ServerClient is a mock implementation of the hcloud.ServerClient. diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index a198422696f0d9f0cf01c5ac3347c606da914233..e23f6c1c36db10efce4b1d43e034698b47708da8 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -17,7 +17,7 @@ import ( "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/annotation" "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/hcops" - "github.com/hetznercloud/hcloud-go/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud" ) var testCluster TestCluster diff --git a/tests/e2e/testing.go b/tests/e2e/testing.go index 5b035b492d7b00fcefca758fcbb464bcbbf01dc3..ef4bf46126d18a49ab25afaa5693632a530164a2 100644 --- a/tests/e2e/testing.go +++ b/tests/e2e/testing.go @@ -21,7 +21,7 @@ import ( "k8s.io/client-go/tools/clientcmd" "github.com/hetznercloud/hcloud-cloud-controller-manager/internal/testsupport" - "github.com/hetznercloud/hcloud-go/hcloud" + "github.com/hetznercloud/hcloud-go/v2/hcloud" ) var rng *rand.Rand