Skip to content

Commit

Permalink
fix: NPE (knative#2062)
Browse files Browse the repository at this point in the history
Signed-off-by: Matej Vasek <[email protected]>
  • Loading branch information
matejvasek committed Nov 1, 2023
1 parent 9fbd7c9 commit cf2fd0e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pkg/knative/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -834,18 +834,21 @@ func processVolumes(volumes []fn.Volume, referencedSecrets, referencedConfigMaps

if !createdVolumes.Has(volumeName) {

sizeLimit, err := resource.ParseQuantity(*vol.EmptyDir.SizeLimit)

if err != nil {
return nil, nil, fmt.Errorf("invalid quantity for sizeLimit: %s. Error: %s", *vol.EmptyDir.SizeLimit, err)
var sizeLimit *resource.Quantity
if vol.EmptyDir.SizeLimit != nil {
sl, err := resource.ParseQuantity(*vol.EmptyDir.SizeLimit)
if err != nil {
return nil, nil, fmt.Errorf("invalid quantity for sizeLimit: %s. Error: %s", *vol.EmptyDir.SizeLimit, err)
}
sizeLimit = &sl
}

newVolumes = append(newVolumes, corev1.Volume{
Name: volumeName,
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{
Medium: corev1.StorageMedium(vol.EmptyDir.Medium),
SizeLimit: &sizeLimit,
SizeLimit: sizeLimit,
},
},
})
Expand Down

0 comments on commit cf2fd0e

Please sign in to comment.