diff --git a/library/common-test/tests/workload/validation_test.yaml b/library/common-test/tests/workload/validation_test.yaml index 9ed20e67e2..727b130df6 100644 --- a/library/common-test/tests/workload/validation_test.yaml +++ b/library/common-test/tests/workload/validation_test.yaml @@ -48,6 +48,17 @@ tests: - failedTemplate: errorMessage: Workload - Expected to be one of [Deployment, StatefulSet, DaemonSet, Job, CronJob], but got [not-valid-type] + - it: should fail without podSpec + set: + workload: + workload-name: + enabled: true + primary: true + type: Deployment + asserts: + - failedTemplate: + errorMessage: Workload - Expected key to exist + - it: should fail without primary enabled workload set: workload: @@ -63,7 +74,7 @@ tests: podSpec: {} asserts: - failedTemplate: - errorMessage: Workload - At least one enabled workload must be primary + errorMessage: Workload - One enabled workload must be primary - it: should fail more than one primary enabled workload set: diff --git a/library/common/1.0.0/templates/spawner/_workload.tpl b/library/common/1.0.0/templates/spawner/_workload.tpl index 444de4167d..a05c0e0dd7 100644 --- a/library/common/1.0.0/templates/spawner/_workload.tpl +++ b/library/common/1.0.0/templates/spawner/_workload.tpl @@ -33,7 +33,7 @@ {{/* Set the podSpec so it doesn't fail on nil pointer */}} {{- if not (hasKey $objectData "podSpec") -}} - {{ $_ := set $objectData "podSpec" dict }} + {{- fail "Workload - Expeced key to exist" -}} {{- end -}} {{/* Call class to create the object */}}