github-vet / github-vet/rangeloop-pointer-findings
BrunoReboul/ram: utilities/iamgt/meth_orgrolesdeployment_deploy.go; 30 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [BrunoReboul/ram](https://www.github.com/BrunoReboul/ram) at [utilities/iamgt/meth_orgrolesdeployment_deploy.go](https://github.com/BrunoReboul/ram/blob/6528036bf45e995a351f39e55c186f699bbfc009/utilities/iamgt/meth_orgrolesdeployment_deploy.go#L31-L60)
Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first
issue it finds, so please do not limit your consideration to the contents of the below message.
> reference to customRole is reassigned at line 39
[Click here to see the code in its original context.](https://github.com/BrunoReboul/ram/blob/6528036bf45e995a351f39e55c186f699bbfc009/utilities/iamgt/meth_orgrolesdeployment_deploy.go#L31-L60)
Click here to show the 30 line(s) of Go which triggered the analyzer.
```go
for _, customRole := range orgRolesDeployment.Settings.Roles {
name := fmt.Sprintf("organizations/%s/roles/%s",
orgRolesDeployment.Artifacts.OrganizationID, customRole.Title)
retreivedCustomRole, err := organizationsRolesService.Get(name).Context(orgRolesDeployment.Core.Ctx).Do()
if err != nil {
if strings.Contains(err.Error(), "404") && strings.Contains(err.Error(), "notFound") {
parent := fmt.Sprintf("organizations/%s", orgRolesDeployment.Artifacts.OrganizationID)
var createRoleRequest iam.CreateRoleRequest
createRoleRequest.Role = &customRole
createRoleRequest.RoleId = customRole.Title
retreivedCustomRole, err = organizationsRolesService.Create(parent, &createRoleRequest).Context(orgRolesDeployment.Core.Ctx).Do()
if err != nil {
log.Printf("%s iam WARNING impossible to CREATE custom organization roles %v", orgRolesDeployment.Core.InstanceName, err)
return nil
}
log.Printf("%s iam custom org role created %s", orgRolesDeployment.Core.InstanceName, retreivedCustomRole.Name)
} else {
log.Printf("%s iam WARNING impossible to GET custom organization roles %v", orgRolesDeployment.Core.InstanceName, err)
return nil
}
} else {
log.Printf("%s iam found custom org role %s", orgRolesDeployment.Core.InstanceName, retreivedCustomRole.Name)
retreivedCustomRole, err = organizationsRolesService.Patch(name, &customRole).Context(orgRolesDeployment.Core.Ctx).Do()
if err != nil {
log.Printf("%s iam WARNING impossible to PATCH custom organization roles %v", orgRolesDeployment.Core.InstanceName, err)
return nil
}
log.Printf("%s iam custom org role patched %s", orgRolesDeployment.Core.InstanceName, retreivedCustomRole.Name)
}
}
```
Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.
commit ID: 6528036bf45e995a351f39e55c186f699bbfc009
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.