mirror of
https://github.com/truenas/charts.git
synced 2026-06-17 07:27:44 +08:00
add tests
This commit is contained in:
7
helm_template_common.sh
Executable file
7
helm_template_common.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
common_path=library/common/1.0.0
|
||||
|
||||
go-yq -i '.type = "application"' "$common_path"/Chart.yaml
|
||||
helm template ./"$common_path"
|
||||
go-yq -i '.type = "library"' "$common_path"/Chart.yaml
|
||||
@@ -17,6 +17,25 @@ tests:
|
||||
documentIndex: *deploymentDoc
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-common-test
|
||||
- equal:
|
||||
documentIndex: *deploymentDoc
|
||||
path: metadata.labels
|
||||
value:
|
||||
app: common-test
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: common-test
|
||||
app.kubernetes.io/version: v1.0.0
|
||||
helm-revision: "0"
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
release: RELEASE-NAME
|
||||
- isNotEmpty:
|
||||
documentIndex: *deploymentDoc
|
||||
path: metadata.annotations.rollme
|
||||
- equal:
|
||||
documentIndex: *deploymentDoc
|
||||
path: spec.revisionHistoryLimit
|
||||
value: 3
|
||||
|
||||
- it: should pass with nameOverride
|
||||
set:
|
||||
@@ -37,6 +56,47 @@ tests:
|
||||
path: metadata.name
|
||||
value: RELEASE-NAME-globalOverrodeName
|
||||
|
||||
- it: should pass with controller and global labels
|
||||
set:
|
||||
controller.labels:
|
||||
controllerkey: controllervalue
|
||||
global.labels:
|
||||
globalkey: globalvalue
|
||||
asserts:
|
||||
- equal:
|
||||
documentIndex: *deploymentDoc
|
||||
path: metadata.labels
|
||||
value:
|
||||
controllerkey: controllervalue
|
||||
globalkey: globalvalue
|
||||
app: common-test
|
||||
app.kubernetes.io/instance: RELEASE-NAME
|
||||
app.kubernetes.io/managed-by: Helm
|
||||
app.kubernetes.io/name: common-test
|
||||
app.kubernetes.io/version: v1.0.0
|
||||
helm-revision: "0"
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
release: RELEASE-NAME
|
||||
|
||||
- it: should pass with controller and global annotations
|
||||
set:
|
||||
controller.annotations:
|
||||
controllerkey: controllervalue
|
||||
global.annotations:
|
||||
globalkey: globalvalue
|
||||
asserts:
|
||||
- equal:
|
||||
documentIndex: *deploymentDoc
|
||||
path: metadata.annotations.controllerkey
|
||||
value: controllervalue
|
||||
- equal:
|
||||
documentIndex: *deploymentDoc
|
||||
path: metadata.annotations.globalkey
|
||||
value: globalvalue
|
||||
- isNotEmpty:
|
||||
documentIndex: *deploymentDoc
|
||||
path: metadata.annotations.rollme
|
||||
|
||||
- it: should pass with controller disabled
|
||||
set:
|
||||
controller.enabled: false
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
apiVersion: v2
|
||||
name: common
|
||||
description: A library chart for iX Official Catalog
|
||||
|
||||
# A chart can be either an 'application' or a 'library' chart.
|
||||
#
|
||||
# Application charts are a collection of templates that can be packaged into versioned archives
|
||||
@@ -11,15 +10,11 @@ description: A library chart for iX Official Catalog
|
||||
# a dependency of application charts to inject those utilities and functions into the rendering
|
||||
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
|
||||
|
||||
# Temporary set to application so I can render it locally
|
||||
type: library
|
||||
# type: application
|
||||
|
||||
# This is the chart version. This version number should be incremented each time you make changes
|
||||
# to the chart and its templates, including the app version.
|
||||
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
||||
version: 1.0.0
|
||||
|
||||
# This is the version number of the application being deployed. This version number should be
|
||||
# incremented each time you make changes to the application. Versions are not expected to
|
||||
# follow Semantic Versioning. They should reflect the version the application is using.
|
||||
|
||||
1
library/common/1.0.0/templates/common.yaml
Normal file
1
library/common/1.0.0/templates/common.yaml
Normal file
@@ -0,0 +1 @@
|
||||
{{ include "ix.v1.common.loader.all" . }}
|
||||
@@ -8,7 +8,10 @@ apiVersion: {{ include "ix.v1.common.capabilities.deployment.apiVersion" $ }}
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ include "ix.v1.common.names.fullname" . }}
|
||||
labels:
|
||||
annotations:
|
||||
{{- $labels := merge (default dict .Values.controller.labels) (include "ix.v1.common.labels" $ | fromYaml) }}
|
||||
labels: {{- (toYaml $labels) | nindent 4 }}
|
||||
{{- $annotations := merge (default dict .Values.controller.annotations) (include "ix.v1.common.annotations" $ | fromYaml) (include "ix.v1.common.annotations.workload" $ | fromYaml ) }}
|
||||
annotations: {{- (toYaml $annotations) | nindent 4 }}
|
||||
spec:
|
||||
revisionHistoryLimit: {{ .Values.controller.revisionHistoryLimit }}
|
||||
{{- end }}
|
||||
|
||||
@@ -19,3 +19,9 @@ controller:
|
||||
# -- Set the controller type.
|
||||
# Valid options are: deployment | daemonset | statefulset
|
||||
type: deployment
|
||||
# -- Set labels on the deployment/statefulset/daemonset
|
||||
labels: {}
|
||||
# -- Set annotations on the deployment/statefulset/daemonset
|
||||
annotations: {}
|
||||
# -- Revision history limit
|
||||
revisionHistoryLimit: 3
|
||||
|
||||
Reference in New Issue
Block a user