diff --git a/.circleci/config.yml b/.circleci/config.yml index ea73f7539..b742902c5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,33 +3,27 @@ # Check https://circleci.com/docs/2.0/language-go/ for more details version: 2 jobs: - test-go-1-13: + test-go-tip: &base-test docker: - - image: circleci/golang:1.13 + - image: circleci/golang:latest steps: - checkout - run: go mod download - run: name: Run unit tests command: go test -v ./... + test-go-1-13: + <<: *base-test + docker: + - image: circleci/golang:1.13 test-go-1-12: + <<: *base-test docker: - image: circleci/golang:1.12 - steps: - - checkout - - run: go mod download - - run: - name: Run unit tests - command: go test -v ./... test-go-1-11: + <<: *base-test docker: - image: circleci/golang:1.11 - steps: - - checkout - - run: go mod download - - run: - name: Run unit tests - command: go test -v ./... test-go-1-10: docker: - image: circleci/golang:1.10 @@ -40,11 +34,47 @@ jobs: - run: name: Run unit tests command: go test -v ./... + + test-build-1-13-amd64: &base-build + docker: + - image: circleci/golang:1.13 + environment: + GOARCH: amd64 + steps: + - checkout + - run: go mod download + - run: + name: Test build + command: go build ./... + test-build-1-13-arm: + <<: *base-build + docker: + - image: circleci/golang:1.13 + environment: + GOARCH: arm + test-build-1-13-arm64: + <<: *base-build + docker: + - image: circleci/golang:1.13 + environment: + GOARCH: arm64 + test-build-1-13-386: + <<: *base-build + docker: + - image: circleci/golang:1.13 + environment: + GOARCH: 386 + workflows: version: 2 test: jobs: + - test-go-tip - test-go-1-13 - test-go-1-12 - test-go-1-11 - test-go-1-10 + - test-build-1-13-amd64 + - test-build-1-13-arm + - test-build-1-13-arm64 + - test-build-1-13-386 diff --git a/api/account/v2alpha1/account_sdk.go b/api/account/v2alpha1/account_sdk.go index 9e0e4ec26..6810d7070 100644 --- a/api/account/v2alpha1/account_sdk.go +++ b/api/account/v2alpha1/account_sdk.go @@ -176,13 +176,13 @@ func (s *API) ListSSHKeys(req *ListSSHKeysRequest, opts ...scw.RequestOption) (* // UnsafeGetTotalCount should not be used // Internal usage only -func (r *ListSSHKeysResponse) UnsafeGetTotalCount() int { - return int(r.TotalCount) +func (r *ListSSHKeysResponse) UnsafeGetTotalCount() uint32 { + return r.TotalCount } // UnsafeAppend should not be used // Internal usage only -func (r *ListSSHKeysResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) { +func (r *ListSSHKeysResponse) UnsafeAppend(res interface{}) (uint32, scw.SdkError) { results, ok := res.(*ListSSHKeysResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) @@ -190,7 +190,7 @@ func (r *ListSSHKeysResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) r.SSHKeys = append(r.SSHKeys, results.SSHKeys...) r.TotalCount += uint32(len(results.SSHKeys)) - return len(results.SSHKeys), nil + return uint32(len(results.SSHKeys)), nil } type CreateSSHKeyRequest struct { diff --git a/api/baremetal/v1alpha1/baremetal_sdk.go b/api/baremetal/v1alpha1/baremetal_sdk.go index 190ccc2f5..b0590845d 100644 --- a/api/baremetal/v1alpha1/baremetal_sdk.go +++ b/api/baremetal/v1alpha1/baremetal_sdk.go @@ -491,13 +491,13 @@ func (s *API) ListServers(req *ListServersRequest, opts ...scw.RequestOption) (* // UnsafeGetTotalCount should not be used // Internal usage only -func (r *ListServersResponse) UnsafeGetTotalCount() int { - return int(r.TotalCount) +func (r *ListServersResponse) UnsafeGetTotalCount() uint32 { + return r.TotalCount } // UnsafeAppend should not be used // Internal usage only -func (r *ListServersResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) { +func (r *ListServersResponse) UnsafeAppend(res interface{}) (uint32, scw.SdkError) { results, ok := res.(*ListServersResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) @@ -505,7 +505,7 @@ func (r *ListServersResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) r.Servers = append(r.Servers, results.Servers...) r.TotalCount += uint32(len(results.Servers)) - return len(results.Servers), nil + return uint32(len(results.Servers)), nil } type GetServerRequest struct { @@ -934,13 +934,13 @@ func (s *API) ListServerEvents(req *ListServerEventsRequest, opts ...scw.Request // UnsafeGetTotalCount should not be used // Internal usage only -func (r *ListServerEventsResponse) UnsafeGetTotalCount() int { - return int(r.TotalCount) +func (r *ListServerEventsResponse) UnsafeGetTotalCount() uint32 { + return r.TotalCount } // UnsafeAppend should not be used // Internal usage only -func (r *ListServerEventsResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) { +func (r *ListServerEventsResponse) UnsafeAppend(res interface{}) (uint32, scw.SdkError) { results, ok := res.(*ListServerEventsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) @@ -948,7 +948,7 @@ func (r *ListServerEventsResponse) UnsafeAppend(res interface{}) (int, scw.SdkEr r.Event = append(r.Event, results.Event...) r.TotalCount += uint32(len(results.Event)) - return len(results.Event), nil + return uint32(len(results.Event)), nil } type CreateRemoteServerAccessRequest struct { diff --git a/api/instance/v1/instance_sdk.go b/api/instance/v1/instance_sdk.go index 46723b7db..37c46f12d 100644 --- a/api/instance/v1/instance_sdk.go +++ b/api/instance/v1/instance_sdk.go @@ -1410,13 +1410,13 @@ func (s *API) ListServers(req *ListServersRequest, opts ...scw.RequestOption) (* // UnsafeGetTotalCount should not be used // Internal usage only -func (r *ListServersResponse) UnsafeGetTotalCount() int { - return int(r.TotalCount) +func (r *ListServersResponse) UnsafeGetTotalCount() uint32 { + return r.TotalCount } // UnsafeAppend should not be used // Internal usage only -func (r *ListServersResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) { +func (r *ListServersResponse) UnsafeAppend(res interface{}) (uint32, scw.SdkError) { results, ok := res.(*ListServersResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) @@ -1424,7 +1424,7 @@ func (r *ListServersResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) r.Servers = append(r.Servers, results.Servers...) r.TotalCount += uint32(len(results.Servers)) - return len(results.Servers), nil + return uint32(len(results.Servers)), nil } type createServerRequest struct { @@ -1977,13 +1977,13 @@ func (s *API) ListImages(req *ListImagesRequest, opts ...scw.RequestOption) (*Li // UnsafeGetTotalCount should not be used // Internal usage only -func (r *ListImagesResponse) UnsafeGetTotalCount() int { - return int(r.TotalCount) +func (r *ListImagesResponse) UnsafeGetTotalCount() uint32 { + return r.TotalCount } // UnsafeAppend should not be used // Internal usage only -func (r *ListImagesResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) { +func (r *ListImagesResponse) UnsafeAppend(res interface{}) (uint32, scw.SdkError) { results, ok := res.(*ListImagesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) @@ -1991,7 +1991,7 @@ func (r *ListImagesResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) { r.Images = append(r.Images, results.Images...) r.TotalCount += uint32(len(results.Images)) - return len(results.Images), nil + return uint32(len(results.Images)), nil } type GetImageRequest struct { @@ -2265,13 +2265,13 @@ func (s *API) ListSnapshots(req *ListSnapshotsRequest, opts ...scw.RequestOption // UnsafeGetTotalCount should not be used // Internal usage only -func (r *ListSnapshotsResponse) UnsafeGetTotalCount() int { - return int(r.TotalCount) +func (r *ListSnapshotsResponse) UnsafeGetTotalCount() uint32 { + return r.TotalCount } // UnsafeAppend should not be used // Internal usage only -func (r *ListSnapshotsResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) { +func (r *ListSnapshotsResponse) UnsafeAppend(res interface{}) (uint32, scw.SdkError) { results, ok := res.(*ListSnapshotsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) @@ -2279,7 +2279,7 @@ func (r *ListSnapshotsResponse) UnsafeAppend(res interface{}) (int, scw.SdkError r.Snapshots = append(r.Snapshots, results.Snapshots...) r.TotalCount += uint32(len(results.Snapshots)) - return len(results.Snapshots), nil + return uint32(len(results.Snapshots)), nil } type CreateSnapshotRequest struct { @@ -2544,13 +2544,13 @@ func (s *API) ListVolumes(req *ListVolumesRequest, opts ...scw.RequestOption) (* // UnsafeGetTotalCount should not be used // Internal usage only -func (r *ListVolumesResponse) UnsafeGetTotalCount() int { - return int(r.TotalCount) +func (r *ListVolumesResponse) UnsafeGetTotalCount() uint32 { + return r.TotalCount } // UnsafeAppend should not be used // Internal usage only -func (r *ListVolumesResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) { +func (r *ListVolumesResponse) UnsafeAppend(res interface{}) (uint32, scw.SdkError) { results, ok := res.(*ListVolumesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) @@ -2558,7 +2558,7 @@ func (r *ListVolumesResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) r.Volumes = append(r.Volumes, results.Volumes...) r.TotalCount += uint32(len(results.Volumes)) - return len(results.Volumes), nil + return uint32(len(results.Volumes)), nil } type CreateVolumeRequest struct { @@ -2771,13 +2771,13 @@ func (s *API) ListSecurityGroups(req *ListSecurityGroupsRequest, opts ...scw.Req // UnsafeGetTotalCount should not be used // Internal usage only -func (r *ListSecurityGroupsResponse) UnsafeGetTotalCount() int { - return int(r.TotalCount) +func (r *ListSecurityGroupsResponse) UnsafeGetTotalCount() uint32 { + return r.TotalCount } // UnsafeAppend should not be used // Internal usage only -func (r *ListSecurityGroupsResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) { +func (r *ListSecurityGroupsResponse) UnsafeAppend(res interface{}) (uint32, scw.SdkError) { results, ok := res.(*ListSecurityGroupsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) @@ -2785,7 +2785,7 @@ func (r *ListSecurityGroupsResponse) UnsafeAppend(res interface{}) (int, scw.Sdk r.SecurityGroups = append(r.SecurityGroups, results.SecurityGroups...) r.TotalCount += uint32(len(results.SecurityGroups)) - return len(results.SecurityGroups), nil + return uint32(len(results.SecurityGroups)), nil } type CreateSecurityGroupRequest struct { @@ -3054,13 +3054,13 @@ func (s *API) ListSecurityGroupRules(req *ListSecurityGroupRulesRequest, opts .. // UnsafeGetTotalCount should not be used // Internal usage only -func (r *ListSecurityGroupRulesResponse) UnsafeGetTotalCount() int { - return int(r.TotalCount) +func (r *ListSecurityGroupRulesResponse) UnsafeGetTotalCount() uint32 { + return r.TotalCount } // UnsafeAppend should not be used // Internal usage only -func (r *ListSecurityGroupRulesResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) { +func (r *ListSecurityGroupRulesResponse) UnsafeAppend(res interface{}) (uint32, scw.SdkError) { results, ok := res.(*ListSecurityGroupRulesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) @@ -3068,7 +3068,7 @@ func (r *ListSecurityGroupRulesResponse) UnsafeAppend(res interface{}) (int, scw r.Rules = append(r.Rules, results.Rules...) r.TotalCount += uint32(len(results.Rules)) - return len(results.Rules), nil + return uint32(len(results.Rules)), nil } type CreateSecurityGroupRuleRequest struct { @@ -3362,13 +3362,13 @@ func (s *API) ListComputeClusters(req *ListComputeClustersRequest, opts ...scw.R // UnsafeGetTotalCount should not be used // Internal usage only -func (r *ListComputeClustersResponse) UnsafeGetTotalCount() int { - return int(r.TotalCount) +func (r *ListComputeClustersResponse) UnsafeGetTotalCount() uint32 { + return r.TotalCount } // UnsafeAppend should not be used // Internal usage only -func (r *ListComputeClustersResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) { +func (r *ListComputeClustersResponse) UnsafeAppend(res interface{}) (uint32, scw.SdkError) { results, ok := res.(*ListComputeClustersResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) @@ -3376,7 +3376,7 @@ func (r *ListComputeClustersResponse) UnsafeAppend(res interface{}) (int, scw.Sd r.ComputeClusters = append(r.ComputeClusters, results.ComputeClusters...) r.TotalCount += uint32(len(results.ComputeClusters)) - return len(results.ComputeClusters), nil + return uint32(len(results.ComputeClusters)), nil } type CreateComputeClusterRequest struct { @@ -3854,13 +3854,13 @@ func (s *API) ListIPs(req *ListIPsRequest, opts ...scw.RequestOption) (*ListIPsR // UnsafeGetTotalCount should not be used // Internal usage only -func (r *ListIPsResponse) UnsafeGetTotalCount() int { - return int(r.TotalCount) +func (r *ListIPsResponse) UnsafeGetTotalCount() uint32 { + return r.TotalCount } // UnsafeAppend should not be used // Internal usage only -func (r *ListIPsResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) { +func (r *ListIPsResponse) UnsafeAppend(res interface{}) (uint32, scw.SdkError) { results, ok := res.(*ListIPsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) @@ -3868,7 +3868,7 @@ func (r *ListIPsResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) { r.IPs = append(r.IPs, results.IPs...) r.TotalCount += uint32(len(results.IPs)) - return len(results.IPs), nil + return uint32(len(results.IPs)), nil } type CreateIPRequest struct { @@ -4157,13 +4157,13 @@ func (s *API) ListBootscripts(req *ListBootscriptsRequest, opts ...scw.RequestOp // UnsafeGetTotalCount should not be used // Internal usage only -func (r *ListBootscriptsResponse) UnsafeGetTotalCount() int { - return int(r.TotalCount) +func (r *ListBootscriptsResponse) UnsafeGetTotalCount() uint32 { + return r.TotalCount } // UnsafeAppend should not be used // Internal usage only -func (r *ListBootscriptsResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) { +func (r *ListBootscriptsResponse) UnsafeAppend(res interface{}) (uint32, scw.SdkError) { results, ok := res.(*ListBootscriptsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) @@ -4171,7 +4171,7 @@ func (r *ListBootscriptsResponse) UnsafeAppend(res interface{}) (int, scw.SdkErr r.Bootscripts = append(r.Bootscripts, results.Bootscripts...) r.TotalCount += uint32(len(results.Bootscripts)) - return len(results.Bootscripts), nil + return uint32(len(results.Bootscripts)), nil } type GetBootscriptRequest struct { diff --git a/api/instance/v1/instance_utils.go b/api/instance/v1/instance_utils.go index 6da60eb5a..9e48bfdc8 100644 --- a/api/instance/v1/instance_utils.go +++ b/api/instance/v1/instance_utils.go @@ -286,13 +286,13 @@ func (r *ListVolumesResponse) UnsafeSetTotalCount(totalCount int) { // UnsafeGetTotalCount should not be used // Internal usage only -func (r *ListServersTypesResponse) UnsafeGetTotalCount() int { - return int(r.TotalCount) +func (r *ListServersTypesResponse) UnsafeGetTotalCount() uint32 { + return r.TotalCount } // UnsafeAppend should not be used // Internal usage only -func (r *ListServersTypesResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) { +func (r *ListServersTypesResponse) UnsafeAppend(res interface{}) (uint32, scw.SdkError) { results, ok := res.(*ListServersTypesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) @@ -307,7 +307,7 @@ func (r *ListServersTypesResponse) UnsafeAppend(res interface{}) (int, scw.SdkEr } r.TotalCount += uint32(len(results.Servers)) - return len(results.Servers), nil + return uint32(len(results.Servers)), nil } func (v *NullableStringValue) UnmarshalJSON(b []byte) error { diff --git a/api/lb/v1/lb_sdk.go b/api/lb/v1/lb_sdk.go index 2306edc29..a4f13f2e4 100644 --- a/api/lb/v1/lb_sdk.go +++ b/api/lb/v1/lb_sdk.go @@ -1236,13 +1236,13 @@ func (s *API) ListLbs(req *ListLbsRequest, opts ...scw.RequestOption) (*ListLbsR // UnsafeGetTotalCount should not be used // Internal usage only -func (r *ListLbsResponse) UnsafeGetTotalCount() int { - return int(r.TotalCount) +func (r *ListLbsResponse) UnsafeGetTotalCount() uint32 { + return r.TotalCount } // UnsafeAppend should not be used // Internal usage only -func (r *ListLbsResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) { +func (r *ListLbsResponse) UnsafeAppend(res interface{}) (uint32, scw.SdkError) { results, ok := res.(*ListLbsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) @@ -1250,7 +1250,7 @@ func (r *ListLbsResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) { r.Lbs = append(r.Lbs, results.Lbs...) r.TotalCount += uint32(len(results.Lbs)) - return len(results.Lbs), nil + return uint32(len(results.Lbs)), nil } type CreateLbRequest struct { @@ -1491,13 +1491,13 @@ func (s *API) ListIPs(req *ListIPsRequest, opts ...scw.RequestOption) (*ListIPsR // UnsafeGetTotalCount should not be used // Internal usage only -func (r *ListIPsResponse) UnsafeGetTotalCount() int { - return int(r.TotalCount) +func (r *ListIPsResponse) UnsafeGetTotalCount() uint32 { + return r.TotalCount } // UnsafeAppend should not be used // Internal usage only -func (r *ListIPsResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) { +func (r *ListIPsResponse) UnsafeAppend(res interface{}) (uint32, scw.SdkError) { results, ok := res.(*ListIPsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) @@ -1505,7 +1505,7 @@ func (r *ListIPsResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) { r.IPs = append(r.IPs, results.IPs...) r.TotalCount += uint32(len(results.IPs)) - return len(results.IPs), nil + return uint32(len(results.IPs)), nil } type GetIPRequest struct { @@ -1688,13 +1688,13 @@ func (s *API) ListBackends(req *ListBackendsRequest, opts ...scw.RequestOption) // UnsafeGetTotalCount should not be used // Internal usage only -func (r *ListBackendsResponse) UnsafeGetTotalCount() int { - return int(r.TotalCount) +func (r *ListBackendsResponse) UnsafeGetTotalCount() uint32 { + return r.TotalCount } // UnsafeAppend should not be used // Internal usage only -func (r *ListBackendsResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) { +func (r *ListBackendsResponse) UnsafeAppend(res interface{}) (uint32, scw.SdkError) { results, ok := res.(*ListBackendsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) @@ -1702,7 +1702,7 @@ func (r *ListBackendsResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) r.Backends = append(r.Backends, results.Backends...) r.TotalCount += uint32(len(results.Backends)) - return len(results.Backends), nil + return uint32(len(results.Backends)), nil } type CreateBackendRequest struct { @@ -2325,13 +2325,13 @@ func (s *API) ListFrontends(req *ListFrontendsRequest, opts ...scw.RequestOption // UnsafeGetTotalCount should not be used // Internal usage only -func (r *ListFrontendsResponse) UnsafeGetTotalCount() int { - return int(r.TotalCount) +func (r *ListFrontendsResponse) UnsafeGetTotalCount() uint32 { + return r.TotalCount } // UnsafeAppend should not be used // Internal usage only -func (r *ListFrontendsResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) { +func (r *ListFrontendsResponse) UnsafeAppend(res interface{}) (uint32, scw.SdkError) { results, ok := res.(*ListFrontendsResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) @@ -2339,7 +2339,7 @@ func (r *ListFrontendsResponse) UnsafeAppend(res interface{}) (int, scw.SdkError r.Frontends = append(r.Frontends, results.Frontends...) r.TotalCount += uint32(len(results.Frontends)) - return len(results.Frontends), nil + return uint32(len(results.Frontends)), nil } type CreateFrontendRequest struct { @@ -2680,13 +2680,13 @@ func (s *API) ListACLs(req *ListACLsRequest, opts ...scw.RequestOption) (*ListAC // UnsafeGetTotalCount should not be used // Internal usage only -func (r *ListACLResponse) UnsafeGetTotalCount() int { - return int(r.TotalCount) +func (r *ListACLResponse) UnsafeGetTotalCount() uint32 { + return r.TotalCount } // UnsafeAppend should not be used // Internal usage only -func (r *ListACLResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) { +func (r *ListACLResponse) UnsafeAppend(res interface{}) (uint32, scw.SdkError) { results, ok := res.(*ListACLResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) @@ -2694,7 +2694,7 @@ func (r *ListACLResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) { r.ACLs = append(r.ACLs, results.ACLs...) r.TotalCount += uint32(len(results.ACLs)) - return len(results.ACLs), nil + return uint32(len(results.ACLs)), nil } type CreateACLRequest struct { @@ -2989,13 +2989,13 @@ func (s *API) ListCertificates(req *ListCertificatesRequest, opts ...scw.Request // UnsafeGetTotalCount should not be used // Internal usage only -func (r *ListCertificatesResponse) UnsafeGetTotalCount() int { - return int(r.TotalCount) +func (r *ListCertificatesResponse) UnsafeGetTotalCount() uint32 { + return r.TotalCount } // UnsafeAppend should not be used // Internal usage only -func (r *ListCertificatesResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) { +func (r *ListCertificatesResponse) UnsafeAppend(res interface{}) (uint32, scw.SdkError) { results, ok := res.(*ListCertificatesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) @@ -3003,7 +3003,7 @@ func (r *ListCertificatesResponse) UnsafeAppend(res interface{}) (int, scw.SdkEr r.Certificates = append(r.Certificates, results.Certificates...) r.TotalCount += uint32(len(results.Certificates)) - return len(results.Certificates), nil + return uint32(len(results.Certificates)), nil } type GetCertificateRequest struct { @@ -3173,13 +3173,13 @@ func (s *API) ListLbTypes(req *ListLbTypesRequest, opts ...scw.RequestOption) (* // UnsafeGetTotalCount should not be used // Internal usage only -func (r *ListLbTypesResponse) UnsafeGetTotalCount() int { - return int(r.TotalCount) +func (r *ListLbTypesResponse) UnsafeGetTotalCount() uint32 { + return r.TotalCount } // UnsafeAppend should not be used // Internal usage only -func (r *ListLbTypesResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) { +func (r *ListLbTypesResponse) UnsafeAppend(res interface{}) (uint32, scw.SdkError) { results, ok := res.(*ListLbTypesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) @@ -3187,7 +3187,7 @@ func (r *ListLbTypesResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) r.LbTypes = append(r.LbTypes, results.LbTypes...) r.TotalCount += uint32(len(results.LbTypes)) - return len(results.LbTypes), nil + return uint32(len(results.LbTypes)), nil } type Config interface { diff --git a/api/marketplace/v1/marketplace_sdk.go b/api/marketplace/v1/marketplace_sdk.go index 71eed12ae..5c365a115 100644 --- a/api/marketplace/v1/marketplace_sdk.go +++ b/api/marketplace/v1/marketplace_sdk.go @@ -189,13 +189,13 @@ func (s *API) ListImages(req *ListImagesRequest, opts ...scw.RequestOption) (*Li // UnsafeGetTotalCount should not be used // Internal usage only -func (r *ListImagesResponse) UnsafeGetTotalCount() int { - return int(r.TotalCount) +func (r *ListImagesResponse) UnsafeGetTotalCount() uint32 { + return r.TotalCount } // UnsafeAppend should not be used // Internal usage only -func (r *ListImagesResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) { +func (r *ListImagesResponse) UnsafeAppend(res interface{}) (uint32, scw.SdkError) { results, ok := res.(*ListImagesResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) @@ -203,7 +203,7 @@ func (r *ListImagesResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) { r.Images = append(r.Images, results.Images...) r.TotalCount += uint32(len(results.Images)) - return len(results.Images), nil + return uint32(len(results.Images)), nil } type GetImageRequest struct { diff --git a/api/test/v1/test_sdk.go b/api/test/v1/test_sdk.go index dfc9a0f76..bfbd17255 100644 --- a/api/test/v1/test_sdk.go +++ b/api/test/v1/test_sdk.go @@ -308,13 +308,13 @@ func (s *API) ListHumans(req *ListHumansRequest, opts ...scw.RequestOption) (*Li // UnsafeGetTotalCount should not be used // Internal usage only -func (r *ListHumansResponse) UnsafeGetTotalCount() int { - return int(r.TotalCount) +func (r *ListHumansResponse) UnsafeGetTotalCount() uint32 { + return r.TotalCount } // UnsafeAppend should not be used // Internal usage only -func (r *ListHumansResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) { +func (r *ListHumansResponse) UnsafeAppend(res interface{}) (uint32, scw.SdkError) { results, ok := res.(*ListHumansResponse) if !ok { return 0, errors.New("%T type cannot be appended to type %T", res, r) @@ -322,7 +322,7 @@ func (r *ListHumansResponse) UnsafeAppend(res interface{}) (int, scw.SdkError) { r.Humans = append(r.Humans, results.Humans...) r.TotalCount += uint32(len(results.Humans)) - return len(results.Humans), nil + return uint32(len(results.Humans)), nil } type GetHumanRequest struct { diff --git a/scw/client.go b/scw/client.go index 2e9dcb377..755949c7d 100644 --- a/scw/client.go +++ b/scw/client.go @@ -23,14 +23,14 @@ import ( // This client should be passed in the `NewApi` functions whenever an API instance is created. // Creating a Client is done with the `NewClient` function. type Client struct { - httpClient httpClient - auth auth.Auth - apiURL string - userAgent string + httpClient httpClient + auth auth.Auth + apiURL string + userAgent string defaultOrganizationID *string - defaultRegion *Region - defaultZone *Zone - defaultPageSize *int32 + defaultRegion *Region + defaultZone *Zone + defaultPageSize *int32 } func defaultOptions() []ClientOption { @@ -70,14 +70,14 @@ func NewClient(opts ...ClientOption) (*Client, error) { logger.Debugf("client: using sdk version " + version) return &Client{ - auth: s.token, - httpClient: s.httpClient, - apiURL: s.apiURL, - userAgent: s.userAgent, + auth: s.token, + httpClient: s.httpClient, + apiURL: s.apiURL, + userAgent: s.userAgent, defaultOrganizationID: s.defaultOrganizationID, - defaultRegion: s.defaultRegion, - defaultZone: s.defaultZone, - defaultPageSize: s.defaultPageSize, + defaultRegion: s.defaultRegion, + defaultZone: s.defaultZone, + defaultPageSize: s.defaultPageSize, }, nil } @@ -268,24 +268,26 @@ func (c *Client) do(req *ScalewayRequest, res interface{}) (sdkErr SdkError) { } type lister interface { - UnsafeGetTotalCount() int - UnsafeAppend(interface{}) (int, SdkError) + UnsafeGetTotalCount() uint32 + UnsafeAppend(interface{}) (uint32, SdkError) } type legacyLister interface { UnsafeSetTotalCount(totalCount int) } +const maxPageCount uint32 = math.MaxUint32 + // doListAll collects all pages of a List request and aggregate all results on a single response. func (c *Client) doListAll(req *ScalewayRequest, res interface{}) (err SdkError) { // check for lister interface if response, isLister := res.(lister); isLister { - pageCount := math.MaxUint32 - for page := 1; page <= pageCount; page++ { + pageCount := maxPageCount + for page := uint32(1); page <= pageCount; page++ { // set current page - req.Query.Set("page", strconv.Itoa(page)) + req.Query.Set("page", strconv.FormatUint(uint64(page), 10)) // request the next page nextPage := newVariableFromType(response) @@ -305,7 +307,7 @@ func (c *Client) doListAll(req *ScalewayRequest, res interface{}) (err SdkError) } // set total count on first request - if pageCount == math.MaxUint32 { + if pageCount == maxPageCount { totalCount := nextPage.(lister).UnsafeGetTotalCount() pageCount = (totalCount + pageSize - 1) / pageSize }