mirror of
https://github.com/truenas/charts.git
synced 2024-04-21 15:21:45 +00:00
command and args
This commit is contained in:
@@ -4,7 +4,8 @@ workload:
|
||||
podSpec:
|
||||
containers:
|
||||
main:
|
||||
enabled: false
|
||||
enabled: true
|
||||
|
||||
|
||||
service:
|
||||
main:
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
suite: container arg test
|
||||
templates:
|
||||
- common.yaml
|
||||
tests:
|
||||
- it: should create the correct multiple args
|
||||
set:
|
||||
some_port: 80
|
||||
image: &image
|
||||
repository: nginx
|
||||
tag: 1.19.0
|
||||
pullPolicy: IfNotPresent
|
||||
workload:
|
||||
workload-name:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: Deployment
|
||||
podSpec:
|
||||
containers:
|
||||
container-name1:
|
||||
enabled: true
|
||||
primary: true
|
||||
imageSelector: image
|
||||
args:
|
||||
- --port
|
||||
- "{{ .Values.some_port }}"
|
||||
asserts:
|
||||
- documentIndex: &deploymentDoc 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
isAPIVersion:
|
||||
of: apps/v1
|
||||
- documentIndex: *deploymentDoc
|
||||
isSubset:
|
||||
path: spec.template.spec.containers[0]
|
||||
content:
|
||||
args:
|
||||
- --port
|
||||
- "80"
|
||||
|
||||
- it: should create the correct arg command
|
||||
set:
|
||||
image: &image
|
||||
repository: nginx
|
||||
tag: 1.19.0
|
||||
pullPolicy: IfNotPresent
|
||||
workload:
|
||||
workload-name:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: Deployment
|
||||
podSpec:
|
||||
containers:
|
||||
container-name1:
|
||||
enabled: true
|
||||
primary: true
|
||||
imageSelector: image
|
||||
args: --accept-eula
|
||||
asserts:
|
||||
- documentIndex: &deploymentDoc 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
isAPIVersion:
|
||||
of: apps/v1
|
||||
- documentIndex: *deploymentDoc
|
||||
isSubset:
|
||||
path: spec.template.spec.containers[0]
|
||||
content:
|
||||
args:
|
||||
- --accept-eula
|
||||
|
||||
- it: should create the correct multiple args and extraArgs
|
||||
set:
|
||||
some_path: /some/path
|
||||
image: &image
|
||||
repository: nginx
|
||||
tag: 1.19.0
|
||||
pullPolicy: IfNotPresent
|
||||
workload:
|
||||
workload-name:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: Deployment
|
||||
podSpec:
|
||||
containers:
|
||||
container-name1:
|
||||
enabled: true
|
||||
primary: true
|
||||
imageSelector: image
|
||||
args:
|
||||
- --port
|
||||
- "80"
|
||||
extraArgs:
|
||||
- --accept-eula
|
||||
- --path
|
||||
- "{{ .Values.some_path }}"
|
||||
asserts:
|
||||
- documentIndex: &deploymentDoc 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
isAPIVersion:
|
||||
of: apps/v1
|
||||
- documentIndex: *deploymentDoc
|
||||
isSubset:
|
||||
path: spec.template.spec.containers[0]
|
||||
content:
|
||||
args:
|
||||
- --port
|
||||
- "80"
|
||||
- --accept-eula
|
||||
- --path
|
||||
- /some/path
|
||||
@@ -0,0 +1,109 @@
|
||||
suite: container command test
|
||||
templates:
|
||||
- common.yaml
|
||||
tests:
|
||||
- it: should create the correct command in scalar
|
||||
set:
|
||||
image: &image
|
||||
repository: nginx
|
||||
tag: 1.19.0
|
||||
pullPolicy: IfNotPresent
|
||||
workload:
|
||||
workload-name:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: Deployment
|
||||
podSpec:
|
||||
containers:
|
||||
container-name1:
|
||||
enabled: true
|
||||
primary: true
|
||||
imageSelector: image
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- |
|
||||
echo "Using image {{ .Values.image.repository }}"
|
||||
asserts:
|
||||
- documentIndex: &deploymentDoc 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
isAPIVersion:
|
||||
of: apps/v1
|
||||
- documentIndex: *deploymentDoc
|
||||
isSubset:
|
||||
path: spec.template.spec.containers[0]
|
||||
content:
|
||||
command:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- |
|
||||
echo "Using image nginx"
|
||||
|
||||
- it: should create the correct single command
|
||||
set:
|
||||
image: &image
|
||||
repository: nginx
|
||||
tag: 1.19.0
|
||||
pullPolicy: IfNotPresent
|
||||
workload:
|
||||
workload-name:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: Deployment
|
||||
podSpec:
|
||||
containers:
|
||||
container-name1:
|
||||
enabled: true
|
||||
primary: true
|
||||
imageSelector: image
|
||||
command: ./start.sh
|
||||
asserts:
|
||||
- documentIndex: &deploymentDoc 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
isAPIVersion:
|
||||
of: apps/v1
|
||||
- documentIndex: *deploymentDoc
|
||||
isSubset:
|
||||
path: spec.template.spec.containers[0]
|
||||
content:
|
||||
command:
|
||||
- ./start.sh
|
||||
|
||||
- it: should create the correct multiple command
|
||||
set:
|
||||
image: &image
|
||||
repository: nginx
|
||||
tag: 1.19.0
|
||||
pullPolicy: IfNotPresent
|
||||
workload:
|
||||
workload-name:
|
||||
enabled: true
|
||||
primary: true
|
||||
type: Deployment
|
||||
podSpec:
|
||||
containers:
|
||||
container-name1:
|
||||
enabled: true
|
||||
primary: true
|
||||
imageSelector: image
|
||||
command:
|
||||
- ./print.sh
|
||||
- "{{ .Values.image.repository }}"
|
||||
asserts:
|
||||
- documentIndex: &deploymentDoc 0
|
||||
isKind:
|
||||
of: Deployment
|
||||
- documentIndex: *deploymentDoc
|
||||
isAPIVersion:
|
||||
of: apps/v1
|
||||
- documentIndex: *deploymentDoc
|
||||
isSubset:
|
||||
path: spec.template.spec.containers[0]
|
||||
content:
|
||||
command:
|
||||
- ./print.sh
|
||||
- nginx
|
||||
@@ -2,13 +2,16 @@
|
||||
|
||||
Assume every key bellow has a prefix of `workload.[workload-name].podSpec`.
|
||||
|
||||
| Key | Type | Required | Helm Template | Default | Description |
|
||||
| :---------------------------------- | :-------: | :------: | :-----------: | :-----: | :-------------------------------- |
|
||||
| containers.[container-name] | `dict` | ✅ | ❌ | `{}` | Define the container as dict |
|
||||
| containers.[container-name].enabled | `boolean` | ✅ | ❌ | `false` | Enables or Disables the container |
|
||||
| containers.[container-name].primary | `boolean` | ✅ | ❌ | `false` | Sets the container as primary |
|
||||
| containers.[container-name].stdin | `boolean` | ❌ | ❌ | `false` | whether to enable stdin or not |
|
||||
| containers.[container-name].tty | `boolean` | ❌ | ❌ | `false` | whether to enable tty or not |
|
||||
| Key | Type | Required | Helm Template | Default | Description |
|
||||
| :------------------------------------ | :-----------: | :------: | :-----------: | :-----: | :--------------------------------------------------------------------------------------------- |
|
||||
| containers.[container-name] | `dict` | ✅ | ❌ | `{}` | Define the container as dict |
|
||||
| containers.[container-name].enabled | `boolean` | ✅ | ❌ | `false` | Enables or Disables the container |
|
||||
| containers.[container-name].primary | `boolean` | ✅ | ❌ | `false` | Sets the container as primary |
|
||||
| containers.[container-name].stdin | `boolean` | ❌ | ❌ | `false` | whether to enable stdin or not |
|
||||
| containers.[container-name].tty | `boolean` | ❌ | ❌ | `false` | whether to enable tty or not |
|
||||
| containers.[container-name].command | `list/string` | ❌ | ✅ | `[]` | Define command(s). If it's single, can be defined as string |
|
||||
| containers.[container-name].args | `list/string` | ❌ | ✅ | `[]` | Define arg(s). If it's single, can be defined as string |
|
||||
| containers.[container-name].extraArgs | `list/string` | ❌ | ✅ | `[]` | Define extraArg(s). Those are appended after the `args`. Useful for user defined args from GUI |
|
||||
|
||||
---
|
||||
|
||||
@@ -43,4 +46,10 @@ workload:
|
||||
primary: true
|
||||
stdin: true
|
||||
tty: true
|
||||
command:
|
||||
- command
|
||||
args: arg
|
||||
extraArgs:
|
||||
- extraArg
|
||||
|
||||
```
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
{{/* Returns args list */}}
|
||||
{{/* Call this template:
|
||||
{{ include "ix.v1.common.lib.container.args" (dict "rootCtx" $ "objectData" $objectData) }}
|
||||
rootCtx: The root context of the template. It is used to access the global context.
|
||||
objectData: The object data to be used to render the container.
|
||||
*/}}
|
||||
{{- define "ix.v1.common.lib.container.args" -}}
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $objectData := .objectData -}}
|
||||
|
||||
{{- range $key := (list "args" "extraArgs") -}}
|
||||
{{- with (get $objectData $key) -}}
|
||||
{{- if kindIs "string" . }}
|
||||
- {{ tpl . $rootCtx | quote }}
|
||||
{{- else if kindIs "slice" . -}}
|
||||
{{- range $arg := . }}
|
||||
- {{ tpl $arg $rootCtx | quote }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,18 @@
|
||||
{{/* Returns command list */}}
|
||||
{{/* Call this template:
|
||||
{{ include "ix.v1.common.lib.container.command" (dict "rootCtx" $ "objectData" $objectData) }}
|
||||
rootCtx: The root context of the template. It is used to access the global context.
|
||||
objectData: The object data to be used to render the container.
|
||||
*/}}
|
||||
{{- define "ix.v1.common.lib.container.command" -}}
|
||||
{{- $rootCtx := .rootCtx -}}
|
||||
{{- $objectData := .objectData -}}
|
||||
|
||||
{{- if kindIs "string" $objectData.command }}
|
||||
- {{ tpl $objectData.command $rootCtx | quote }}
|
||||
{{- else if kindIs "slice" $objectData.command -}}
|
||||
{{- range $objectData.command }}
|
||||
- {{ tpl . $rootCtx | quote }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -14,4 +14,12 @@ objectData: The object data to be used to render the Pod.
|
||||
imagePullPolicy: {{ $imageObj.pullPolicy }}
|
||||
tty: {{ $objectData.tty | default false }}
|
||||
stdin: {{ $objectData.stdin | default false }}
|
||||
{{- with (include "ix.v1.common.lib.container.command" (dict "rootCtx" $rootCtx "objectData" $objectData) | trim) }}
|
||||
command:
|
||||
{{- . | nindent 4 }}
|
||||
{{- end -}}
|
||||
{{- with (include "ix.v1.common.lib.container.args" (dict "rootCtx" $rootCtx "objectData" $objectData) | trim) }}
|
||||
args:
|
||||
{{- . | nindent 4 }}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
Reference in New Issue
Block a user