github-vet / github-vet/rangeloop-pointer-findings
pearsontechnology/environment-operator: pkg/diff/compare.go; 90 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [pearsontechnology/environment-operator](https://www.github.com/pearsontechnology/environment-operator) at [pkg/diff/compare.go](https://github.com/pearsontechnology/environment-operator/blob/e527a2c4ba4d27b6337593ef18351bcc2c4a69da/pkg/diff/compare.go#L36-L125)
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 desiredCfgSvc at line 107 may start a goroutine
[Click here to see the code in its original context.](https://github.com/pearsontechnology/environment-operator/blob/e527a2c4ba4d27b6337593ef18351bcc2c4a69da/pkg/diff/compare.go#L36-L125)
Click here to show the 90 line(s) of Go which triggered the analyzer.
```go
for _, desiredCfgSvc := range desiredCfg.Services {
util.LogTraceAsYaml("Desired Service Config", desiredCfgSvc)
serviceName := desiredCfgSvc.Name
log.Debugf("Checking desired configuration against running service %s", serviceName)
// retrieve existing deployed configuration
existingCfgSvc := existingCfg.Services.FindByName(serviceName)
// existingCfgSvc.Status = bitesize.ServiceStatus{} // don't compare service status
util.LogTraceAsYaml("Existing Service Config", existingCfgSvc)
cfgDiff := compareConfig.Compare(existingCfgSvc, desiredCfgSvc)
if cfgDiff == "" {
log.Debugf("No changes detected for service %s", serviceName)
} else {
log.Debugf("Detected changes for service %s. Difference in config: %s",
serviceName, cfgDiff)
}
// no existing deployed config; blue/green parent deployment
if existingCfgSvc == nil && desiredCfgSvc.IsBlueGreenParentDeployment() {
log.Debugf("Forcing change for blue/green \"parent\" service")
// add the Name field to the parent service
addServiceChange(serviceName, fmt.Sprintf("Name: +%s", serviceName))
}
if desiredCfgSvc.IsActiveBlueGreenDeployment() {
log.Debugf("Ignore changes for active blue/green deployment")
continue
}
if desiredCfgSvc.IsBlueGreenParentDeployment() {
log.Debugf("Desire a B/G Parent deployment")
if existingCfgSvc == nil {
log.Debugf("Applying changes for blue/green \"parent\" service")
generatedConfig := compareConfig.Compare(nil, desiredCfgSvc)
addServiceChange(serviceName, generatedConfig)
continue
}
// Compare externalURLs
if serviceDiff := compareConfig.Compare(existingCfgSvc.ExternalURL, desiredCfgSvc.ExternalURL); serviceDiff != "" {
log.Debugf("change detected for blue/green service ExternalURL %s", serviceName)
util.LogTraceAsYaml("Service Config Change of ExternalURL", serviceDiff)
addServiceChange(serviceName, serviceDiff)
continue
}
// Compare ActiveDeploymentName()
if serviceDiff := compareConfig.Compare(existingCfgSvc.ActiveDeploymentName(), desiredCfgSvc.ActiveDeploymentName()); serviceDiff != "" {
log.Debugf("change detected for blue/green service ActiveDeploymentName %s", serviceName)
util.LogTraceAsYaml("Service Config Change of ActiveDeploymentName()", serviceDiff)
addServiceChange(serviceName, serviceDiff)
continue
}
}
// Changes are only applied if:
// - config in git for service has version set
// OR
// - deployed config for service has version set
gitConfigHasVersionSetForService := desiredCfgSvc.Version != ""
deployedConfigHasVersionSetForService := (existingCfgSvc != nil &&
existingCfgSvc.Version != "")
if gitConfigHasVersionSetForService || deployedConfigHasVersionSetForService {
// if service is already deployed
if existingCfgSvc != nil {
log.Tracef("Aligning currently-deployed service %s to desired state", serviceName)
existingCfgSvc.Status = bitesize.ServiceStatus{} // don't compare service status
alignServices(&desiredCfgSvc, existingCfgSvc)
}
// if changes are needed
if serviceDiff := compareConfig.Compare(existingCfgSvc, desiredCfgSvc); serviceDiff != "" {
log.Debugf("change detected for service %s", serviceName)
util.LogTraceAsYaml("Service Changes", serviceDiff)
addServiceChange(serviceName, serviceDiff)
}
} else {
log.Debugf("\"version\" field not set for Service %s. Skipping deployment.", serviceName)
}
if k8s.ExternalSecretsEnabled && desiredCfgSvc.IsTLSEnabled() &&
!desiredCfgSvc.ExternalSecretExist(desiredCfg.Namespace, serviceName) {
log.Debugf("changes detected for externalsecrets for %s", serviceName)
addServiceChange(serviceName, fmt.Sprintf("ExternalSecrets: +%s", serviceName))
}
}
```
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: e527a2c4ba4d27b6337593ef18351bcc2c4a69da
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.