From cf2fd0e31a2d5e67e122306d001978ff3fb49845 Mon Sep 17 00:00:00 2001 From: Matej Vasek Date: Tue, 31 Oct 2023 18:05:10 +0100 Subject: [PATCH] fix: NPE (#2062) Signed-off-by: Matej Vasek --- pkg/knative/deployer.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pkg/knative/deployer.go b/pkg/knative/deployer.go index 67ea7a364b..9e2dfd3f3b 100644 --- a/pkg/knative/deployer.go +++ b/pkg/knative/deployer.go @@ -834,10 +834,13 @@ 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{ @@ -845,7 +848,7 @@ func processVolumes(volumes []fn.Volume, referencedSecrets, referencedConfigMaps VolumeSource: corev1.VolumeSource{ EmptyDir: &corev1.EmptyDirVolumeSource{ Medium: corev1.StorageMedium(vol.EmptyDir.Medium), - SizeLimit: &sizeLimit, + SizeLimit: sizeLimit, }, }, })