From 649a8b437d98d6e39f5e304b36950d00603a8806 Mon Sep 17 00:00:00 2001
From: Greg Miernicki <14550-gmiernicki@users.noreply.gitlab.example.com>
Date: Tue, 24 Jan 2023 21:51:08 +0000
Subject: [PATCH] Resolve "Mattermost packages: Update to meet standards"

---
 chart/templates/NOTES.txt                     |  6 +++++-
 .../gitrepository.yaml                        |  8 +++++---
 .../helmrelease.yaml                          | 20 ++++++++++---------
 .../imagepullsecret.yaml                      |  4 +++-
 .../namespace.yaml                            |  4 +++-
 .../values.yaml                               |  8 +++++---
 .../{mattermost => }/gitrepository.yaml       |  0
 .../{mattermost => }/helmrelease.yaml         |  0
 .../{mattermost => }/imagepullsecret.yaml     |  0
 .../{mattermost => }/namespace.yaml           |  0
 .../{mattermost => }/secret-ca.yaml           |  0
 .../{mattermost => }/secret-database.yaml     |  0
 .../{mattermost => }/secret-objectstore.yaml  |  0
 .../mattermost/{mattermost => }/values.yaml   |  0
 chart/values.yaml                             |  2 +-
 chart/values2.0.yaml                          |  2 +-
 .../configs/example/git-repo-values.yaml      |  2 +-
 docs/assets/scripts/airgap-dev/values.yaml    |  2 +-
 .../guides/using-bigbang/image-pull-policy.md |  2 +-
 tests/test-values.yaml                        |  2 +-
 20 files changed, 38 insertions(+), 24 deletions(-)
 rename chart/templates/{mattermost/operator => mattermost-operator}/gitrepository.yaml (53%)
 rename chart/templates/{mattermost/operator => mattermost-operator}/helmrelease.yaml (71%)
 rename chart/templates/{mattermost/operator => mattermost-operator}/imagepullsecret.yaml (65%)
 rename chart/templates/{mattermost/operator => mattermost-operator}/namespace.yaml (55%)
 rename chart/templates/{mattermost/operator => mattermost-operator}/values.yaml (53%)
 rename chart/templates/mattermost/{mattermost => }/gitrepository.yaml (100%)
 rename chart/templates/mattermost/{mattermost => }/helmrelease.yaml (100%)
 rename chart/templates/mattermost/{mattermost => }/imagepullsecret.yaml (100%)
 rename chart/templates/mattermost/{mattermost => }/namespace.yaml (100%)
 rename chart/templates/mattermost/{mattermost => }/secret-ca.yaml (100%)
 rename chart/templates/mattermost/{mattermost => }/secret-database.yaml (100%)
 rename chart/templates/mattermost/{mattermost => }/secret-objectstore.yaml (100%)
 rename chart/templates/mattermost/{mattermost => }/values.yaml (100%)

diff --git a/chart/templates/NOTES.txt b/chart/templates/NOTES.txt
index 56a0e4d479..aada4b045d 100644
--- a/chart/templates/NOTES.txt
+++ b/chart/templates/NOTES.txt
@@ -185,4 +185,8 @@ DEPRECATION NOTICE:
   Please reconfigure your values overrides to use .Values.addons.nexusRepositoryManager 
 {{- end }}
 
-
+{{- if .Values.addons.mattermostoperator }}
+DEPRECATION NOTICE:
+  .Values.addons.mattermostoperator has been deprecated and will be removed in a future Big Bang release.
+  Please reconfigure your values overrides to use .Values.addons.mattermostOperator 
+{{- end }}
diff --git a/chart/templates/mattermost/operator/gitrepository.yaml b/chart/templates/mattermost-operator/gitrepository.yaml
similarity index 53%
rename from chart/templates/mattermost/operator/gitrepository.yaml
rename to chart/templates/mattermost-operator/gitrepository.yaml
index 33e9e9d5c0..f738b15b4f 100644
--- a/chart/templates/mattermost/operator/gitrepository.yaml
+++ b/chart/templates/mattermost-operator/gitrepository.yaml
@@ -1,4 +1,6 @@
-{{- if and (eq (include "checkGitRef" .Values.addons.mattermostoperator) "true") (not .Values.offline) (or .Values.addons.mattermostoperator.enabled .Values.addons.mattermost.enabled) }}
+{{- $mmOpOldValues := default dict .Values.addons.mattermostoperator -}}
+{{- $mmOpValues := merge $mmOpOldValues .Values.addons.mattermostOperator -}}
+{{- if and (eq (include "checkGitRef" $mmOpValues) "true") (not .Values.offline) (or $mmOpValues.enabled .Values.addons.mattermost.enabled) }}
 apiVersion: source.toolkit.fluxcd.io/v1beta2
 kind: GitRepository
 metadata:
