Skip to content

Commit

Permalink
Add check to ensure use_secret_as_volume accepts secret name as param…
Browse files Browse the repository at this point in the history
…eter

Signed-off-by: ddalvi <ddalvi@redhat.com>
  • Loading branch information
DharmitD committed Aug 1, 2024
1 parent fbf772e commit 4afe3d4
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions kubernetes_platform/python/test/unit/test_secret.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,47 @@ 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',
)

import pprint
pprint.pprint(json_format.MessageToDict(my_pipeline.platform_spec))
assert json_format.MessageToDict(my_pipeline.platform_spec) == {
'root': {
'inputDefinitions': {
'parameters': {
'secret_name': {
'defaultValue': 'my-secret',
'isOptional': True,
'parameterType': 'STRING'
}
}
}
},
'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

Expand Down

0 comments on commit 4afe3d4

Please sign in to comment.