github-vet / github-vet/rangeloop-pointer-findings
virtual-kubelet/openstack-zun: zun.go; 40 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [virtual-kubelet/openstack-zun](https://www.github.com/virtual-kubelet/openstack-zun) at [zun.go](https://github.com/virtual-kubelet/openstack-zun/blob/e04d568634af06c91010544b123bc74b5852688b/zun.go#L329-L368)
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 c was used in a composite literal at line 357
[Click here to see the code in its original context.](https://github.com/virtual-kubelet/openstack-zun/blob/e04d568634af06c91010544b123bc74b5852688b/zun.go#L329-L368)
Click here to show the 40 line(s) of Go which triggered the analyzer.
```go
for _, c := range capsule.Containers {
containerMemoryMB := 0
if c.Memory != "" {
containerMemory, err := strconv.Atoi(c.Memory)
if err != nil {
log.Println(err)
}
containerMemoryMB = containerMemory
}
container := v1.Container{
Name: c.Name,
Image: c.Image,
Command: c.Command,
Resources: v1.ResourceRequirements{
Limits: v1.ResourceList{
v1.ResourceCPU: resource.MustParse(fmt.Sprintf("%g", float64(c.CPU))),
v1.ResourceMemory: resource.MustParse(fmt.Sprintf("%dM", containerMemoryMB)),
},
Requests: v1.ResourceList{
v1.ResourceCPU: resource.MustParse(fmt.Sprintf("%g", float64(c.CPU*1024/100))),
v1.ResourceMemory: resource.MustParse(fmt.Sprintf("%dM", containerMemoryMB)),
},
},
}
containers = append(containers, container)
containerStatus := v1.ContainerStatus{
Name: c.Name,
State: zunContainerStausToContainerStatus(&c),
LastTerminationState: zunContainerStausToContainerStatus(&c),
Ready: zunStatusToPodPhase(c.Status) == v1.PodRunning,
RestartCount: int32(0),
Image: c.Image,
ImageID: "",
ContainerID: c.UUID,
}
// Add to containerStatuses
containerStatuses = append(containerStatuses, containerStatus)
}
```
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: e04d568634af06c91010544b123bc74b5852688b
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.