@@ -10,9 +12,9 @@ metadata:
     {{- include "commonLabels" . | nindent 4}}
 spec:
   interval: {{ .Values.flux.interval }}
-  url: {{ .Values.addons.mattermostoperator.git.repo }}
+  url: {{ $mmOpValues.git.repo }}
   ref:
-    {{- include "validRef" .Values.addons.mattermostoperator.git | nindent 4 }}
+    {{- include "validRef" $mmOpValues.git | nindent 4 }}
   {{ include "gitIgnore" . }}
   {{- include "gitCreds" . | nindent 2 }}
 {{- end }}
diff --git a/chart/templates/mattermost/operator/helmrelease.yaml b/chart/templates/mattermost-operator/helmrelease.yaml
similarity index 71%
rename from chart/templates/mattermost/operator/helmrelease.yaml
rename to chart/templates/mattermost-operator/helmrelease.yaml
index 8ff13def2e..0ca4d0a41f 100644
--- a/chart/templates/mattermost/operator/helmrelease.yaml
+++ b/chart/templates/mattermost-operator/helmrelease.yaml
@@ -1,5 +1,7 @@
-{{- $fluxSettingsMattermostOperator := merge .Values.addons.mattermostoperator.flux .Values.flux -}}
-{{- if or .Values.addons.mattermostoperator.enabled .Values.addons.mattermost.enabled }}
+{{- $mmOpOldValues := default dict .Values.addons.mattermostoperator -}}
+{{- $mmOpValues := merge $mmOpOldValues .Values.addons.mattermostOperator -}}
+{{- $fluxSettingsMattermostOperator := merge $mmOpValues.flux .Values.flux -}}
+{{- if or $mmOpValues.enabled .Values.addons.mattermost.enabled }}
 apiVersion: helm.toolkit.fluxcd.io/v2beta1
 kind: HelmRelease
 metadata:
@@ -13,27 +15,27 @@ spec:
   targetNamespace: mattermost-operator
   chart:
     spec:
-      {{- if eq (include "checkGitRef" .Values.addons.mattermostoperator) "true" }}
-      chart: {{ .Values.addons.mattermostoperator.git.path }}
+      {{- if eq (include "checkGitRef" $mmOpValues) "true" }}
+      chart: {{ $mmOpValues.git.path }}
       sourceRef:
         kind: GitRepository
         name: mattermost-operator
         namespace: {{ .Release.Namespace }}
       {{- else }}
-      chart: {{ .Values.addons.mattermostoperator.oci.name }}
-      version: {{ .Values.addons.mattermostoperator.oci.tag }}
+      chart: {{ $mmOpValues.oci.name }}
+      version: {{ $mmOpValues.oci.tag }}
       sourceRef:
         kind: HelmRepository
-        name: {{ .Values.addons.mattermostoperator.oci.repo }}
+        name: {{ $mmOpValues.oci.repo }}
         namespace: {{ .Release.Namespace }}
       {{- end }}
       interval: 5m
 
   {{- toYaml $fluxSettingsMattermostOperator | nindent 2 }}
   
-  {{- if .Values.addons.mattermostoperator.postRenderers }}
+  {{- if $mmOpValues.postRenderers }}
   postRenderers:
-  {{- toYaml .Values.addons.mattermostoperator.postRenderers | nindent 4 }}
+  {{- toYaml $mmOpValues.postRenderers | nindent 4 }}
   {{- end }}
   valuesFrom:
     - name: {{ .Release.Name }}-mattermost-operator-values
diff --git a/chart/templates/mattermost/operator/imagepullsecret.yaml b/chart/templates/mattermost-operator/imagepullsecret.yaml
similarity index 65%
rename from chart/templates/mattermost/operator/imagepullsecret.yaml
rename to chart/templates/mattermost-operator/imagepullsecret.yaml
index 3e94f0272e..f0727daa48 100644
--- a/chart/templates/mattermost/operator/imagepullsecret.yaml
+++ b/chart/templates/mattermost-operator/imagepullsecret.yaml
@@ -1,4 +1,6 @@
-{{- if or .Values.addons.mattermostoperator.enabled .Values.addons.mattermost.enabled }}
+{{- $mmOpOldValues := default dict .Values.addons.mattermostoperator -}}
+{{- $mmOpValues := merge $mmOpOldValues .Values.addons.mattermostOperator -}}
+{{- if or $mmOpValues.enabled .Values.addons.mattermost.enabled }}
 {{- if ( include "imagePullSecret" . ) }}
 apiVersion: v1
 kind: Secret
