github-vet / github-vet/rangeloop-pointer-findings
micro/micro: service/runtime/kubernetes/kubernetes.go; 32 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [micro/micro](https://www.github.com/micro/micro) at [service/runtime/kubernetes/kubernetes.go](https://github.com/micro/micro/blob/e3518348d5a861e879a81dedaebf8fbacac07782/service/runtime/kubernetes/kubernetes.go#L356-L387)
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 dep was used in a composite literal at line 379
[Click here to see the code in its original context.](https://github.com/micro/micro/blob/e3518348d5a861e879a81dedaebf8fbacac07782/service/runtime/kubernetes/kubernetes.go#L356-L387)
Click here to show the 32 line(s) of Go which triggered the analyzer.
```go
for _, dep := range depList.Items {
// the service wan't created by the k8s runtime
if dep.Metadata == nil || dep.Metadata.Annotations == nil {
continue
}
// update metadata
for k, v := range s.Metadata {
dep.Metadata.Annotations[k] = v
}
if rcn := getRuntimeClassName(k.options.Context); len(rcn) > 0 {
dep.Spec.Template.PodSpec.RuntimeClassName = rcn
logger.Infof("Setting runtime class name to %v", rcn)
}
// update build time annotation
dep.Spec.Template.Metadata.Annotations["updated"] = fmt.Sprintf("%d", time.Now().Unix())
// update the deployment
res := &client.Resource{
Kind: "deployment",
Name: resourceName(s),
Value: &dep,
}
if err := k.client.Update(res, client.UpdateNamespace(options.Namespace)); err != nil {
if logger.V(logger.ErrorLevel, logger.DefaultLogger) {
logger.Errorf("Runtime failed to update deployment: %v", err)
}
return err
}
}
```
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: e3518348d5a861e879a81dedaebf8fbacac07782
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.