diff --git a/README.md b/README.md index 36e5167..da4dafe 100644 --- a/README.md +++ b/README.md @@ -196,6 +196,8 @@ The generated `chart/values.yaml` contains two types of information: After execution, the `runtime-values.yaml` file is created in the chart folder of your project directory. +> **Note:** By default, the `CAPApplicationVersion` resource uses the Helm release revision as its version (`.Release.Revision`). If you are not using `helm install`/`helm upgrade` directly — for example, when templating the chart and applying the rendered manifests via GitOps tools like Argo CD, the revision may always be `1`. In such cases, you can explicitly set a version string via `app.version` in your runtime-values.yaml (e.g., `app.version: "1.2.3"`). When set, this value takes precedence over the release revision. + 7. Now, you can deploy the application using the following command: ```sh diff --git a/files/chart/values.schema.json b/files/chart/values.schema.json index 2b3608a..2116939 100644 --- a/files/chart/values.schema.json +++ b/files/chart/values.schema.json @@ -3204,6 +3204,9 @@ "type": "string" }, "type": "object" + }, + "version": { + "type": "string" } }, "required": [ diff --git a/files/configurableTemplatesChart/values.schema.json b/files/configurableTemplatesChart/values.schema.json index 0242b5d..fe96a34 100644 --- a/files/configurableTemplatesChart/values.schema.json +++ b/files/configurableTemplatesChart/values.schema.json @@ -127,6 +127,9 @@ "type": "string" }, "type": "object" + }, + "version": { + "type": "string" } }, "required": [ diff --git a/hack/schema-generation.go b/hack/schema-generation.go index 732f995..53a426b 100644 --- a/hack/schema-generation.go +++ b/hack/schema-generation.go @@ -30,6 +30,7 @@ type provider struct { type app struct { Domains Domains `json:"domains"` IstioIngressGatewayLabels map[string]string `json:"istioIngressGatewayLabels"` + Version string `json:"version,omitempty"` } type serviceInstanceExt struct { diff --git a/lib/util.js b/lib/util.js index 3d6e991..03aaaef 100644 --- a/lib/util.js +++ b/lib/util.js @@ -318,7 +318,7 @@ function writeCAPApplicationVersionCommonCRO(yaml) { ' name: {{ include "capApplicationVersionName" $ }}', 'spec:', ' capApplicationInstance: {{ include "appName" $ }}', - ' version: "{{ .Release.Revision }}"', + ' version: "{{ .Values.app.version | default .Release.Revision }}"', ' registrySecrets:', ' {{- range .Values.imagePullSecrets }}', ' - {{ . }}', @@ -689,7 +689,7 @@ function getHelperTpl(project, isConfigurableTemplateChart) { yaml.push([ '{{- define "capApplicationVersionName" -}}', - '{{ printf "%s-%d" (include "appName" $) (.Release.Revision) }}', + '{{ printf "%s-%v" (include "appName" $) (.Values.app.version | default .Release.Revision) }}', '{{- end -}}', '\n', '{{- define "domainName" -}}', diff --git a/test/files/expectedChart/templates/_helpers-ias.tpl b/test/files/expectedChart/templates/_helpers-ias.tpl index 3150d35..94b156b 100644 --- a/test/files/expectedChart/templates/_helpers-ias.tpl +++ b/test/files/expectedChart/templates/_helpers-ias.tpl @@ -1,5 +1,5 @@ {{- define "capApplicationVersionName" -}} -{{ printf "%s-%d" (include "appName" $) (.Release.Revision) }} +{{ printf "%s-%v" (include "appName" $) (.Values.app.version | default .Release.Revision) }} {{- end -}} {{- define "domainName" -}} diff --git a/test/files/expectedChart/templates/_helpers.tpl b/test/files/expectedChart/templates/_helpers.tpl index 38fd357..4164184 100644 --- a/test/files/expectedChart/templates/_helpers.tpl +++ b/test/files/expectedChart/templates/_helpers.tpl @@ -1,5 +1,5 @@ {{- define "capApplicationVersionName" -}} -{{ printf "%s-%d" (include "appName" $) (.Release.Revision) }} +{{ printf "%s-%v" (include "appName" $) (.Values.app.version | default .Release.Revision) }} {{- end -}} {{- define "domainName" -}} diff --git a/test/files/expectedChart/templates/cap-operator-cros-ias.yaml b/test/files/expectedChart/templates/cap-operator-cros-ias.yaml index 6f2d3b4..8e8c8a6 100644 --- a/test/files/expectedChart/templates/cap-operator-cros-ias.yaml +++ b/test/files/expectedChart/templates/cap-operator-cros-ias.yaml @@ -51,7 +51,7 @@ metadata: name: {{ include "capApplicationVersionName" $ }} spec: capApplicationInstance: {{ include "appName" $ }} - version: "{{ .Release.Revision }}" + version: "{{ .Values.app.version | default .Release.Revision }}" registrySecrets: {{- range .Values.imagePullSecrets }} - {{ . }} diff --git a/test/files/expectedChart/templates/cap-operator-cros-svc-ias.yaml b/test/files/expectedChart/templates/cap-operator-cros-svc-ias.yaml index 6c77b32..077fb42 100644 --- a/test/files/expectedChart/templates/cap-operator-cros-svc-ias.yaml +++ b/test/files/expectedChart/templates/cap-operator-cros-svc-ias.yaml @@ -48,7 +48,7 @@ metadata: name: {{ include "capApplicationVersionName" $ }} spec: capApplicationInstance: {{ include "appName" $ }} - version: "{{ .Release.Revision }}" + version: "{{ .Values.app.version | default .Release.Revision }}" registrySecrets: {{- range .Values.imagePullSecrets }} - {{ . }} diff --git a/test/files/expectedChart/templates/cap-operator-cros-svc.yaml b/test/files/expectedChart/templates/cap-operator-cros-svc.yaml index 3565c76..4126d6c 100644 --- a/test/files/expectedChart/templates/cap-operator-cros-svc.yaml +++ b/test/files/expectedChart/templates/cap-operator-cros-svc.yaml @@ -43,7 +43,7 @@ metadata: name: {{ include "capApplicationVersionName" $ }} spec: capApplicationInstance: {{ include "appName" $ }} - version: "{{ .Release.Revision }}" + version: "{{ .Values.app.version | default .Release.Revision }}" registrySecrets: {{- range .Values.imagePullSecrets }} - {{ . }} diff --git a/test/files/expectedChart/templates/cap-operator-cros.yaml b/test/files/expectedChart/templates/cap-operator-cros.yaml index 40303f7..ec7fe5a 100644 --- a/test/files/expectedChart/templates/cap-operator-cros.yaml +++ b/test/files/expectedChart/templates/cap-operator-cros.yaml @@ -46,7 +46,7 @@ metadata: name: {{ include "capApplicationVersionName" $ }} spec: capApplicationInstance: {{ include "appName" $ }} - version: "{{ .Release.Revision }}" + version: "{{ .Values.app.version | default .Release.Revision }}" registrySecrets: {{- range .Values.imagePullSecrets }} - {{ . }} diff --git a/test/files/expectedConfigurableTemplatesChart/templates/_helpers-ias.tpl b/test/files/expectedConfigurableTemplatesChart/templates/_helpers-ias.tpl index 9d60db4..cc5634c 100644 --- a/test/files/expectedConfigurableTemplatesChart/templates/_helpers-ias.tpl +++ b/test/files/expectedConfigurableTemplatesChart/templates/_helpers-ias.tpl @@ -1,5 +1,5 @@ {{- define "capApplicationVersionName" -}} -{{ printf "%s-%d" (include "appName" $) (.Release.Revision) }} +{{ printf "%s-%v" (include "appName" $) (.Values.app.version | default .Release.Revision) }} {{- end -}} {{- define "domainName" -}} diff --git a/test/files/expectedConfigurableTemplatesChart/templates/_helpers.tpl b/test/files/expectedConfigurableTemplatesChart/templates/_helpers.tpl index 51d898b..772544d 100644 --- a/test/files/expectedConfigurableTemplatesChart/templates/_helpers.tpl +++ b/test/files/expectedConfigurableTemplatesChart/templates/_helpers.tpl @@ -1,5 +1,5 @@ {{- define "capApplicationVersionName" -}} -{{ printf "%s-%d" (include "appName" $) (.Release.Revision) }} +{{ printf "%s-%v" (include "appName" $) (.Values.app.version | default .Release.Revision) }} {{- end -}} {{- define "domainName" -}} diff --git a/test/files/expectedConfigurableTemplatesChart/templates/cap-operator-cros-ias.yaml b/test/files/expectedConfigurableTemplatesChart/templates/cap-operator-cros-ias.yaml index 65d1af7..6596396 100644 --- a/test/files/expectedConfigurableTemplatesChart/templates/cap-operator-cros-ias.yaml +++ b/test/files/expectedConfigurableTemplatesChart/templates/cap-operator-cros-ias.yaml @@ -51,7 +51,7 @@ metadata: name: {{ include "capApplicationVersionName" $ }} spec: capApplicationInstance: {{ include "appName" $ }} - version: "{{ .Release.Revision }}" + version: "{{ .Values.app.version | default .Release.Revision }}" registrySecrets: {{- range .Values.imagePullSecrets }} - {{ . }} diff --git a/test/files/expectedConfigurableTemplatesChart/templates/cap-operator-cros-modified-svc.yaml b/test/files/expectedConfigurableTemplatesChart/templates/cap-operator-cros-modified-svc.yaml index fb1dbb0..f2a3d18 100644 --- a/test/files/expectedConfigurableTemplatesChart/templates/cap-operator-cros-modified-svc.yaml +++ b/test/files/expectedConfigurableTemplatesChart/templates/cap-operator-cros-modified-svc.yaml @@ -43,7 +43,7 @@ metadata: name: {{ include "capApplicationVersionName" $ }} spec: capApplicationInstance: {{ include "appName" $ }} - version: "{{ .Release.Revision }}" + version: "{{ .Values.app.version | default .Release.Revision }}" registrySecrets: {{- range .Values.imagePullSecrets }} - {{ . }} diff --git a/test/files/expectedConfigurableTemplatesChart/templates/cap-operator-cros-modified.yaml b/test/files/expectedConfigurableTemplatesChart/templates/cap-operator-cros-modified.yaml index 60feda2..f0f129b 100644 --- a/test/files/expectedConfigurableTemplatesChart/templates/cap-operator-cros-modified.yaml +++ b/test/files/expectedConfigurableTemplatesChart/templates/cap-operator-cros-modified.yaml @@ -46,7 +46,7 @@ metadata: name: {{ include "capApplicationVersionName" $ }} spec: capApplicationInstance: {{ include "appName" $ }} - version: "{{ .Release.Revision }}" + version: "{{ .Values.app.version | default .Release.Revision }}" registrySecrets: {{- range .Values.imagePullSecrets }} - {{ . }} diff --git a/test/files/expectedConfigurableTemplatesChart/templates/cap-operator-cros-mta.yaml b/test/files/expectedConfigurableTemplatesChart/templates/cap-operator-cros-mta.yaml index 7211a9e..d9134ed 100644 --- a/test/files/expectedConfigurableTemplatesChart/templates/cap-operator-cros-mta.yaml +++ b/test/files/expectedConfigurableTemplatesChart/templates/cap-operator-cros-mta.yaml @@ -46,7 +46,7 @@ metadata: name: {{ include "capApplicationVersionName" $ }} spec: capApplicationInstance: {{ include "appName" $ }} - version: "{{ .Release.Revision }}" + version: "{{ .Values.app.version | default .Release.Revision }}" registrySecrets: {{- range .Values.imagePullSecrets }} - {{ . }} diff --git a/test/files/expectedConfigurableTemplatesChart/templates/cap-operator-cros-svc-ias.yaml b/test/files/expectedConfigurableTemplatesChart/templates/cap-operator-cros-svc-ias.yaml index 4169f11..9ea09a1 100644 --- a/test/files/expectedConfigurableTemplatesChart/templates/cap-operator-cros-svc-ias.yaml +++ b/test/files/expectedConfigurableTemplatesChart/templates/cap-operator-cros-svc-ias.yaml @@ -48,7 +48,7 @@ metadata: name: {{ include "capApplicationVersionName" $ }} spec: capApplicationInstance: {{ include "appName" $ }} - version: "{{ .Release.Revision }}" + version: "{{ .Values.app.version | default .Release.Revision }}" registrySecrets: {{- range .Values.imagePullSecrets }} - {{ . }} diff --git a/test/files/expectedConfigurableTemplatesChart/templates/cap-operator-cros-svc.yaml b/test/files/expectedConfigurableTemplatesChart/templates/cap-operator-cros-svc.yaml index 332a0f0..2c054df 100644 --- a/test/files/expectedConfigurableTemplatesChart/templates/cap-operator-cros-svc.yaml +++ b/test/files/expectedConfigurableTemplatesChart/templates/cap-operator-cros-svc.yaml @@ -43,7 +43,7 @@ metadata: name: {{ include "capApplicationVersionName" $ }} spec: capApplicationInstance: {{ include "appName" $ }} - version: "{{ .Release.Revision }}" + version: "{{ .Values.app.version | default .Release.Revision }}" registrySecrets: {{- range .Values.imagePullSecrets }} - {{ . }} diff --git a/test/files/expectedConfigurableTemplatesChart/templates/cap-operator-cros.yaml b/test/files/expectedConfigurableTemplatesChart/templates/cap-operator-cros.yaml index 97aa49a..11f2817 100644 --- a/test/files/expectedConfigurableTemplatesChart/templates/cap-operator-cros.yaml +++ b/test/files/expectedConfigurableTemplatesChart/templates/cap-operator-cros.yaml @@ -46,7 +46,7 @@ metadata: name: {{ include "capApplicationVersionName" $ }} spec: capApplicationInstance: {{ include "appName" $ }} - version: "{{ .Release.Revision }}" + version: "{{ .Values.app.version | default .Release.Revision }}" registrySecrets: {{- range .Values.imagePullSecrets }} - {{ . }}