Skip to content

Commit 51ee363

Browse files
committed
fixup! fixup! fixup! fixup! fixup! fix
Signed-off-by: Oleksii Kurinnyi <[email protected]>
1 parent 2812a14 commit 51ee363

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

controllers/workspace/devworkspace_controller.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,6 @@ import (
6868
"sigs.k8s.io/controller-runtime/pkg/reconcile"
6969
)
7070

71-
// ensureHomeInitContainerFields ensures that an init-persistent-home container has
72-
// the correct Command and VolumeMounts.
73-
func ensureHomeInitContainerFields(c *corev1.Container) error {
74-
// Set default command only if not provided
75-
if len(c.Command) == 0 {
76-
c.Command = []string{"/bin/sh", "-c"}
77-
}
78-
c.VolumeMounts = []corev1.VolumeMount{{
79-
Name: constants.HomeVolumeName,
80-
MountPath: constants.HomeUserDirectory,
81-
}}
82-
return nil
83-
}
8471

8572
const (
8673
startingWorkspaceRequeueInterval = 5 * time.Second
@@ -416,7 +403,7 @@ func (r *DevWorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request
416403
// Ensure init-persistent-home container has correct fields after merge
417404
for i := range merged {
418405
if merged[i].Name == constants.HomeInitComponentName {
419-
if err := ensureHomeInitContainerFields(&merged[i]); err != nil {
406+
if err := home.EnsureHomeInitContainerFields(&merged[i]); err != nil {
420407
return r.failWorkspace(workspace, fmt.Sprintf("Failed to configure %s container: %s", constants.HomeInitComponentName, err), metrics.ReasonBadRequest, reqLogger, &reconcileStatus), nil
421408
}
422409
}

pkg/library/home/persistentHome.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
devfilevalidation "github.com/devfile/api/v2/pkg/validation"
2323
"github.com/devfile/devworkspace-operator/pkg/provision/storage"
2424
"k8s.io/utils/pointer"
25+
corev1 "k8s.io/api/core/v1"
2526

2627
"github.com/devfile/devworkspace-operator/pkg/common"
2728
"github.com/devfile/devworkspace-operator/pkg/constants"
@@ -227,3 +228,17 @@ func inferInitContainer(dwTemplateSpec *v1alpha2.DevWorkspaceTemplateSpec) *v1al
227228
}
228229
return nil
229230
}
231+
232+
// EnsureHomeInitContainerFields ensures that an init-persistent-home container has
233+
// the correct Command and VolumeMounts.
234+
func EnsureHomeInitContainerFields(c *corev1.Container) error {
235+
// Set default command only if not provided
236+
if len(c.Command) == 0 {
237+
c.Command = []string{"/bin/sh", "-c"}
238+
}
239+
c.VolumeMounts = []corev1.VolumeMount{{
240+
Name: constants.HomeVolumeName,
241+
MountPath: constants.HomeUserDirectory,
242+
}}
243+
return nil
244+
}

0 commit comments

Comments
 (0)