diff --git a/apis/controller/v1alpha1/devworkspaceoperatorconfig_types.go b/apis/controller/v1alpha1/devworkspaceoperatorconfig_types.go index 31bc96e47..9169e4fea 100644 --- a/apis/controller/v1alpha1/devworkspaceoperatorconfig_types.go +++ b/apis/controller/v1alpha1/devworkspaceoperatorconfig_types.go @@ -98,6 +98,9 @@ type WorkspaceConfig struct { // DefaultStorageSize defines an optional struct with fields to specify the sizes of Persistent Volume Claims for storage // classes used by DevWorkspaces. DefaultStorageSize *StorageSizes `json:"defaultStorageSize,omitempty"` + // PersistUserHome defines configuration options for persisting the `/home/user/` + // directory in workspaces. + PersistUserHome *PersistentHomeConfig `json:"persistUserHome,omitempty"` // IdleTimeout determines how long a workspace should sit idle before being // automatically scaled down. Proper functionality of this configuration property // requires support in the workspace being started. If not specified, the default diff --git a/pkg/config/defaults.go b/pkg/config/defaults.go index c145dea3b..c76365233 100644 --- a/pkg/config/defaults.go +++ b/pkg/config/defaults.go @@ -43,9 +43,12 @@ var defaultConfig = &v1alpha1.OperatorConfiguration{ Common: &commonStorageSize, PerWorkspace: &perWorkspaceStorageSize, }, + PersistUserHome: &v1alpha1.PersistentHomeConfig{ + Enabled: pointer.Bool(false), + }, IdleTimeout: "15m", ProgressTimeout: "5m", - CleanupOnStop: pointer.BoolPtr(false), + CleanupOnStop: pointer.Bool(false), PodSecurityContext: nil, ContainerSecurityContext: &corev1.SecurityContext{}, DefaultTemplate: nil, diff --git a/pkg/config/sync.go b/pkg/config/sync.go index 51ff528ec..0805f60ba 100644 --- a/pkg/config/sync.go +++ b/pkg/config/sync.go @@ -327,6 +327,14 @@ func mergeConfig(from, to *controller.OperatorConfiguration) { to.Workspace.DefaultStorageSize.PerWorkspace = &perWorkspaceSizeCopy } } + if from.Workspace.PersistUserHome != nil { + if to.Workspace.PersistUserHome == nil { + to.Workspace.PersistUserHome = &controller.PersistentHomeConfig{} + } + if from.Workspace.PersistUserHome.Enabled != nil { + to.Workspace.PersistUserHome.Enabled = from.Workspace.PersistUserHome.Enabled + } + } if from.Workspace.DefaultTemplate != nil { templateSpecContentCopy := from.Workspace.DefaultTemplate.DeepCopy() to.Workspace.DefaultTemplate = templateSpecContentCopy @@ -500,6 +508,11 @@ func GetCurrentConfigString(currConfig *controller.OperatorConfiguration) string config = append(config, fmt.Sprintf("workspace.defaultStorageSize.perWorkspace=%s", workspace.DefaultStorageSize.PerWorkspace.String())) } } + if workspace.PersistUserHome != nil { + if workspace.PersistUserHome.Enabled != nil && *workspace.PersistUserHome.Enabled != *defaultConfig.Workspace.PersistUserHome.Enabled { + config = append(config, fmt.Sprintf("workspace.persistUserHomeDierctory.enabled=%t", *workspace.PersistUserHome.Enabled)) + } + } if !reflect.DeepEqual(workspace.PodSecurityContext, defaultConfig.Workspace.PodSecurityContext) { config = append(config, "workspace.podSecurityContext is set") }