diff --git a/library/common-test/tests/container/lifecycle_test.yaml b/library/common-test/tests/container/lifecycle_test.yaml index dce725f990..2d99b8ddc0 100644 --- a/library/common-test/tests/container/lifecycle_test.yaml +++ b/library/common-test/tests/container/lifecycle_test.yaml @@ -217,6 +217,29 @@ tests: - failedTemplate: errorMessage: Container - Expected non-empty on [http] type + - it: should fail with path not starting with / on http lifecycle type + set: + image: *image + workload: + workload-name: + enabled: true + primary: true + type: Deployment + podSpec: + containers: + container-name1: + enabled: true + primary: true + imageSelector: image + lifecycle: + preStop: + type: http + port: 80 + path: "api/v1" + asserts: + - failedTemplate: + errorMessage: Container - Expected to start with a forward slash [/] on type + - it: should fail with empty value on httpHeaders on http lifecycle type set: image: *image diff --git a/library/common/1.0.0/templates/lib/container/actions/_httpGet.tpl b/library/common/1.0.0/templates/lib/container/actions/_httpGet.tpl index eb9eb1b35f..702b9f9040 100644 --- a/library/common/1.0.0/templates/lib/container/actions/_httpGet.tpl +++ b/library/common/1.0.0/templates/lib/container/actions/_httpGet.tpl @@ -15,9 +15,15 @@ objectData: The object data to be used to render the container. {{- if kindIs "string" $port -}} {{- $port = tpl $port $rootCtx -}} {{- end -}} + {{- with $objectData.path -}} {{- $path = tpl . $rootCtx -}} {{- end -}} + + {{- if not (hasPrefix "/" $path) -}} + {{- fail "Container - Expected to start with a forward slash [/] on type" -}} + {{- end -}} + {{- with $objectData.scheme -}} {{- $scheme = tpl . $rootCtx -}} {{- end }}