diff --git a/.golangci.yaml b/.golangci.yaml index 5e990066..50762b54 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -69,6 +69,10 @@ linters: - linters: - staticcheck text: schema\.DatacenterServerTypes is deprecated + - # TODO: can be removed once https://github.com/leighmcculloch/gocheckcompilerdirectives/pull/6 is merged + linters: + - gocheckcompilerdirectives + text: "compiler directive unrecognized: //go:fix" formatters: enable: diff --git a/hcloud/action.go b/hcloud/action.go index e01480e8..301eb6bb 100644 --- a/hcloud/action.go +++ b/hcloud/action.go @@ -134,8 +134,10 @@ func (c *ActionClient) List(ctx context.Context, opts ActionListOpts) ([]*Action // All returns all actions. // // Deprecated: It is required to pass in a list of IDs since 30 January 2025. Please use [ActionClient.AllWithOpts] instead. +// +//go:fix inline func (c *ActionClient) All(ctx context.Context) ([]*Action, error) { - return c.action.All(ctx, ActionListOpts{}) + return c.AllWithOpts(ctx, ActionListOpts{ID: []int64{}}) } // AllWithOpts returns all actions for the given options. diff --git a/hcloud/action_test.go b/hcloud/action_test.go index d970eaf6..e7431640 100644 --- a/hcloud/action_test.go +++ b/hcloud/action_test.go @@ -192,7 +192,7 @@ func TestActionClientAll(t *testing.T) { }) ctx := context.Background() - actions, err := env.Client.Action.All(ctx) + actions, err := env.Client.Action.AllWithOpts(ctx, ActionListOpts{}) if err != nil { t.Fatal(err) } diff --git a/hcloud/client.go b/hcloud/client.go index 46c2c983..82c33ea1 100644 --- a/hcloud/client.go +++ b/hcloud/client.go @@ -166,6 +166,8 @@ func WithToken(token string) ClientOption { // hcloud.WithPollOpts(hcloud.PollOpts{ // BackoffFunc: hcloud.ConstantBackoff(2 * time.Second), // }) +// +//go:fix inline func WithPollInterval(pollInterval time.Duration) ClientOption { return WithPollOpts(PollOpts{ BackoffFunc: ConstantBackoff(pollInterval), @@ -176,6 +178,8 @@ func WithPollInterval(pollInterval time.Duration) ClientOption { // function when polling from the API. // // Deprecated: WithPollBackoffFunc is deprecated, use [WithPollOpts] instead. +// +//go:fix inline func WithPollBackoffFunc(f BackoffFunc) ClientOption { return WithPollOpts(PollOpts{ BackoffFunc: f, @@ -202,10 +206,12 @@ func WithPollOpts(opts PollOpts) ClientOption { // The backoff function is used for retrying HTTP requests. // // Deprecated: WithBackoffFunc is deprecated, use [WithRetryOpts] instead. +// +//go:fix inline func WithBackoffFunc(f BackoffFunc) ClientOption { - return func(client *Client) { - client.retryBackoffFunc = f - } + return WithRetryOpts(RetryOpts{ + BackoffFunc: f, + }) } // RetryOpts defines the options used by [WithRetryOpts]. diff --git a/hcloud/error.go b/hcloud/error.go index 9dd6e852..a34fbd9a 100644 --- a/hcloud/error.go +++ b/hcloud/error.go @@ -106,6 +106,8 @@ const ( // before Hetzner Cloud launched into the public. To make clients using the // old error code still work as expected, we set the value of the old error // code to that of the new error code. + // + //go:fix inline ErrorCodeLimitReached = ErrorCodeRateLimitExceeded ) diff --git a/hcloud/floating_ip.go b/hcloud/floating_ip.go index de7b7938..452954ec 100644 --- a/hcloud/floating_ip.go +++ b/hcloud/floating_ip.go @@ -39,8 +39,10 @@ func (o *FloatingIP) pathID() (string, error) { // DNSPtrForIP returns the reverse DNS pointer of the IP address. // // Deprecated: Use GetDNSPtrForIP instead. +// +//go:fix inline func (o *FloatingIP) DNSPtrForIP(ip net.IP) string { - return o.DNSPtr[ip.String()] + return IgnoreError(o.GetDNSPtrForIP(ip)) } // FloatingIPProtection represents the protection level of a Floating IP. diff --git a/hcloud/helper.go b/hcloud/helper.go index 1965609a..1de7e373 100644 --- a/hcloud/helper.go +++ b/hcloud/helper.go @@ -10,19 +10,31 @@ func Ptr[T any](p T) *T { // String returns a pointer to the passed string s. // // Deprecated: Use [Ptr] instead. +// +//go:fix inline func String(s string) *string { return Ptr(s) } // Int returns a pointer to the passed integer i. // // Deprecated: Use [Ptr] instead. +// +//go:fix inline func Int(i int) *int { return Ptr(i) } // Bool returns a pointer to the passed bool b. // // Deprecated: Use [Ptr] instead. +// +//go:fix inline func Bool(b bool) *bool { return Ptr(b) } // Duration returns a pointer to the passed time.Duration d. // // Deprecated: Use [Ptr] instead. +// +//go:fix inline func Duration(d time.Duration) *time.Duration { return Ptr(d) } + +func IgnoreError[T any](t T, _ error) T { + return t +} diff --git a/hcloud/primary_ip.go b/hcloud/primary_ip.go index 19eb8bc5..87d07310 100644 --- a/hcloud/primary_ip.go +++ b/hcloud/primary_ip.go @@ -136,6 +136,8 @@ type PrimaryIPAssignOpts struct { } // Deprecated: Please use [schema.PrimaryIPActionAssignResponse] instead. +// +//go:fix inline type PrimaryIPAssignResult = schema.PrimaryIPActionAssignResponse // PrimaryIPChangeDNSPtrOpts defines the request to @@ -147,6 +149,8 @@ type PrimaryIPChangeDNSPtrOpts struct { } // Deprecated: Please use [schema.PrimaryIPChangeDNSPtrResponse] instead. +// +//go:fix inline type PrimaryIPChangeDNSPtrResult = schema.PrimaryIPActionChangeDNSPtrResponse // PrimaryIPChangeProtectionOpts defines the request to @@ -157,6 +161,8 @@ type PrimaryIPChangeProtectionOpts struct { } // Deprecated: Please use [schema.PrimaryIPActionChangeProtectionResponse] instead. +// +//go:fix inline type PrimaryIPChangeProtectionResult = schema.PrimaryIPActionChangeProtectionResponse // PrimaryIPClient is a client for the Primary IP API.