Skip to content

Commit

Permalink
Explicit conversion of strings to int64.
Browse files Browse the repository at this point in the history
Instead of machine dependant conversion when using integer type int.
Will throw "value out of range" error for platforms that infer int as int32,
when larger integers than int32 is used.
  • Loading branch information
RicNord committed May 28, 2023
1 parent e30e31b commit b701ceb
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion access/resource_permission_assignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (a PermissionAssignmentAPI) List() (list PermissionAssignmentList, err erro
}

func mustInt64(s string) int64 {
n, err := strconv.ParseInt(s, 10, 0)
n, err := strconv.ParseInt(s, 10, 64)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion mws/resource_mws_permission_assignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (a PermissionAssignmentAPI) List(workspaceId int64) (list PermissionAssignm
}

func mustInt64(s string) int64 {
n, err := strconv.ParseInt(s, 10, 0)
n, err := strconv.ParseInt(s, 10, 64)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion permissions/resource_permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func (a PermissionsAPI) Delete(objectID string) error {
return err
}
if strings.HasPrefix(objectID, "/jobs") {
jobId, err := strconv.ParseInt(strings.ReplaceAll(objectID, "/jobs/", ""), 10, 0)
jobId, err := strconv.ParseInt(strings.ReplaceAll(objectID, "/jobs/", ""), 10, 64)
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions repos/resource_git_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func ResourceGitCredential() *schema.Resource {
if err != nil {
return err
}
cred_id, err := strconv.ParseInt(d.Id(), 10, 0)
cred_id, err := strconv.ParseInt(d.Id(), 10, 64)
if err != nil {
return err
}
Expand All @@ -83,7 +83,7 @@ func ResourceGitCredential() *schema.Resource {
var req workspace.UpdateCredentials

common.DataToStructPointer(d, s, &req)
cred_id, err := strconv.ParseInt(d.Id(), 10, 0)
cred_id, err := strconv.ParseInt(d.Id(), 10, 64)
if err != nil {
return err
}
Expand All @@ -99,7 +99,7 @@ func ResourceGitCredential() *schema.Resource {
if err != nil {
return err
}
cred_id, err := strconv.ParseInt(d.Id(), 10, 0)
cred_id, err := strconv.ParseInt(d.Id(), 10, 64)
if err != nil {
return err
}
Expand Down

0 comments on commit b701ceb

Please sign in to comment.