github-vet / github-vet/rangeloop-pointer-findings
BrunoReboul/ram: utilities/iamgt/meth_projectrolesdeployment_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_projectrolesdeployment_deploy.go](https://github.com/BrunoReboul/ram/blob/6528036bf45e995a351f39e55c186f699bbfc009/utilities/iamgt/meth_projectrolesdeployment_deploy.go#L29-L58)
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 38
[Click here to see the code in its original context.](https://github.com/BrunoReboul/ram/blob/6528036bf45e995a351f39e55c186f699bbfc009/utilities/iamgt/meth_projectrolesdeployment_deploy.go#L29-L58)
Click here to show the 30 line(s) of Go which triggered the analyzer.
```go
for _, customRole := range projectRolesDeployment.Settings.Roles {
name := fmt.Sprintf("projects/%s/roles/%s",
projectRolesDeployment.Artifacts.ProjectID, customRole.Title)
retreivedCustomRole, err := projectsRolesService.Get(name).Context(projectRolesDeployment.Core.Ctx).Do()
if err != nil {
if strings.Contains(err.Error(), "404") && strings.Contains(err.Error(), "notFound") {
parent := fmt.Sprintf("projects/%s", projectRolesDeployment.Artifacts.ProjectID)
var createRoleRequest iam.CreateRoleRequest
createRoleRequest.RoleId = customRole.Title
createRoleRequest.Role = &customRole
retreivedCustomRole, err = projectsRolesService.Create(parent, &createRoleRequest).Context(projectRolesDeployment.Core.Ctx).Do()
if err != nil {
log.Printf("%s iam WARNING impossible to CREATE custom project roles %v", projectRolesDeployment.Core.InstanceName, err)
return nil
}
log.Printf("%s iam custom project role created %s", projectRolesDeployment.Core.InstanceName, retreivedCustomRole.Name)
} else {
log.Printf("%s iam WARNING impossible to GET custom project roles %v", projectRolesDeployment.Core.InstanceName, err)
return nil
}
} else {
log.Printf("%s iam custom project role found %s", projectRolesDeployment.Core.InstanceName, retreivedCustomRole.Name)
retreivedCustomRole, err = projectsRolesService.Patch(name, &customRole).Context(projectRolesDeployment.Core.Ctx).Do()
if err != nil {
log.Printf("%s iam WARNING impossible to PATCH custom project roles %v", projectRolesDeployment.Core.InstanceName, err)
return nil
}
log.Printf("%s iam custom project role patched %s", projectRolesDeployment.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.