Skip to content

Commit

Permalink
Add parsing of eventual settings.provider_labels for AT, Container pr…
Browse files Browse the repository at this point in the history
…oviders
  • Loading branch information
rplevka committed Apr 22, 2024
1 parent 99eada8 commit 191c9de
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions broker/providers/ansible_tower.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,10 @@ def execute(self, **kwargs): # noqa: PLR0912,PLR0915 - Possible TODO refactor
payload["labels"] = self._resolve_labels(labels, target)
# record labels also as extra vars - use key=value format
kwargs["provider_labels"] = kwargs.get("provider_labels", {})
# include eventual common labels, specified at each level of configuration
# typically imported from dynaconf env vars
kwargs["provider_labels"].update(settings.get("provider_labels", {}))
kwargs["provider_labels"].update(settings.ANSIBLETOWER.get("provider_labels", {}))
kwargs["provider_labels"].update(
{label[0]: "=".join(label[1:]) for label in labels.items()}
)
Expand Down
4 changes: 4 additions & 0 deletions broker/providers/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ def run_container(self, container_host, **kwargs):
if origin[1]:
envars["JENKINS_URL"] = origin[1]
kwargs["environment"] = envars

# process provider labels for each setting level
kwargs["provider_labels"].update(settings.get("provider_labels", {}))
kwargs["provider_labels"].update(settings.CONTAINER.get("provider_labels", {}))
# prefix eventual label keys with 'broker.' to conform to the docker guidelines
# https://docs.docker.com/config/labels-custom-metadata/#key-format-recommendations
kwargs["provider_labels"] = {
Expand Down

0 comments on commit 191c9de

Please sign in to comment.