Skip to content

Commit

Permalink
Nil pointer fix
Browse files Browse the repository at this point in the history
Signed-off-by: Abhijit Mukherjee <[email protected]>
  • Loading branch information
mabhi committed Mar 21, 2024
1 parent e72b3eb commit 907854b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions pkg/function/kube_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,15 @@ func kubeTask(ctx context.Context, cli kubernetes.Interface, namespace, image st
PodOverride: podOverride,
}
// Mark labels to pods with prefix `jobPrefix`. Add the jobID as reference to the origin for the pod.
fields := field.FromContext(ctx)
for _, f := range fields.Fields() {
if strings.HasPrefix(f.Key(), consts.LabelPrefix) {
jobID := f.Value().(string)
if options.Labels == nil {
options.Labels = make(map[string]string)
if fields := field.FromContext(ctx); fields != nil {
for _, f := range fields.Fields() {
if strings.HasPrefix(f.Key(), consts.LabelPrefix) {
jobID := f.Value().(string)
if options.Labels == nil {
options.Labels = make(map[string]string)
}
options.Labels[consts.LabelPrefix+"JobID"] = jobID
}
options.Labels[consts.LabelPrefix+"JobID"] = jobID
}
}

Expand Down

0 comments on commit 907854b

Please sign in to comment.