{"modulePath":"github.com/devfile/devworkspace-operator","version":"v1.1.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package storage\n\nPackage storage contains library functions for provisioning volumes and volumeMounts in containers according to the volume components in a devfile. These functions also handle mounting project sources to containers that require it.\n\nTODO:\n\n  - Figure out how to handle 'size' parameter on volumes, given that we can't meaningfully use it for common PVC-type storage\n  - Devfile API spec is unclear on how mountSources should be handled -- mountPath is assumed to be /projects and volume name is assumed to be \"projects\" see issues:\n  - [https://github.com/devfile/api/issues/290](https://github.com/devfile/api/issues/290)\n  - [https://github.com/devfile/api/issues/291](https://github.com/devfile/api/issues/291)\n\n## Variables\n\n```go\nvar UnsupportedStorageStrategy = errors.New(\"configured storage type not supported\")\n```\nUnsupportedStorageStrategy is used when the controller is configured with an invalid storage strategy\n\n## Functions\n\n```go\nfunc FindNodeForPVC(ctx context.Context, k8sClient client.Client, namespace, pvcName, excludeJob string) (string, error)\n```\nFindNodeForPVC lists DevWorkspace pods in the given namespace and returns the node name where a running pod mounts the specified PVC. Returns an empty string (and nil error) when no such pod is found. Pods controlled by the Job named excludeJob are skipped; pass an empty string to consider all pods.\n\n```go\nfunc NodeAffinityForHostname(nodeName string) *corev1.NodeAffinity\n```\nNodeAffinityForHostname returns a NodeAffinity that requires scheduling on the node with the given name, matched via the kubernetes.io/hostname label. Callers are expected to resolve the target node beforehand (e.g. via FindNodeForPVC) and skip setting affinity when none is found. It is used by cleanup and backup Jobs to run on the node a ReadWriteOnce PVC is attached to, avoiding Multi-Attach errors on multi-node clusters.\n\n```go\nfunc WorkspaceNeedsStorage(workspace *dw.DevWorkspaceTemplateSpec) bool\n```\nWorkspaceNeedsStorage returns true if storage will need to be provisioned for the current workspace. Note that ephemeral volumes do not need to provision storage\n\n## Types\n\n```go\ntype AsyncStorageProvisioner struct{}\n```\nThe AsyncStorageProvisioner provisions one PVC per namespace and creates an ssh deployment that syncs data into that PVC. Workspaces are provisioned with sync sidecars that sync data from the workspace to the async ssh deployment. All storage attached to a workspace is emptyDir volumes.\n\n```go\nfunc (p *AsyncStorageProvisioner) CleanupWorkspaceStorage(workspace *common.DevWorkspaceWithConfig, clusterAPI sync.ClusterAPI) error\n```\n\n```go\nfunc (*AsyncStorageProvisioner) NeedsStorage(workspace *dw.DevWorkspaceTemplateSpec) bool\n```\n\n```go\nfunc (p *AsyncStorageProvisioner) ProvisionStorage(podAdditions *v1alpha1.PodAdditions, workspace *common.DevWorkspaceWithConfig, clusterAPI sync.ClusterAPI) error\n```\n\n```go\ntype CommonStorageProvisioner struct{}\n```\nThe CommonStorageProvisioner provisions one PVC per namespace and configures all volumes in a workspace to mount on subpaths within that PVC. Workspace storage is mounted prefixed with the workspace ID.\n\n```go\nfunc (p *CommonStorageProvisioner) CleanupWorkspaceStorage(workspace *common.DevWorkspaceWithConfig, clusterAPI sync.ClusterAPI) error\n```\n\n```go\nfunc (*CommonStorageProvisioner) NeedsStorage(workspace *dw.DevWorkspaceTemplateSpec) bool\n```\n\n```go\nfunc (p *CommonStorageProvisioner) ProvisionStorage(podAdditions *v1alpha1.PodAdditions, workspace *common.DevWorkspaceWithConfig, clusterAPI sync.ClusterAPI) error\n```\n\n```go\ntype EphemeralStorageProvisioner struct{}\n```\nThe EphemeralStorageProvisioner provisions all workspace storage as emptyDir volumes. Any local changes are lost when the workspace is stopped; its lifetime is tied to the underlying pod.\n\n```go\nfunc (e EphemeralStorageProvisioner) CleanupWorkspaceStorage(_ *common.DevWorkspaceWithConfig, _ sync.ClusterAPI) error\n```\n\n```go\nfunc (e EphemeralStorageProvisioner) NeedsStorage(_ *dw.DevWorkspaceTemplateSpec) bool\n```\n\n```go\nfunc (e EphemeralStorageProvisioner) ProvisionStorage(podAdditions *v1alpha1.PodAdditions, workspace *common.DevWorkspaceWithConfig, _ sync.ClusterAPI) error\n```\n\n```go\ntype PerWorkspaceStorageProvisioner struct{}\n```\nThe PerWorkspaceStorageProvisioner provisions one PVC per workspace and configures all volumes in the workspace to mount on subpaths within that PVC.\n\n```go\nfunc (*PerWorkspaceStorageProvisioner) CleanupWorkspaceStorage(workspace *common.DevWorkspaceWithConfig, clusterAPI sync.ClusterAPI) error\n```\nWe rely on Kubernetes to use the owner reference to automatically delete the PVC once the workspace is set for deletion.\n\n```go\nfunc (*PerWorkspaceStorageProvisioner) NeedsStorage(workspace *dw.DevWorkspaceTemplateSpec) bool\n```\nThis function is used to determine whether a finalizer should be applied to the DevWorkspace. Since the per-workspace PVC are cleaned up/deleted via Owner References when the workspace is deleted, no finalizer needs to be applied\n\n```go\nfunc (p *PerWorkspaceStorageProvisioner) ProvisionStorage(podAdditions *v1alpha1.PodAdditions, workspace *common.DevWorkspaceWithConfig, clusterAPI sync.ClusterAPI) error\n```\n\n```go\ntype Provisioner interface {\n\t// ProvisionStorage rewrites the volumes and volumeMounts in podAdditions to match the current storage policy and syncs any\n\t// out-of-pod required objects to the cluster.\n\t// Returns NotReadyError to signify that storage is not ready, ProvisioningError when a fatal issue is encountered,\n\t// and other error if there is an unexpected problem.\n\tProvisionStorage(podAdditions *v1alpha1.PodAdditions, workspace *common.DevWorkspaceWithConfig, clusterAPI sync.ClusterAPI) error\n\t// NeedsStorage returns whether the current workspace needs a PVC to be provisioned, given this storage strategy.\n\tNeedsStorage(workspace *dw.DevWorkspaceTemplateSpec) bool\n\t// CleanupWorkspaceStorage removes any objects provisioned by in the ProvisionStorage step that aren't automatically removed when a\n\t// DevWorkspace is deleted (e.g. delete subfolders in a common PVC assigned to the workspace)\n\t// Returns nil on success (DevWorkspace can be deleted), NotReadyError if additional reconciles are necessary, ProvisioningError when\n\t// a fatal issue is encountered, and any other error if an unexpected problem arises.\n\tCleanupWorkspaceStorage(workspace *common.DevWorkspaceWithConfig, clusterAPI sync.ClusterAPI) error\n}\n```\nProvisioner is an interface for rewriting volumeMounts in a pod according to a storage policy (e.g. common PVC for all mounts, etc.)\n\n```go\nfunc GetProvisioner(workspace *common.DevWorkspaceWithConfig) (Provisioner, error)\n```\nGetProvisioner returns the storage provisioner that should be used for the current workspace\n\n","path":"github.com/devfile/devworkspace-operator/pkg/provision/storage","name":"storage","synopsis":"Package storage contains library functions for provisioning volumes and volumeMounts in containers according to the volume components in a devfile.","isRedistributable":true}
