From 70f103fce93908fee4e86051349edcc6115b88d6 Mon Sep 17 00:00:00 2001
From: Syrine Neifar <syrine@greenhost.nl>
Date: Wed, 19 Apr 2023 11:49:38 +0200
Subject: [PATCH] add a custom_apps list to the chart values

---
 README.md                                  | 35 +++++++++++++---------
 templates/nextcloud-onlyoffice-config.yaml |  4 ++-
 values-local.yaml.example                  | 33 ++++++++++----------
 values.yaml                                | 25 ++++++++++++++++
 4 files changed, 66 insertions(+), 31 deletions(-)

diff --git a/README.md b/README.md
index 17e5091e..6ad4571d 100644
--- a/README.md
+++ b/README.md
@@ -107,12 +107,18 @@ through the Apps screen in Nextcloud.
 Apps that are installed this way are automatically updated to their newest
 version every time Nextcloud is updated.
 
-To install apps, edit the values.yaml file:
+To install apps, edit the values.yaml file by adding your app config under:
+- `default_apps` if this app will part of the Stackspin defaults.
+- `custom_apps` if you're installing this app only for a specific cluster.
 
 ```yaml
 apps:
-  - name: sociallogin  # Installs sociallogin app
-    enabled: false     # Disables sociallogin by default
+  default_apps:
+    - name: sociallogin  # Installs sociallogin app
+      enabled: false     # Disables sociallogin by default
+  custom_apps:
+    - name: polls
+      enabled: false
 ```
 
 Note that manually enabled apps will not be disabled upon rerunning the installer,
@@ -126,17 +132,18 @@ To install an app from GitHub releases:
 
 ```yaml
 apps:
-  - name: onlyoffice
-    # The name of the repository. This is the name for a repository located at
-    # https://github.com/ONLYOFFICE/onlyoffice-nextcloud:
-    github_repository: ONLYOFFICE/onlyoffice-nextcloud
-    # The version to install or upgrade the app to
-    version: 7.5.4
-    # The name of the "asset" to download from this release. This name can be
-    # found on https://github.com/ONLYOFFICE/onlyoffice-nextcloud/releases
-    release_filename: onlyoffice.tar.gz
-    # Enable the app after installing it
-    enabled: true
+  default_apps:
+    - name: onlyoffice
+      # The name of the repository. This is the name for a repository located at
+      # https://github.com/ONLYOFFICE/onlyoffice-nextcloud:
+      github_repository: ONLYOFFICE/onlyoffice-nextcloud
+      # The version to install or upgrade the app to
+      version: 7.5.4
+      # The name of the "asset" to download from this release. This name can be
+      # found on https://github.com/ONLYOFFICE/onlyoffice-nextcloud/releases
+      release_filename: onlyoffice.tar.gz
+      # Enable the app after installing it
+      enabled: true
 ```
 
 
diff --git a/templates/nextcloud-onlyoffice-config.yaml b/templates/nextcloud-onlyoffice-config.yaml
index b3fddb34..4bee1bf1 100644
--- a/templates/nextcloud-onlyoffice-config.yaml
+++ b/templates/nextcloud-onlyoffice-config.yaml
@@ -126,7 +126,8 @@ data:
     echo "app versions found"
 
     # Install all apps declared in the `apps` helm values array
-    {{- range .Values.apps }}
+    {{- range $apps_type, $apps := .Values.apps }}
+    {{- range $apps }}  
     {{- if not .name }}
       echo "Skipping app {{ . }} without name variable set"
     {{- else if and .github_repository .version .release_filename }}
@@ -178,6 +179,7 @@ data:
     # Enable {{ .name }} app
     run_as "php $occ app:enable {{ .name }}"
     {{ end }} # end if .enabled
+    {{ end }} # end range $apps
     {{ end }} # end range .Values.apps
 
     # Some of the manually installed apps might need to run upgrade scripts, run
diff --git a/values-local.yaml.example b/values-local.yaml.example
index 5dcccbc7..a73249e0 100644
--- a/values-local.yaml.example
+++ b/values-local.yaml.example
@@ -67,22 +67,23 @@ rabbitmq:
 
 # apps controls which apps will be installed and enabled in nextcloud
 # apps:
-#   - name: sociallogin
-#     # apps[0].enabled needs to be set to true if you want to enable login via an external
-#     # oauth server. In that case you need to configure all the values in `sociallogin`
-#     enabled: false
-#   - name: onlyoffice
-#     enabled: true
-#   - name: polls
-#     # Install an app from a github repository. This has the advantage that you
-#     # can pin the version number, so it does not get auto-updated to breaking
-#     # versions.
-#     # Note: you can use the version number in the release_filename variable if
-#     # needed, as written here:
-#     github_repository: nextcloud/polls
-#     version: 3.8.1
-#     release_filename: polls-{{ .version }}.tar.gz
-#     enabled: true
+#   default_apps:
+#     - name: sociallogin
+#       # apps[0].enabled needs to be set to true if you want to enable login via an external
+#       # oauth server. In that case you need to configure all the values in `sociallogin`
+#       enabled: false
+#     - name: onlyoffice
+#       enabled: true
+#     - name: polls
+#       # Install an app from a github repository. This has the advantage that you
+#       # can pin the version number, so it does not get auto-updated to breaking
+#       # versions.
+#       # Note: you can use the version number in the release_filename variable if
+#       # needed, as written here:
+#       github_repository: nextcloud/polls
+#       version: 3.8.1
+#       release_filename: polls-{{ .version }}.tar.gz
+#       enabled: true
 
 # sociallogin enables login via oAuth/Open-ID Connect
 # sociallogin:
diff --git a/values.yaml b/values.yaml
index 815e5f5c..e5b8dc3e 100644
--- a/values.yaml
+++ b/values.yaml
@@ -61,6 +61,7 @@ nextcloud:
       - "/var/local/setup-apps.sh"
 
 apps:
+<<<<<<< HEAD
   - name: sociallogin
     # apps[0].enabled needs to be set to true if you want to enable login via an external
     # oauth server. In that case you need to configure all the values in `sociallogin`
@@ -77,6 +78,30 @@ apps:
     version: v7.8.0
     release_filename: onlyoffice.tar.gz
     enabled: true
+=======
+  default_apps:
+    - name: sociallogin
+      # apps[0].enabled needs to be set to true if you want to enable login via an external
+      # oauth server. In that case you need to configure all the values in `sociallogin`
+      enabled: false
+      # Line order is important here for renovatebot! first github_repository,
+      # then version
+      github_repository: zorn-v/nextcloud-social-login
+      version: v5.4.3
+      release_filename: release.tar.gz
+    - name: onlyoffice
+      # Line order is important here for renovatebot! first github_repository,
+      # then version
+      enabled: true
+      github_repository: ONLYOFFICE/onlyoffice-nextcloud
+      version: v7.8.0
+      release_filename: onlyoffice.tar.gz
+  custom_apps:
+      # Apps you want to add that are not part of Stackspin defaults.
+    - name: polls
+      enabled: false
+
+>>>>>>> 28ef4ee (add a custom_apps list to the chart values)
 
 setupApps:
   # How many times the setup-apps job can try and fail before it is marked as
-- 
GitLab