Skip to content

Commit

Permalink
fix: avoid panic in WithWorkload when metadata.name is missing
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Meier <[email protected]>
  • Loading branch information
astromechza committed May 9, 2024
1 parent 5d0b6f5 commit 9d313c7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion framework/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ func (s *State[StateExtras, WorkloadExtras, ResourceExtras]) WithWorkload(spec *
} else {
out.Workloads = maps.Clone(s.Workloads)
}
out.Workloads[spec.Metadata["name"].(string)] = ScoreWorkloadState[WorkloadExtras]{
name, ok := spec.Metadata["name"].(string)
if !ok {
return nil, fmt.Errorf("metadata: name: is missing or is not a string")
}
out.Workloads[name] = ScoreWorkloadState[WorkloadExtras]{
Spec: *spec,
File: filePath,
Extras: extras,
Expand Down

0 comments on commit 9d313c7

Please sign in to comment.