Skip to content

Commit

Permalink
Fix slices values
Browse files Browse the repository at this point in the history
The only valid slice type for `unstructured` is `[]any` or
`[]interface{}`.
  • Loading branch information
Kidswiss committed Jan 7, 2025
1 parent efb45b7 commit 7bbb14d
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 52 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file added apis/.DS_Store
Binary file not shown.
Binary file added apis/apiserver/.DS_Store
Binary file not shown.
Binary file added apis/vshn/.DS_Store
Binary file not shown.
Binary file added docs/modules/ROOT/assets/.DS_Store
Binary file not shown.
Binary file added pkg/.DS_Store
Binary file not shown.
Binary file added pkg/apiserver/.DS_Store
Binary file not shown.
Binary file added pkg/apiserver/vshn/.DS_Store
Binary file not shown.
95 changes: 43 additions & 52 deletions pkg/comp-functions/functions/vshnnextcloud/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"sigs.k8s.io/yaml"
)

const (
Expand Down Expand Up @@ -397,57 +396,54 @@ func newRelease(ctx context.Context, svc *runtime.ServiceRuntime, comp *vshnv1.V
}

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

stringSidecarContainers, err := toYAML(extraSidecarContainers)
if err != nil {
return fmt.Errorf("cannot parse extraSidecarContainers: %w", err)
}

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

func addApacheConfig(svc *runtime.ServiceRuntime, comp *vshnv1.VSHNNextcloud) error {
Expand Down Expand Up @@ -505,8 +501,3 @@ func validateFQDNs(fqdns []string) error {
}
return nil
}

func toYAML(obj any) (string, error) {
yamlBytes, err := yaml.Marshal(obj)
return string(yamlBytes), err
}

0 comments on commit 7bbb14d

Please sign in to comment.