mirror of
https://github.com/truecharts/library-charts.git
synced 2026-07-05 23:36:20 -03:00
fix more issues
This commit is contained in:
55
docs/common-library/values/configmap.md
Normal file
55
docs/common-library/values/configmap.md
Normal file
@@ -0,0 +1,55 @@
|
||||
# ConfigMap
|
||||
|
||||
## key: configmap
|
||||
|
||||
- Type: `dict`
|
||||
- Default: `{}`
|
||||
- Helm Template:
|
||||
- content.KEY: ❌
|
||||
- content.KEY.value: ✅
|
||||
|
||||
`configmap` dict creates a configmap based on the `content`
|
||||
|
||||
Options:
|
||||
|
||||
```yaml
|
||||
configmap:
|
||||
somename:
|
||||
enabled: true
|
||||
# Optional
|
||||
labels: {}
|
||||
# Optional
|
||||
annotations: {}
|
||||
# Optional
|
||||
nameOverride: ""
|
||||
# Tells to common that this contains environment variables
|
||||
# So it wil be checked for duplicates among `env`, `envList`, `fixedEnvs`
|
||||
# and other `secrets` / `configmaps` (with parseAsEnv set)
|
||||
parseAsEnv: true
|
||||
# Key/Value
|
||||
content:
|
||||
key: value
|
||||
# Or yaml scalar
|
||||
content:
|
||||
someKey: |
|
||||
configmap content
|
||||
```
|
||||
|
||||
Examples:
|
||||
|
||||
```yaml
|
||||
configmap:
|
||||
somename:
|
||||
enabled: true
|
||||
content:
|
||||
somekey: value
|
||||
otherkey: othervalue
|
||||
|
||||
configmap:
|
||||
somename:
|
||||
enabled: true
|
||||
content:
|
||||
somekey: value
|
||||
nginx.conf: |
|
||||
listen {{ .Values.service.main.ports.main.port }}
|
||||
```
|
||||
58
docs/common-library/values/secret.md
Normal file
58
docs/common-library/values/secret.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# Secret
|
||||
|
||||
## key: secret
|
||||
|
||||
- Type: `dict`
|
||||
- Default: `{}`
|
||||
- Helm Template:
|
||||
- secretType: ❌
|
||||
- content.KEY: ❌
|
||||
- content.KEY.value: ✅
|
||||
|
||||
`secret` dict creates a secret based on the `content`
|
||||
|
||||
Options:
|
||||
|
||||
```yaml
|
||||
secret:
|
||||
somename:
|
||||
enabled: true
|
||||
# Optional
|
||||
labels: {}
|
||||
# Optional
|
||||
annotations: {}
|
||||
# Optional
|
||||
nameOverride: ""
|
||||
# Optional - Defaults to Opaque
|
||||
secretType: ""
|
||||
# Tells to common that this contains environment variables
|
||||
# So it wil be checked for duplicates among `env`, `envList`, `fixedEnvs`
|
||||
# and other `secrets` / `configmaps` (with parseAsEnv set)
|
||||
parseAsEnv: true
|
||||
# Key/Value
|
||||
content:
|
||||
key: value
|
||||
# Or yaml scalar
|
||||
content:
|
||||
someKey: |
|
||||
configmap content
|
||||
```
|
||||
|
||||
Examples:
|
||||
|
||||
```yaml
|
||||
secret:
|
||||
somename:
|
||||
enabled: true
|
||||
content:
|
||||
somekey: value
|
||||
otherkey: othervalue
|
||||
|
||||
secret:
|
||||
somename:
|
||||
enabled: true
|
||||
content:
|
||||
somekey: value
|
||||
nginx.conf: |
|
||||
listen {{ .Values.service.main.ports.main.port }}
|
||||
```
|
||||
@@ -42,6 +42,17 @@ tests:
|
||||
- failedTemplate:
|
||||
errorMessage: Content of Configmap (somename) are empty. Please disable or add content.
|
||||
|
||||
- it: should fail with key without content in configmap
|
||||
set:
|
||||
configmap:
|
||||
somename:
|
||||
enabled: true
|
||||
content:
|
||||
key:
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: Configmap (somename) has key (key), without content.
|
||||
|
||||
- it: should fail with string in content in configmap
|
||||
set:
|
||||
configmap:
|
||||
@@ -91,6 +102,20 @@ tests:
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
release: RELEASE-NAME
|
||||
|
||||
- it: should pass with empty key in content in configmap
|
||||
documentIndex: *configMapDoc
|
||||
set:
|
||||
configmap:
|
||||
somename:
|
||||
enabled: true
|
||||
content:
|
||||
key: ""
|
||||
asserts:
|
||||
- equal:
|
||||
path: data
|
||||
value:
|
||||
key: ""
|
||||
|
||||
- it: should pass with 1 configmap created with parseAsEnv and values set from tpl
|
||||
documentIndex: *configMapDoc
|
||||
set:
|
||||
@@ -235,7 +260,7 @@ tests:
|
||||
k3: pair
|
||||
k4: value2
|
||||
k5: 81
|
||||
k6: pair2
|
||||
k6: false
|
||||
configmap:
|
||||
some-name:
|
||||
enabled: true
|
||||
@@ -295,7 +320,7 @@ tests:
|
||||
k3: pair
|
||||
k4: value2
|
||||
k5: 81
|
||||
k6: pair2
|
||||
k6: false
|
||||
configmap:
|
||||
some-name:
|
||||
enabled: true
|
||||
@@ -331,7 +356,7 @@ tests:
|
||||
- equal:
|
||||
path: data
|
||||
value:
|
||||
key: pair2
|
||||
key: "false"
|
||||
nginx.conf2: |
|
||||
alias value2
|
||||
listen 81
|
||||
|
||||
@@ -42,6 +42,17 @@ tests:
|
||||
- failedTemplate:
|
||||
errorMessage: Content of Secret (somename) are empty. Please disable or add content.
|
||||
|
||||
- it: should fail with key without content in secret
|
||||
set:
|
||||
secret:
|
||||
somename:
|
||||
enabled: true
|
||||
content:
|
||||
key:
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorMessage: Secret (somename) has key (key), without content.
|
||||
|
||||
- it: should fail with string in content in secret
|
||||
set:
|
||||
secret:
|
||||
@@ -94,6 +105,20 @@ tests:
|
||||
helm.sh/chart: common-test-1.0.0
|
||||
release: RELEASE-NAME
|
||||
|
||||
- it: should pass with empty key in content in secret
|
||||
documentIndex: *secretDoc
|
||||
set:
|
||||
secret:
|
||||
somename:
|
||||
enabled: true
|
||||
content:
|
||||
key: ""
|
||||
asserts:
|
||||
- equal:
|
||||
path: stringData
|
||||
value:
|
||||
key: ""
|
||||
|
||||
- it: should pass with 1 secret created with parseAsEnv and values set from tpl
|
||||
documentIndex: *secretDoc
|
||||
set:
|
||||
|
||||
@@ -53,22 +53,26 @@
|
||||
{{- $dupeCheck := dict -}}
|
||||
|
||||
{{- range $k, $v := $objectData.content -}} {{/* Expand templates before sending them to the configmap */}}
|
||||
{{- $value := tpl ($v | toString ) $root -}} {{/* Convert to string so safely handle ints */}}
|
||||
{{- $_ := set $classData $k $value -}}
|
||||
{{- if and (not $v) (not (mustHas $v (list "" 0 false))) -}} {{/* To handle falsy values */}}
|
||||
{{- fail (printf "%s (%s) has key (%s), without content." (camelcase $objectType) $name $k) -}}
|
||||
{{- end -}}
|
||||
{{- $value := tpl ($v | toString) $root -}} {{/* Convert to string so safely handle ints */}}
|
||||
{{- $_ := set $dupeCheck $k $value -}}
|
||||
{{- $_ := set $classData $k $value -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $contentType = "key_value" -}}
|
||||
{{- include "ix.v1.common.util.storeEnvsForDupeCheck" (dict "root" $root "source" (printf "%s-%s" (camelcase $objectType) $objectName) "data" $dupeCheck) -}}
|
||||
|
||||
{{- else -}} {{/* If it's not destined for envFromm assume "scalar" secret/configmap... */}}
|
||||
{{- range $key, $value := $objectData.content -}} {{/* key/value works too when parsed as scalar */}}
|
||||
{{- if not $value -}}
|
||||
{{- fail (printf "%s (%s) has key (%s), without content." (camelcase $objectType) $name $key) -}}
|
||||
{{- range $k, $v := $objectData.content -}} {{/* key/value works too when parsed as scalar */}}
|
||||
{{- if and (not $v) (not (mustHas $v (list "" 0 false))) -}} {{/* To handle falsy values */}}
|
||||
{{- fail (printf "%s (%s) has key (%s), without content." (camelcase $objectType) $name $k) -}}
|
||||
{{- end -}}
|
||||
{{- $_ := set $classData $k ($v | toString) -}}
|
||||
{{- end -}}
|
||||
{{- $contentType = "scalar" -}} {{/* Handle both key/value and scalar the same way */}}
|
||||
{{- $classData = (tpl (toYaml $objectData.content) $root) -}} {{/* toYaml works on both scalar and key/value */}}
|
||||
{{- $classData = (tpl (toYaml $classData) $root) -}} {{/* toYaml works on both scalar and key/value */}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Create ConfigMap or Secret */}}
|
||||
|
||||
@@ -23,6 +23,10 @@ envList: []
|
||||
|
||||
envFrom: []
|
||||
|
||||
configmap: {}
|
||||
|
||||
secret: {}
|
||||
|
||||
TZ: UTC
|
||||
|
||||
lifecycle: {}
|
||||
@@ -275,44 +279,6 @@ service:
|
||||
# [[ref]](https://kubernetes.io/docs/concepts/services-networking/service/#type-nodeport)
|
||||
nodePort:
|
||||
|
||||
configmap: {}
|
||||
# someName:
|
||||
# enabled: true
|
||||
# labels: {}
|
||||
# annotations: {}
|
||||
# nameOverride: ""
|
||||
# Tells to common that this contains environment variables
|
||||
# So it wil be checked for duplicates among `env` `envList` and fixedEnvs
|
||||
# also content can be key/value pairs
|
||||
# parseAsEnv: true
|
||||
## Key/Value
|
||||
# content:
|
||||
# key: value
|
||||
## Or yaml scalar
|
||||
# content:
|
||||
# someKey: |
|
||||
# configmap content
|
||||
|
||||
secret: {}
|
||||
# someName:
|
||||
# enabled: true
|
||||
# # Define custom secret type. Defaults to Opaque
|
||||
# secretType: ""
|
||||
# labels: {}
|
||||
# annotations: {}
|
||||
# nameOverride: ""
|
||||
# Tells to common that this contains environment variables
|
||||
# So it wil be checked for duplicates among `env` `envList` and fixedEnvs
|
||||
# also content can be key/value pairs
|
||||
# parseAsEnv: true
|
||||
## Key/Value
|
||||
# content:
|
||||
# key: value
|
||||
## Or yaml scalar
|
||||
# content:
|
||||
# someKey: |
|
||||
# configmap content
|
||||
|
||||
persistence: {}
|
||||
# TODO: Discuss if we are going to add defaults like:
|
||||
# - /dev/shm
|
||||
|
||||
Reference in New Issue
Block a user