From c516c4e05df0de810e45cbb710da50bf8deca2ab Mon Sep 17 00:00:00 2001 From: Richard Cox Date: Tue, 29 Sep 2020 14:45:50 -0500 Subject: [PATCH] [home-assistant] Adds control over vscode image arguments (#75) * Added ability to control vscode arguments Signed-off-by: Richard Cox * Fixed helpers function to handle null and empty string vscode.args value Signed-off-by: Richard Cox Co-authored-by: Jeff Billimek --- charts/home-assistant/Chart.yaml | 2 +- charts/home-assistant/README.md | 1 + charts/home-assistant/templates/_helpers.tpl | 21 +++++++++++++++++++ .../home-assistant/templates/deployment.yaml | 13 ++++-------- charts/home-assistant/values.yaml | 4 ++++ 5 files changed, 31 insertions(+), 10 deletions(-) diff --git a/charts/home-assistant/Chart.yaml b/charts/home-assistant/Chart.yaml index 67bd58c2..7cff6eb5 100644 --- a/charts/home-assistant/Chart.yaml +++ b/charts/home-assistant/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 appVersion: 0.115.2 description: Home Assistant name: home-assistant -version: 2.4.1 +version: 2.5.0 keywords: - home-assistant - hass diff --git a/charts/home-assistant/README.md b/charts/home-assistant/README.md index ee63debd..963d2c14 100644 --- a/charts/home-assistant/README.md +++ b/charts/home-assistant/README.md @@ -135,6 +135,7 @@ The following tables lists the configurable parameters of the Home Assistant cha | `vscode.vscodePath` | Base path of the VS Code configuration files | `/config/.vscode` | | `vscode.password` | If this is set, will require a password to access the VS Code Server UI | `` | | `vscode.extraEnv` | Extra ENV vars to pass to the configuration UI | `{}` | +| `vscode.args` | Optional arguments to pass into vscode image. Defaulting to "-" uses default arguments. | `-` | | `vscode.ingress.enabled` | Enables Ingress for the VS Code UI | `false` | | `vscode.ingress.annotations` | Ingress annotations for the VS Code UI | `{}` | | `vscode.ingress.hosts` | Ingress accepted hostnames for the VS Code UI | `chart-example.local` | diff --git a/charts/home-assistant/templates/_helpers.tpl b/charts/home-assistant/templates/_helpers.tpl index d277f82d..4f65f054 100644 --- a/charts/home-assistant/templates/_helpers.tpl +++ b/charts/home-assistant/templates/_helpers.tpl @@ -30,3 +30,24 @@ Create chart name and version as used by the chart label. {{- define "home-assistant.chart" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} {{- end -}} + +{{/* +Create argument list for vscode image. +*/}} +{{- define "home-assistant.vscode.args" -}} +{{- if empty .Values.vscode.args -}} +{{- "" -}} +{{- else if (eq (typeOf .Values.vscode.args) "string") -}} +- --port={{ .Values.vscode.service.port }} +{{- if not (.Values.vscode.password) }} +- --auth=none +{{- end }} +{{- if .Values.vscode.vscodePath }} +- --extensions-dir={{ .Values.vscode.vscodePath }} +- --user-data-dir={{ .Values.vscode.vscodePath }} +- {{ .Values.vscode.hassConfig }} +{{- end }} +{{- else -}} +{{ toYaml .Values.vscode.args }} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/charts/home-assistant/templates/deployment.yaml b/charts/home-assistant/templates/deployment.yaml index c3419292..fc0f2ab8 100644 --- a/charts/home-assistant/templates/deployment.yaml +++ b/charts/home-assistant/templates/deployment.yaml @@ -1,3 +1,4 @@ +{{- $args := include "home-assistant.vscode.args" . -}} apiVersion: apps/v1 kind: Deployment metadata: @@ -273,15 +274,9 @@ spec: imagePullPolicy: {{ .Values.vscode.image.pullPolicy }} workingDir: {{ .Values.vscode.hassConfig }} args: - - --port={{ .Values.vscode.service.port }} - {{- if not (.Values.vscode.password) }} - - --auth=none - {{- end }} - {{- if .Values.vscode.vscodePath }} - - --extensions-dir={{ .Values.vscode.vscodePath }} - - --user-data-dir={{ .Values.vscode.vscodePath }} - - {{ .Values.vscode.hassConfig }} - {{- end }} +{{- with $args }} +{{ . | indent 12 }} +{{- end }} ports: - name: vscode containerPort: {{ .Values.vscode.service.port }} diff --git a/charts/home-assistant/values.yaml b/charts/home-assistant/values.yaml index 835df855..6899ae6a 100644 --- a/charts/home-assistant/values.yaml +++ b/charts/home-assistant/values.yaml @@ -250,6 +250,10 @@ vscode: ## extraEnv: {} + ## Set to "-" to use default argument list + ## Otherwise convert to list of arguments + args: "-" + ingress: enabled: false annotations: {}