Skip to content

Commit

Permalink
Update azure_loadbalancer_healthprobe.go
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinForReal committed Jul 27, 2023
1 parent 0cfeb04 commit 3c60378
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions pkg/provider/azure_loadbalancer_healthprobe.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,29 +99,22 @@ func (az *Cloud) buildHealthProbeRulesForPort(serviceManifest *v1.Service, port
if s == nil {
return nil
}
//not a integer
for _, item := range serviceManifest.Spec.Ports {
if strings.EqualFold(item.Name, *s) {
//found the port
return nil
}
}
//nolint:gosec
port, err := strconv.Atoi(*s)
if err != nil {
//not a integer
for _, item := range serviceManifest.Spec.Ports {
if strings.EqualFold(item.Name, *s) {
//found the port
return nil
}
}
return fmt.Errorf("port %s not found in service", *s)
}
if port < 0 || port > 65535 {
return fmt.Errorf("port %d is out of range", port)
}
for _, item := range serviceManifest.Spec.Ports {
//nolint:gosec
if item.Port == int32(port) {
//found the port
return nil
}
}
return fmt.Errorf("port %s not found in service", *s)
return nil
})
if err != nil {
return nil, fmt.Errorf("failed to parse annotation %s: %w", consts.BuildHealthProbeAnnotationKeyForPort(port.Port, consts.HealthProbeParamsPort), err)
Expand All @@ -140,13 +133,19 @@ func (az *Cloud) buildHealthProbeRulesForPort(serviceManifest *v1.Service, port
}
} else {
// Not need to verify probePort is in correct range again.
var found bool
for _, item := range serviceManifest.Spec.Ports {
//nolint:gosec
if item.Port == int32(port) {
//found the port
properties.Port = pointer.Int32(item.NodePort)
found = true
break
}
}
if !found {
properties.Port = pointer.Int32(port)

Check failure on line 147 in pkg/provider/azure_loadbalancer_healthprobe.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

cannot use port (variable of type int) as int32 value in argument to pointer.Int32
}
}
}

Expand Down

0 comments on commit 3c60378

Please sign in to comment.