Skip to content

Commit 4c18672

Browse files
authored
Merge pull request #289 from vshn/nextcloud/fix_cronjob
Add sidecar for nextcloud cron jobs
2 parents 25d65f1 + 36a812f commit 4c18672

File tree

1 file changed

+58
-1
lines changed
  • pkg/comp-functions/functions/vshnnextcloud

1 file changed

+58
-1
lines changed

pkg/comp-functions/functions/vshnnextcloud/deploy.go

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
corev1 "k8s.io/api/core/v1"
2121
v1 "k8s.io/api/core/v1"
2222
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23+
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2324
)
2425

2526
const (
@@ -382,18 +383,74 @@ func newRelease(ctx context.Context, svc *runtime.ServiceRuntime, comp *vshnv1.V
382383
return nil, fmt.Errorf("cannot get observed release values: %w", err)
383384
}
384385

385-
_, err = maintenance.SetReleaseVersion(ctx, comp.Spec.Parameters.Service.Version, values, observedValues, []string{"image", "tag"})
386+
version, err := maintenance.SetReleaseVersion(ctx, comp.Spec.Parameters.Service.Version, values, observedValues, []string{"image", "tag"})
386387
if err != nil {
387388
return nil, fmt.Errorf("cannot set keycloak version for release: %w", err)
388389
}
389390

391+
err = configureCronSidecar(values, version)
392+
if err != nil {
393+
return nil, fmt.Errorf("cannot set keycloak version for cron sidecar: %w", err)
394+
}
395+
390396
release, err := common.NewRelease(ctx, svc, comp, values)
391397

392398
release.Spec.ForProvider.Chart.Name = "nextcloud"
393399

394400
return release, err
395401
}
396402

403+
func configureCronSidecar(values map[string]interface{}, version string) error {
404+
extraSidecarContainers := []any{
405+
map[string]any{
406+
"name": "cron",
407+
"command": []any{
408+
"/cron.sh",
409+
},
410+
"image": "nextcloud:" + version,
411+
"volumeMounts": []any{
412+
map[string]any{
413+
"mountPath": "/var/www",
414+
"name": "nextcloud-main",
415+
"subpath": "root",
416+
},
417+
map[string]any{
418+
"mountPath": "/var/www/html",
419+
"name": "nextcloud-main",
420+
"subPath": "html",
421+
},
422+
map[string]any{
423+
"mountPath": "/var/www/html/data",
424+
"name": "nextcloud-main",
425+
"subPath": "data",
426+
},
427+
map[string]any{
428+
"mountPath": "/var/www/html/config",
429+
"name": "nextcloud-main",
430+
"subPath": "config",
431+
},
432+
map[string]any{
433+
"mountPath": "/var/www/html/custom_apps",
434+
"name": "nextcloud-main",
435+
"subPath": "custom_apps",
436+
},
437+
map[string]any{
438+
"mountPath": "/var/www/tmp",
439+
"name": "nextcloud-main",
440+
"subPath": "tmp",
441+
},
442+
map[string]any{
443+
"mountPath": "/var/www/html/themes",
444+
"name": "nextcloud-main",
445+
"subPath": "themes",
446+
},
447+
},
448+
},
449+
}
450+
451+
return unstructured.SetNestedSlice(values, extraSidecarContainers, []string{"nextcloud", "extraSidecarContainers"}...)
452+
}
453+
397454
func addApacheConfig(svc *runtime.ServiceRuntime, comp *vshnv1.VSHNNextcloud) error {
398455

399456
cm := &v1.ConfigMap{

0 commit comments

Comments
 (0)