From 4f6400218a405a7f1381f0bf378dc4deb4c5545d Mon Sep 17 00:00:00 2001 From: suggsa Date: Mon, 26 Aug 2024 10:46:19 -0400 Subject: [PATCH 1/3] update urls templating to trim trailing comma and whitespae; update url regex to allow underscores --- charts/local-ai/templates/deployment.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/local-ai/templates/deployment.yaml b/charts/local-ai/templates/deployment.yaml index 4756ab1..3af2362 100644 --- a/charts/local-ai/templates/deployment.yaml +++ b/charts/local-ai/templates/deployment.yaml @@ -2,7 +2,7 @@ {{- $urls := "" -}} {{- $rootPersistence := .Values.persistence }} {{- range $idx, $model := .Values.models.list }} -{{- $urls = printf "%s%s %s," $urls $model.url ($model.basicAuth | default "") }} +{{- $urls = printf "%s%s %s," $urls $model.url ($model.basicAuth | default "") | trimSuffix "," | trim }} {{- end }} apiVersion: apps/v1 @@ -140,7 +140,7 @@ spec: validate_url() { local url=$1 - local regex='^(https?|ftp)://[a-zA-Z0-9.-]+(:[a-zA-Z0-9.-]+)?(/[a-zA-Z0-9.-]*)*$' + local regex='^(https?|ftp):\/\/[a-zA-Z0-9.-_]+(:[a-zA-Z0-9.-]+)?(\/[a-zA-Z0-9._-]*)*$' if [[ $url =~ $regex ]]; then return 0 # URL is valid else From b9529fb38a5b6343c3bbb0cf1cd677cb0c07bf3a Mon Sep 17 00:00:00 2001 From: suggsa Date: Fri, 30 Aug 2024 08:23:24 -0400 Subject: [PATCH 2/3] Fix issue where trimming was within the range loop --- charts/local-ai/templates/deployment.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/charts/local-ai/templates/deployment.yaml b/charts/local-ai/templates/deployment.yaml index 3af2362..d7c0474 100644 --- a/charts/local-ai/templates/deployment.yaml +++ b/charts/local-ai/templates/deployment.yaml @@ -2,8 +2,9 @@ {{- $urls := "" -}} {{- $rootPersistence := .Values.persistence }} {{- range $idx, $model := .Values.models.list }} -{{- $urls = printf "%s%s %s," $urls $model.url ($model.basicAuth | default "") | trimSuffix "," | trim }} +{{- $urls = printf "%s%s %s," $urls $model.url ($model.basicAuth | default "") }} {{- end }} +{{- $urls = $urls | trimSuffix "," | trim }} apiVersion: apps/v1 kind: Deployment From 2c505112758ddb894236e61911fabc1305987cc2 Mon Sep 17 00:00:00 2001 From: suggsa Date: Fri, 30 Aug 2024 08:56:48 -0400 Subject: [PATCH 3/3] fix typo in regex validation --- charts/local-ai/templates/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/local-ai/templates/deployment.yaml b/charts/local-ai/templates/deployment.yaml index d7c0474..4d2032e 100644 --- a/charts/local-ai/templates/deployment.yaml +++ b/charts/local-ai/templates/deployment.yaml @@ -141,7 +141,7 @@ spec: validate_url() { local url=$1 - local regex='^(https?|ftp):\/\/[a-zA-Z0-9.-_]+(:[a-zA-Z0-9.-]+)?(\/[a-zA-Z0-9._-]*)*$' + local regex='^(https?|ftp):\/\/[a-zA-Z0-9._-]+(:[a-zA-Z0-9.-]+)?(\/[a-zA-Z0-9._-]*)*$' if [[ $url =~ $regex ]]; then return 0 # URL is valid else