From 0cd59aa46815e6b920e6f0a3a9d688dad24caf4d Mon Sep 17 00:00:00 2001 From: "a.b.christie" Date: Wed, 11 Mar 2026 11:39:58 +0000 Subject: [PATCH 1/3] feat: Add get_environment_constants() --- decoder/decoder.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/decoder/decoder.py b/decoder/decoder.py index 90f51ab..7ab1fc5 100644 --- a/decoder/decoder.py +++ b/decoder/decoder.py @@ -323,6 +323,27 @@ def get_environment_assets(job_definition: Dict[str, Any]) -> List[Dict[str, str return env_assets +def get_environment_constants(job_definition: Dict[str, Any]) -> List[Dict[str, str]]: + """Given a Job definition this function returns the list of all the + environment-based image constants declared. What's returned is a list + of the environment variable's name and its value. + """ + env_constants: List[Dict[str, str]] = [] + # Iterate through the environment block... + environment: List[Dict[str, Any]] = job_definition.get("image", {}).get( + "environment", [] + ) + env_constants.extend( + { + item["name"]: item["value-from"]["constant"]["value"], + } + for item in environment + if "constant" in item["value-from"] + ) + + return env_constants + + def get_jobs_replaced(job_definition: Dict[str, Any]) -> Optional[List[str]]: """Given a Job Definition this function returns the Jobs it replaces. The returned list is a list of jobs identified by collection and From 57d7d6559a7cc5596a8077539070b8e283786f04 Mon Sep 17 00:00:00 2001 From: "a.b.christie" Date: Wed, 11 Mar 2026 11:52:56 +0000 Subject: [PATCH 2/3] test: Add test for constants --- tests/test_get_environment_constants.py | 29 +++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/test_get_environment_constants.py diff --git a/tests/test_get_environment_constants.py b/tests/test_get_environment_constants.py new file mode 100644 index 0000000..471f717 --- /dev/null +++ b/tests/test_get_environment_constants.py @@ -0,0 +1,29 @@ +# Tests for the decoder's get_environment_assets() function. +from typing import Dict + +import pytest + +pytestmark = pytest.mark.unit + +from decoder import decoder + + +def test_get_environment_constants(): + # Arrange + job_definition: Dict = { + "image": { + "environment": [ + { + "name": "BLOB", + "value-from": {"constant": {"value": "42"}}, + } + ], + }, + } + + # Act + env_assets = decoder.get_environment_constants(job_definition) + + # Assert + assert len(env_assets) == 1 + assert env_assets[0]["BLOB"] == "42" From 1b35a6cf7dc65025dd12d7c8dfdd502f56689e26 Mon Sep 17 00:00:00 2001 From: "a.b.christie" Date: Wed, 11 Mar 2026 11:54:58 +0000 Subject: [PATCH 3/3] ci: Update action versions --- .github/workflows/build.yaml | 4 ++-- .github/workflows/publish.yaml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 7132e13..83688b6 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -37,9 +37,9 @@ jobs: - '3.13' steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} - name: Install requirements diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 99183b1..4174fb8 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -31,11 +31,11 @@ jobs: id-token: write # IMPORTANT: this permission is mandatory for trusted publishing steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Inject slug/short variables - uses: rlespinasse/github-slug-action@v4 + uses: rlespinasse/github-slug-action@v5 - name: Set up Python - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: '3.12' - name: Install dependencies