diff --git a/.golangci.yml b/.golangci.yml index 52d0a87..a1bc9ef 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -16,8 +16,8 @@ linters: - nilerr - predeclared - staticcheck - - tenv + - usetesting - unconvert - unparam - unused - - vet + - govet diff --git a/internal/client/request.go b/internal/client/request.go index 786dd83..5748fe8 100644 --- a/internal/client/request.go +++ b/internal/client/request.go @@ -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 } diff --git a/internal/client/types.go b/internal/client/types.go index 09ed03b..81d4b4e 100644 --- a/internal/client/types.go +++ b/internal/client/types.go @@ -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. diff --git a/internal/provider/data_source_ssh_keys_by_user.go b/internal/provider/data_source_ssh_keys_by_user.go index 1d50202..42a4304 100644 --- a/internal/provider/data_source_ssh_keys_by_user.go +++ b/internal/provider/data_source_ssh_keys_by_user.go @@ -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"` } diff --git a/internal/provider/resource_server.go b/internal/provider/resource_server.go index 2c15246..e241d2a 100644 --- a/internal/provider/resource_server.go +++ b/internal/provider/resource_server.go @@ -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)