Skip to content

Commit

Permalink
Merge pull request #289 from vshn/nextcloud/fix_cronjob
Browse files Browse the repository at this point in the history
Add sidecar for nextcloud cron jobs
  • Loading branch information
TheBigLee authored Jan 10, 2025
2 parents 25d65f1 + 36a812f commit 4c18672
Showing 1 changed file with 58 additions and 1 deletion.
59 changes: 58 additions & 1 deletion pkg/comp-functions/functions/vshnnextcloud/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
)

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

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

err = configureCronSidecar(values, version)
if err != nil {
return nil, fmt.Errorf("cannot set keycloak version for cron sidecar: %w", err)
}

release, err := common.NewRelease(ctx, svc, comp, values)

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

return release, err
}

func configureCronSidecar(values map[string]interface{}, version string) error {
extraSidecarContainers := []any{
map[string]any{
"name": "cron",
"command": []any{
"/cron.sh",
},
"image": "nextcloud:" + version,
"volumeMounts": []any{
map[string]any{
"mountPath": "/var/www",
"name": "nextcloud-main",
"subpath": "root",
},
map[string]any{
"mountPath": "/var/www/html",
"name": "nextcloud-main",
"subPath": "html",
},
map[string]any{
"mountPath": "/var/www/html/data",
"name": "nextcloud-main",
"subPath": "data",
},
map[string]any{
"mountPath": "/var/www/html/config",
"name": "nextcloud-main",
"subPath": "config",
},
map[string]any{
"mountPath": "/var/www/html/custom_apps",
"name": "nextcloud-main",
"subPath": "custom_apps",
},
map[string]any{
"mountPath": "/var/www/tmp",
"name": "nextcloud-main",
"subPath": "tmp",
},
map[string]any{
"mountPath": "/var/www/html/themes",
"name": "nextcloud-main",
"subPath": "themes",
},
},
},
}

return unstructured.SetNestedSlice(values, extraSidecarContainers, []string{"nextcloud", "extraSidecarContainers"}...)
}

func addApacheConfig(svc *runtime.ServiceRuntime, comp *vshnv1.VSHNNextcloud) error {

cm := &v1.ConfigMap{
Expand Down

0 comments on commit 4c18672

Please sign in to comment.