diff --git a/chart/templates/mattermost/operator/namespace.yaml b/chart/templates/mattermost-operator/namespace.yaml
similarity index 55%
rename from chart/templates/mattermost/operator/namespace.yaml
rename to chart/templates/mattermost-operator/namespace.yaml
index 4707ae7bf3..5e7b000cd8 100644
--- a/chart/templates/mattermost/operator/namespace.yaml
+++ b/chart/templates/mattermost-operator/namespace.yaml
@@ -1,4 +1,6 @@
-{{- if or .Values.addons.mattermostoperator.enabled .Values.addons.mattermost.enabled }}
+{{- $mmOpOldValues := default dict .Values.addons.mattermostoperator -}}
+{{- $mmOpValues := merge $mmOpOldValues .Values.addons.mattermostOperator -}}
+{{- if or $mmOpValues.enabled .Values.addons.mattermost.enabled }}
 apiVersion: v1
 kind: Namespace
 metadata:
diff --git a/chart/templates/mattermost/operator/values.yaml b/chart/templates/mattermost-operator/values.yaml
similarity index 53%
rename from chart/templates/mattermost/operator/values.yaml
rename to chart/templates/mattermost-operator/values.yaml
index abc7f1848d..0bdb31b9f6 100644
--- a/chart/templates/mattermost/operator/values.yaml
+++ b/chart/templates/mattermost-operator/values.yaml
@@ -1,8 +1,10 @@
-{{- if or .Values.addons.mattermostoperator.enabled .Values.addons.mattermost.enabled }}
-{{- include "values-secret" (dict "root" $ "package" .Values.addons.mattermostoperator "name" "mattermost-operator" "defaults" (include "bigbang.defaults.mattermostoperator" .)) }}
+{{- $mmOpOldValues := default dict .Values.addons.mattermostoperator -}}
+{{- $mmOpValues := merge $mmOpOldValues .Values.addons.mattermostOperator -}}
+{{- if or $mmOpValues.enabled .Values.addons.mattermost.enabled }}
+{{- include "values-secret" (dict "root" $ "package" $mmOpValues "name" "mattermost-operator" "defaults" (include "bigbang.defaults.mattermostOperator" .)) }}
 {{- end }}
 
-{{- define "bigbang.defaults.mattermostoperator" -}}
+{{- define "bigbang.defaults.mattermostOperator" -}}
 imagePullSecrets:
   - name: private-registry
 
diff --git a/chart/templates/mattermost/mattermost/gitrepository.yaml b/chart/templates/mattermost/gitrepository.yaml
similarity index 100%
rename from chart/templates/mattermost/mattermost/gitrepository.yaml
rename to chart/templates/mattermost/gitrepository.yaml
diff --git a/chart/templates/mattermost/mattermost/helmrelease.yaml b/chart/templates/mattermost/helmrelease.yaml
similarity index 100%
rename from chart/templates/mattermost/mattermost/helmrelease.yaml
rename to chart/templates/mattermost/helmrelease.yaml
diff --git a/chart/templates/mattermost/mattermost/imagepullsecret.yaml b/chart/templates/mattermost/imagepullsecret.yaml
similarity index 100%
rename from chart/templates/mattermost/mattermost/imagepullsecret.yaml
rename to chart/templates/mattermost/imagepullsecret.yaml
diff --git a/chart/templates/mattermost/mattermost/namespace.yaml b/chart/templates/mattermost/namespace.yaml
similarity index 100%
rename from chart/templates/mattermost/mattermost/namespace.yaml
rename to chart/templates/mattermost/namespace.yaml
diff --git a/chart/templates/mattermost/mattermost/secret-ca.yaml b/chart/templates/mattermost/secret-ca.yaml
similarity index 100%
rename from chart/templates/mattermost/mattermost/secret-ca.yaml
rename to chart/templates/mattermost/secret-ca.yaml
diff --git a/chart/templates/mattermost/mattermost/secret-database.yaml b/chart/templates/mattermost/secret-database.yaml
similarity index 100%
rename from chart/templates/mattermost/mattermost/secret-database.yaml
rename to chart/templates/mattermost/secret-database.yaml
diff --git a/chart/templates/mattermost/mattermost/secret-objectstore.yaml b/chart/templates/mattermost/secret-objectstore.yaml
similarity index 100%
rename from chart/templates/mattermost/mattermost/secret-objectstore.yaml
rename to chart/templates/mattermost/secret-objectstore.yaml
diff --git a/chart/templates/mattermost/mattermost/values.yaml b/chart/templates/mattermost/values.yaml
similarity index 100%
rename from chart/templates/mattermost/mattermost/values.yaml
rename to chart/templates/mattermost/values.yaml
diff --git a/chart/values.yaml b/chart/values.yaml
index 1b04790744..ddf323c5a7 100644
--- a/chart/values.yaml
+++ b/chart/values.yaml
@@ -1254,7 +1254,7 @@ addons:
   # ----------------------------------------------------------------------------------------------------------------------
   # Mattermost Operator and Instance
   #
