github-vet / github-vet/rangeloop-pointer-findings
AshishJainRadicle/fissionJvm: pkg/fission-cli/cmd/spec/apply.go; 63 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [AshishJainRadicle/fissionJvm](https://www.github.com/AshishJainRadicle/fissionJvm) at [pkg/fission-cli/cmd/spec/apply.go](https://github.com/AshishJainRadicle/fissionJvm/blob/e2f1f778f353af857e0b7323299a3962c264334b/pkg/fission-cli/cmd/spec/apply.go#L571-L633)
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 o is reassigned at line 607
[Click here to see the code in its original context.](https://github.com/AshishJainRadicle/fissionJvm/blob/e2f1f778f353af857e0b7323299a3962c264334b/pkg/fission-cli/cmd/spec/apply.go#L571-L633)
Click here to show the 63 line(s) of Go which triggered the analyzer.
```go
for _, o := range fr.Packages {
// apply deploymentConfig so we can find our objects on future apply invocations
applyDeploymentConfig(&o.ObjectMeta, fr)
// index desired state
desired[mapKey(&o.ObjectMeta)] = true
// exists?
existingObj, ok := existent[mapKey(&o.ObjectMeta)]
if ok {
// ok, a resource with the same name exists, is it the same?
keep := false
if reflect.DeepEqual(existingObj.Spec, o.Spec) {
keep = true
} else if reflect.DeepEqual(existingObj.Spec.Environment, o.Spec.Environment) &&
!reflect.DeepEqual(existingObj.Spec.Source, fv1.Archive{}) &&
reflect.DeepEqual(existingObj.Spec.Source, o.Spec.Source) &&
existingObj.Spec.BuildCommand == o.Spec.BuildCommand {
keep = true
}
if keep && existingObj.Status.BuildStatus == fv1.BuildStatusSucceeded {
// nothing to do on the server
metadataMap[mapKey(&o.ObjectMeta)] = existingObj.ObjectMeta
} else {
// update
o.ObjectMeta.ResourceVersion = existingObj.ObjectMeta.ResourceVersion
// We may be racing against the package builder to update the
// package (a previous version might have been getting built). So,
// wait for the package to have a non-running build status.
pkg, err := waitForPackageBuild(fclient, &o)
if err != nil {
// log and ignore
console.Warn(fmt.Sprintf("Error waiting for package '%v' build, ignoring", o.ObjectMeta.Name))
pkg = &o
}
// update status in order to rebuild the package again
if pkg.Status.BuildStatus == fv1.BuildStatusFailed {
pkg.Status.BuildStatus = fv1.BuildStatusPending
}
newmeta, err := fclient.V1().Package().Update(pkg)
if err != nil {
return nil, nil, err
// TODO check for resourceVersion conflict errors and retry
}
ras.Updated = append(ras.Updated, newmeta)
// keep track of metadata in case we need to create a reference to it
metadataMap[mapKey(&o.ObjectMeta)] = *newmeta
}
} else {
// create
newmeta, err := fclient.V1().Package().Create(&o)
if err != nil {
return nil, nil, err
}
ras.Created = append(ras.Created, newmeta)
metadataMap[mapKey(&o.ObjectMeta)] = *newmeta
}
}
```
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: e2f1f778f353af857e0b7323299a3962c264334b
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.