Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion hcloud/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}})
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added ID: []int64{} explicitly here to make clear that a list of IDs is expected. This function should have been broken for over a year anyway.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, there is no real replacement for this function, the feature has been removed, so I think we should only have it deprecated. Fixing this requires manual intervention.

Otherwise we replace the deprecated function with a function that is not deprecated but also not working, and we remove the information from the users that the feature is removed.

}

// AllWithOpts returns all actions for the given options.
Expand Down
2 changes: 1 addition & 1 deletion hcloud/action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
12 changes: 9 additions & 3 deletions hcloud/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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,
Expand All @@ -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].
Expand Down
2 changes: 2 additions & 0 deletions hcloud/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
4 changes: 3 additions & 1 deletion hcloud/floating_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 12 additions & 0 deletions hcloud/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, we will soon be able to suggest new(d), is this really worth changing now?


// 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 {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This helper is necessary to make it possible to inline (*FloatingIP).DNSPtrForIP. If we don't want to export it we could consider moving it to exp/ (though there would be an import cycle if we moved it to errutil) or removing it entirely.

Copy link
Copy Markdown
Member

@jooola jooola May 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I am not sure this is a good idea. We should probably not officially suggest ignoring errors. I'd rather leave this function out and require manual intervention from the users.

return t
}
6 changes: 6 additions & 0 deletions hcloud/primary_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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.
Expand Down
Loading