Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
Support configuring fetch-artifacts-url.yaml
Browse files Browse the repository at this point in the history
This allows user to define `fetch-artifacts-url.yaml` in ocp-build-data image config:

```yaml
content:
  source:
    artifacts:
      from_urls:
      - target: yarn-v1.22.19.tar.gz
        url: http://download.eng.bos.redhat.com/rcm-guest/puddles/RHAOS/artifacts/build-deps/yarn-v1.22.19.tar.gz
        sha256: 732620bac8b1690d507274f025f3c6cfdc3627a84d9642e38a07452cc00e0f2e
        source-url: http://download.eng.bos.redhat.com/rcm-guest/puddles/RHAOS/artifacts/build-deps/yarn-source-v1.22.19.tar.gz
        source-sha256: 50af0025d2ef942bf3e6cdd0587dc9c4dd8d6e6e69501b84935d09f2b2b5de8b
```
  • Loading branch information
vfreex committed May 24, 2022
1 parent 998c9b1 commit 93cebc3
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion doozerlib/distgit.py
Expand Up @@ -418,7 +418,7 @@ def __init__(self, metadata, autoclone=True,
self.build_lock.acquire()
self.rebase_event = Event()
self.rebase_status = False
self.logger = metadata.logger
self.logger: logging.Logger = metadata.logger
self.source_modifier_factory = source_modifier_factory

def clone(self, distgits_root_dir, distgit_branch):
Expand All @@ -442,6 +442,24 @@ def image_build_method(self):

return build_method

def _write_fetch_artifacts(self):
# Write fetch-artifacts-url.yaml for OSBS to fetch external artifacts
# See https://osbs.readthedocs.io/en/osbs_ocp3/users.html#using-artifacts-from-koji-or-project-newcastle-aka-pnc
config_value = None
if self.config.content.source.artifacts.from_urls is not Missing:
config_value = self.config.content.source.artifacts.from_urls.primitive()
path = self.dg_path.joinpath('fetch-artifacts-url.yaml')
if path.exists(): # upstream provides its own fetch-artifacts-url.yaml
if not config_value:
self.logger.info("Use fetch-artifacts-url.yaml provided by upstream.")
return
raise ValueError("Image config option content.source.artifacts.from_urls cannot be used if upstream source has fetch-artifacts-url.yaml")
if not config_value:
return # fetch-artifacts-url.yaml is not needed.
self.logger.info('Generating fetch-artifacts-url.yaml')
with path.open("w") as f:
yaml.safe_dump(config_value, f)

def _write_osbs_image_config(self, version: str):
# Writes OSBS image config (container.yaml).
# For more info about the format, see https://osbs.readthedocs.io/en/latest/users.html#image-configuration.
Expand Down Expand Up @@ -1499,6 +1517,8 @@ def update_distgit_dir(self, version, release, prev_release=None, force_yum_upda

self._write_cvp_owners()

self._write_fetch_artifacts()

dfp = DockerfileParser(path=str(dg_path.joinpath('Dockerfile')))

self._clean_repos(dfp)
Expand Down

0 comments on commit 93cebc3

Please sign in to comment.