Skip to content

Commit

Permalink
fix ports panic (#6179)
Browse files Browse the repository at this point in the history
Signed-off-by: rokkiter <101091030+rokkiter@users.noreply.github.com>
  • Loading branch information
rokkiter authored Jun 26, 2023
1 parent 5b5a6ac commit 6e1263d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions plugin/kubernetes/object/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,19 @@ func EndpointSliceToEndpoints(obj meta.Object) (meta.Object, error) {
} else {
e.Subsets[0].Ports = make([]EndpointPort, len(ends.Ports))
for k, p := range ends.Ports {
ep := EndpointPort{Port: *p.Port, Name: *p.Name, Protocol: string(*p.Protocol)}
port := int32(-1)
name := ""
protocol := ""
if p.Port != nil {
port = *p.Port
}
if p.Name != nil {
name = *p.Name
}
if p.Protocol != nil {
protocol = string(*p.Protocol)
}
ep := EndpointPort{Port: port, Name: name, Protocol: protocol}
e.Subsets[0].Ports[k] = ep
}
}
Expand Down Expand Up @@ -146,7 +158,6 @@ func (e *Endpoints) DeepCopyObject() runtime.Object {
ep := EndpointPort{Port: p.Port, Name: p.Name, Protocol: p.Protocol}
sub.Ports[k] = ep
}

e1.Subsets[i] = sub
}
return e1
Expand Down

0 comments on commit 6e1263d

Please sign in to comment.