You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fmt.Fprintf(cmd.OutOrStderr(), "PersistentVolumeClaim will be mounted as read-only")
373
+
}
374
+
fmt.Fprintf(cmd.OutOrStderr(), "Please ensure the PersistentVolumeClaim extension flag is enabled:\nhttps://knative.dev/docs/serving/configuration/feature-flags/\n")
returnfmt.Errorf("invalid medium: must be 'Memory' or empty")
383
+
}
384
+
emptyDir.Medium=medium
385
+
}
386
+
newVolume.EmptyDir=emptyDir
387
+
fmt.Fprintf(cmd.OutOrStderr(), "Please make sure to enable the EmptyDir extension flag:\nhttps://knative.dev/docs/serving/configuration/feature-flags/\n")
388
+
389
+
default:
390
+
returnfmt.Errorf("invalid volume type: %s (must be one of: configmap, secret, pvc, emptydir)", volumeType)
391
+
}
392
+
393
+
// Add the volume to the function
394
+
f.Run.Volumes=append(f.Run.Volumes, newVolume)
395
+
396
+
// Save the function
397
+
err:=f.Write()
398
+
iferr==nil {
399
+
fmt.Printf("Volume entry was added to the function configuration\n")
400
+
fmt.Printf("Added: %s\n", newVolume.String())
401
+
}
402
+
returnerr
403
+
}
404
+
405
+
// runRemoveVolume handles removing volumes by mount path
406
+
funcrunRemoveVolume(cmd*cobra.Command, f fn.Function, mountPathstring) error {
407
+
if!strings.HasPrefix(mountPath, "/") {
408
+
returnfmt.Errorf("mount path must be an absolute path (start with /)")
409
+
}
410
+
411
+
// Find and remove the volume with the specified path
412
+
varnewVolumes []fn.Volume
413
+
removed:=false
414
+
for_, v:=rangef.Run.Volumes {
415
+
ifv.Path!=nil&&*v.Path==mountPath {
416
+
removed=true
417
+
} else {
418
+
newVolumes=append(newVolumes, v)
419
+
}
420
+
}
421
+
422
+
if!removed {
423
+
returnfmt.Errorf("no volume found with mount path: %s", mountPath)
424
+
}
425
+
426
+
f.Run.Volumes=newVolumes
427
+
err:=f.Write()
428
+
iferr==nil {
429
+
fmt.Fprintf(cmd.OutOrStderr(), "Volume entry was removed from the function configuration\n")
430
+
fmt.Fprintf(cmd.OutOrStderr(), "Removed volume at path: %s\n", mountPath)
0 commit comments