From fb86bdac44e8e91e91754e599528839c7cd4990f Mon Sep 17 00:00:00 2001 From: Stavros kois Date: Fri, 30 Dec 2022 15:13:46 +0200 Subject: [PATCH] simplify a regex --- library/common/1.0.0/templates/lib/container/_resources.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/common/1.0.0/templates/lib/container/_resources.tpl b/library/common/1.0.0/templates/lib/container/_resources.tpl index c0c55a0b34..bd70442532 100644 --- a/library/common/1.0.0/templates/lib/container/_resources.tpl +++ b/library/common/1.0.0/templates/lib/container/_resources.tpl @@ -95,8 +95,8 @@ memory: {{ . }} {{/* If it's not null validate input */}} {{- if ne . "" -}} {{/* Limits can be null, means "no limit" */}} {{- if eq $key "cpu" -}} - {{/* https://regex101.com/r/TlVTXr/3 */}} {{/*TODO: smallify this? */}} - {{- if not (mustRegexMatch "^([1-9][0-9]*(\\.\\[0-9]+)?m|[1-9][0-9]*|[0-9]*\\.[1-9][0-9]*(m)?)$" .) -}} + {{/* https://regex101.com/r/D4HouI/1 */}} + {{- if not (mustRegexMatch "^(0\\.[1-9]|[1-9][0-9]*)(\\.[0-9]|m?)$" .) -}} {{- fail (printf " has invalid format in value (%s). Valid formats are (Plain Integer eg. 1) (Float eg. 0.5) (Milicpu 500m)." $object $key .) -}} {{- end -}}