-  mattermostoperator:
+  mattermostOperator:
     enabled: false
     git:
       repo: https://repo1.dso.mil/platform-one/big-bang/apps/collaboration-tools/mattermost-operator.git
diff --git a/chart/values2.0.yaml b/chart/values2.0.yaml
index 79e53cf2ac..2eecd35bc2 100644
--- a/chart/values2.0.yaml
+++ b/chart/values2.0.yaml
@@ -200,7 +200,7 @@ addons:
       tag: "1.20.0-bb.1"
       repo: "registry1"
 
-  mattermostoperator:
+  mattermostOperator:
     git: null
     oci:
       name: "mattermost-operator"
diff --git a/docs/assets/configs/example/git-repo-values.yaml b/docs/assets/configs/example/git-repo-values.yaml
index 2be0711d5f..a8ab14c5c1 100644
--- a/docs/assets/configs/example/git-repo-values.yaml
+++ b/docs/assets/configs/example/git-repo-values.yaml
@@ -160,7 +160,7 @@ addons:
       repo: https://repo1.dso.mil/platform-one/big-bang/apps/security-tools/anchore-enterprise.git
       path: "./chart"
       branch: "my-dev-branch"
-  mattermostoperator:
+  mattermostOperator:
     git:
       repo: https://repo1.dso.mil/platform-one/big-bang/apps/collaboration-tools/mattermost-operator.git
       path: "./chart"
diff --git a/docs/assets/scripts/airgap-dev/values.yaml b/docs/assets/scripts/airgap-dev/values.yaml
index 7d1d0fb431..d2c6f5d376 100644
--- a/docs/assets/scripts/airgap-dev/values.yaml
+++ b/docs/assets/scripts/airgap-dev/values.yaml
@@ -107,7 +107,7 @@ addons:
     enabled: false
     git:
       repo: ssh://git@host.k3d.internal/home/git/repos/haproxy
-  mattermostoperator:
+  mattermostOperator:
     enabled: false
     git:
       repo: ssh://git@host.k3d.internal/home/git/repos/mattermost-operator
diff --git a/docs/guides/using-bigbang/image-pull-policy.md b/docs/guides/using-bigbang/image-pull-policy.md
index 4dde9fbdce..358c8f1d4e 100644
--- a/docs/guides/using-bigbang/image-pull-policy.md
+++ b/docs/guides/using-bigbang/image-pull-policy.md
@@ -35,7 +35,7 @@ We have also documented the package overrides required if you want to set a sing
 | Nexus | `IfNotPresent` | <pre lang="yaml">addons:<br>  nexusRepositoryManager:<br>    values:<br>      image:<br>        pullPolicy: IfNotPresent<br>      job_image:<br>        pullPolicy: IfNotPresent</pre> |
 | Sonarqube | `IfNotPresent` | <pre lang="yaml">addons:<br>  sonarqube:<br>    values:<br>      image:<br>        pullPolicy: IfNotPresent</pre> |
 | Anchore | `IfNotPresent` | <pre lang="yaml">addons:<br>  anchore:<br>    values:<br>      anchoreGlobal:<br>        imagePullPolicy: IfNotPresent<br>      anchoreEnterpriseGlobal:<br>        imagePullPolicy: IfNotPresent<br>      anchoreEnterpriseUi:<br>        imagePullPolicy: IfNotPresent</pre> |
-| Mattermost Operator | `IfNotPresent` | <pre lang="yaml">addons:<br>  mattermostoperator:<br>    values:<br>      image:<br>        imagePullPolicy: IfNotPresent</pre> |
+| Mattermost Operator | `IfNotPresent` | <pre lang="yaml">addons:<br>  mattermostOperator:<br>    values:<br>      image:<br>        imagePullPolicy: IfNotPresent</pre> |
 | Mattermost | `IfNotPresent` | <pre lang="yaml">addons:<br>  mattermost:<br>    values:<br>      image:<br>        imagePullPolicy: IfNotPresent</pre> |
 | Velero | `IfNotPresent` | <pre lang="yaml">addons:<br>  velero:<br>    values:<br>      image:<br>        pullPolicy: IfNotPresent</pre> |
 | Keycloak | `IfNotPresent` | <pre lang="yaml">addons:<br>  keycloak:<br>    values:<br>      image:<br>        pullPolicy: IfNotPresent<br>      pgchecker:<br>        image:<br>          pullPolicy: IfNotPresent</pre> |
diff --git a/tests/test-values.yaml b/tests/test-values.yaml
index 68b5b96b4e..0e69056d34 100644
--- a/tests/test-values.yaml
+++ b/tests/test-values.yaml
@@ -1247,7 +1247,7 @@ addons:
             MINIO_PORT: ''
             MINIO_HOST: 'https://minio-api.bigbang.dev'
 
-  mattermostoperator:
+  mattermostOperator:
     enabled: false
 
   mattermost:
-- 
GitLab