github-vet / github-vet/rangeloop-pointer-findings

write2madhu/oshift1: pkg/cmd/cli/cmd/deploy.go; 23 LoC

Open
#6,260 0 comments 0 reactions 0 assignees View on GitHub
fresh small
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [write2madhu/oshift1](https://www.github.com/write2madhu/oshift1) at [pkg/cmd/cli/cmd/deploy.go](https://github.com/write2madhu/oshift1/blob/43d4d9b6591bba12d001f13334c5417af61a9eef/pkg/cmd/cli/cmd/deploy.go#L320-L342)

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.

> function call which takes a reference to deployment at line 327 may start a goroutine

[Click here to see the code in its original context.](https://github.com/write2madhu/oshift1/blob/43d4d9b6591bba12d001f13334c5417af61a9eef/pkg/cmd/cli/cmd/deploy.go#L320-L342)

Click here to show the 23 line(s) of Go which triggered the analyzer.

```go
for _, deployment := range deployments.Items {
status := deployutil.DeploymentStatusFor(&deployment)
switch status {
case deployapi.DeploymentStatusNew,
deployapi.DeploymentStatusPending,
deployapi.DeploymentStatusRunning:

if deployutil.IsDeploymentCancelled(&deployment) {
continue
}

deployment.Annotations[deployapi.DeploymentCancelledAnnotation] = deployapi.DeploymentCancelledAnnotationValue
deployment.Annotations[deployapi.DeploymentStatusReasonAnnotation] = deployapi.DeploymentCancelledByUser
_, err := o.kubeClient.ReplicationControllers(deployment.Namespace).Update(&deployment)
if err == nil {
fmt.Fprintf(out, "Cancelled deployment #%d\n", config.Status.LatestVersion)
anyCancelled = true
} else {
fmt.Fprintf(out, "Couldn't cancel deployment #%d (status: %s): %v\n", deployutil.DeploymentVersionFor(&deployment), status, err)
failedCancellations = append(failedCancellations, strconv.FormatInt(deployutil.DeploymentVersionFor(&deployment), 10))
}
}
}

```

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: 43d4d9b6591bba12d001f13334c5417af61a9eef

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.