Fix golangci-lint: formatting, nilerr false positive, deprecated linter names
Some checks failed
CI / build (push) Failing after 34s

- gofmt: fix struct field alignment in types.go, resource_server.go,
  data_source_ssh_keys_by_user.go
- nilerr: refactor GetAllPages pagination detection to avoid returning
  nil error when json.Unmarshal fails (intentional passthrough for
  non-paginated responses)
- .golangci.yml: replace deprecated linter names (vet -> govet,
  tenv -> usetesting)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-16 02:17:13 -04:00
parent 5b1dd07063
commit 39c8cf0b58
5 changed files with 46 additions and 43 deletions

View File

@@ -37,8 +37,11 @@ func (c *Client) GetAllPages(ctx context.Context, path string) (json.RawMessage,
}
var page paginatedResponse
if err := json.Unmarshal(firstRaw, &page); err != nil || page.LastPage == 0 {
// Not a paginated response — return as-is.
// Attempt to detect pagination metadata. If the response doesn't look
// like a paginated envelope (unmarshal fails or last_page is absent/zero),
// return the raw response as-is — this is not an error.
unmarshallable := json.Unmarshal(firstRaw, &page) == nil
if !unmarshallable || page.LastPage <= 1 {
return firstRaw, nil
}

View File

@@ -5,22 +5,22 @@ package client
// ServerCreateRequest represents the request body for creating a server.
type ServerCreateRequest struct {
PackageID int64 `json:"packageId"`
UserID int64 `json:"userId"`
HypervisorID int64 `json:"hypervisorId"`
Ipv4 *int64 `json:"ipv4,omitempty"`
Storage *int64 `json:"storage,omitempty"`
Memory *int64 `json:"memory,omitempty"`
CPUCores *int64 `json:"cpuCores,omitempty"`
Traffic *int64 `json:"traffic,omitempty"`
NetworkSpeedInbound *int64 `json:"networkSpeedInbound,omitempty"`
NetworkSpeedOutbound *int64 `json:"networkSpeedOutbound,omitempty"`
StorageProfile *int64 `json:"storageProfile,omitempty"`
NetworkProfile *int64 `json:"networkProfile,omitempty"`
DryRun *bool `json:"dryRun,omitempty"`
AdditionalStorage1 *int64 `json:"additionalStorage1,omitempty"`
PackageID int64 `json:"packageId"`
UserID int64 `json:"userId"`
HypervisorID int64 `json:"hypervisorId"`
Ipv4 *int64 `json:"ipv4,omitempty"`
Storage *int64 `json:"storage,omitempty"`
Memory *int64 `json:"memory,omitempty"`
CPUCores *int64 `json:"cpuCores,omitempty"`
Traffic *int64 `json:"traffic,omitempty"`
NetworkSpeedInbound *int64 `json:"networkSpeedInbound,omitempty"`
NetworkSpeedOutbound *int64 `json:"networkSpeedOutbound,omitempty"`
StorageProfile *int64 `json:"storageProfile,omitempty"`
NetworkProfile *int64 `json:"networkProfile,omitempty"`
DryRun *bool `json:"dryRun,omitempty"`
AdditionalStorage1 *int64 `json:"additionalStorage1,omitempty"`
AdditionalStorage1Profile *int64 `json:"additionalStorage1Profile,omitempty"`
AdditionalStorage2 *int64 `json:"additionalStorage2,omitempty"`
AdditionalStorage2 *int64 `json:"additionalStorage2,omitempty"`
AdditionalStorage2Profile *int64 `json:"additionalStorage2Profile,omitempty"`
}
@@ -211,11 +211,11 @@ type IPBlockResponse struct {
// IPBlockData represents an IP block in the API.
// The API nests gateway/netmask under "ipv4" and returns "type" as an int.
type IPBlockData struct {
ID int64 `json:"id"`
Name string `json:"name"`
Type int64 `json:"type"`
IPv4 IPBlockIPv4 `json:"ipv4"`
Enabled bool `json:"enabled"`
ID int64 `json:"id"`
Name string `json:"name"`
Type int64 `json:"type"`
IPv4 IPBlockIPv4 `json:"ipv4"`
Enabled bool `json:"enabled"`
}
// IPBlockIPv4 represents the IPv4 section of an IP block.
@@ -236,8 +236,8 @@ type FirewallResponse struct {
// FirewallData represents firewall data in the API.
type FirewallData struct {
Enabled bool `json:"enabled"`
Rules []FirewallRule `json:"rules"`
Enabled bool `json:"enabled"`
Rules []FirewallRule `json:"rules"`
}
// FirewallRule represents a single firewall rule.
@@ -418,9 +418,9 @@ type SelfServiceCreditData struct {
// SelfServiceResourcePackRequest represents the request body for resource packs.
type SelfServiceResourcePackRequest struct {
Name string `json:"name"`
UserID int64 `json:"userId"`
PackID int64 `json:"packId"`
Name string `json:"name"`
UserID int64 `json:"userId"`
PackID int64 `json:"packId"`
}
// SelfServiceResourcePackResponse represents the response for resource pack operations.

View File

@@ -32,8 +32,8 @@ type SSHKeysByUserDataSource struct {
// SSHKeysByUserDataSourceModel describes the data source data model.
type SSHKeysByUserDataSourceModel struct {
UserID types.Int64 `tfsdk:"user_id"`
Results types.Int64 `tfsdk:"results"`
UserID types.Int64 `tfsdk:"user_id"`
Results types.Int64 `tfsdk:"results"`
SSHKeys []SSHKeyByUserItemModel `tfsdk:"ssh_keys"`
}

View File

@@ -53,19 +53,19 @@ type ServerResourceModel struct {
HypervisorID types.Int64 `tfsdk:"hypervisor_id"`
// Optional (create)
Ipv4 types.Int64 `tfsdk:"ipv4"`
Storage types.Int64 `tfsdk:"storage"`
Memory types.Int64 `tfsdk:"memory"`
Cores types.Int64 `tfsdk:"cores"`
Traffic types.Int64 `tfsdk:"traffic"`
InboundNetworkSpeed types.Int64 `tfsdk:"inbound_network_speed"`
OutboundNetworkSpeed types.Int64 `tfsdk:"outbound_network_speed"`
StorageProfile types.Int64 `tfsdk:"storage_profile"`
NetworkProfile types.Int64 `tfsdk:"network_profile"`
DryRun types.Bool `tfsdk:"dry_run"`
AdditionalStorage1 types.Int64 `tfsdk:"additional_storage_1"`
Ipv4 types.Int64 `tfsdk:"ipv4"`
Storage types.Int64 `tfsdk:"storage"`
Memory types.Int64 `tfsdk:"memory"`
Cores types.Int64 `tfsdk:"cores"`
Traffic types.Int64 `tfsdk:"traffic"`
InboundNetworkSpeed types.Int64 `tfsdk:"inbound_network_speed"`
OutboundNetworkSpeed types.Int64 `tfsdk:"outbound_network_speed"`
StorageProfile types.Int64 `tfsdk:"storage_profile"`
NetworkProfile types.Int64 `tfsdk:"network_profile"`
DryRun types.Bool `tfsdk:"dry_run"`
AdditionalStorage1 types.Int64 `tfsdk:"additional_storage_1"`
AdditionalStorage1Profile types.Int64 `tfsdk:"additional_storage_1_profile"`
AdditionalStorage2 types.Int64 `tfsdk:"additional_storage_2"`
AdditionalStorage2 types.Int64 `tfsdk:"additional_storage_2"`
AdditionalStorage2Profile types.Int64 `tfsdk:"additional_storage_2_profile"`
// Optional (update-only)