From c788e298071396a9a4707ea4bea9b493359cf269 Mon Sep 17 00:00:00 2001 From: ddalvi Date: Wed, 31 Jul 2024 19:55:22 -0400 Subject: [PATCH] Add check to ensure use_secret_as_volume accepts secret name as parameter Signed-off-by: ddalvi --- .../python/test/unit/test_secret.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/kubernetes_platform/python/test/unit/test_secret.py b/kubernetes_platform/python/test/unit/test_secret.py index a22e6be45201..e1f4f1b52f8f 100644 --- a/kubernetes_platform/python/test/unit/test_secret.py +++ b/kubernetes_platform/python/test/unit/test_secret.py @@ -147,6 +147,34 @@ def my_pipeline(): } } + def test_with_secret_name_param(self): + @dsl.pipeline + def my_pipeline(secret_name: str = 'my-secret'): + task = comp() + kubernetes.use_secret_as_volume( + task, + secret_name=secret_name, + mount_path='secretpath', + ) + + assert json_format.MessageToDict(my_pipeline.pipeline_spec) == { + 'platforms': { + 'kubernetes': { + 'deploymentSpec': { + 'executors': { + 'exec-comp': { + 'secretAsVolume': [{ + 'secretName': 'secret_name', + 'mountPath': 'secretpath', + 'optional': False + }] + } + } + } + } + } + } + def test_preserves_secret_as_env(self): # checks that use_secret_as_volume respects previously set secrets as env