Skip to content

Commit 3a75314

Browse files
author
Alan Christie
committed
feat: Adds get_pull_secret_names
1 parent 6e1582e commit 3a75314

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

decoder/decoder.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,20 @@ def get_job_doc_url(
211211
return doc_url
212212

213213

214+
def get_pull_secret_names(job_definition: Dict[str, Any]) -> Set[str]:
215+
""" "Given a Job definition this function returns the unique list of the
216+
pull-secrets declared.
217+
"""
218+
names: Set[str] = set()
219+
220+
# Check the environment block...
221+
pull_secret: Optional[str] = job_definition.get("image", {}).get("pull-secret")
222+
if pull_secret:
223+
names.add(pull_secret)
224+
225+
return names
226+
227+
214228
def get_asset_names(job_definition: Dict[str, Any]) -> Set[str]:
215229
""" "Given a Job definition this function returns the unique list of all the
216230
asset names declared. Asset names can be used in image environment
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Tests for the decoder's get_job_doc_url() function.
2+
from typing import Dict
3+
4+
import pytest
5+
6+
pytestmark = pytest.mark.unit
7+
8+
from decoder import decoder
9+
10+
11+
def test_get_asset_names():
12+
# Arrange
13+
job_definition: Dict = {
14+
"image": {"pull-secret": "secret-a"},
15+
}
16+
17+
# Act
18+
secret_names = decoder.get_pull_secret_names(job_definition)
19+
20+
# Assert
21+
assert len(secret_names) == 1
22+
assert "secret-a" in secret_names

0 commit comments

Comments
 (0)