Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sidecar for nextcloud cron jobs #289

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading