Skip to content

Commit

Permalink
Add DWOC field for persisting home directory
Browse files Browse the repository at this point in the history
Part of devfile#1097

Signed-off-by: Andrew Obuchowicz <aobuchow@redhat.com>
  • Loading branch information
AObuchow committed May 15, 2023
1 parent 89370ce commit 24d8e21
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions apis/controller/v1alpha1/devworkspaceoperatorconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion pkg/config/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 13 additions & 0 deletions pkg/config/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
}
Expand Down

0 comments on commit 24d8e21

Please sign in to comment.