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

Commit

Permalink
A bit more bundle doc
Browse files Browse the repository at this point in the history
  • Loading branch information
jupierce committed Jun 18, 2021
1 parent 64d815f commit 1834dc3
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions doozerlib/operator_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,10 @@ def get_operator_branch(self):
return self.runtime.group_config.branch

def get_operator_name(self):
"""
Extracts the operator name from brew information; .e.g. "clusterresourceoverride-operator"
This is the same as the name of the distgit / image metadata yaml filename.
"""
_rc, stdout, _stderr = self.brew_buildinfo
return re.search('Source:([^#]+)', stdout).group(1).split('/')[-1]

Expand All @@ -678,9 +682,24 @@ def get_operator(self):

@log
def get_brew_buildinfo(self):
"""Output of this command is used to extract the operator name and its commit hash
"""
Output of this command is used to extract the operator name and its commit hash.
TODO: replace with koji api calls.
"""
cmd = 'brew buildinfo {}'.format(self.nvr)
"""
Example output:
$ brew buildinfo ose-clusterresourceoverride-operator-container-v4.8.0-202106152230.p0.git.09010e9.assembly.stream
BUILD: ose-clusterresourceoverride-operator-container-v4.8.0-202106152230.p0.git.09010e9.assembly.stream [1635324]
State: COMPLETE
Built by: ocp-build/buildvm.openshift.eng.bos.redhat.com
Source: git://pkgs.devel.redhat.com/containers/clusterresourceoverride-operator#85e1a37d1a6cdfaa83c1ebb8309ff352da0e8801
Volume: DEFAULT
Task: none
Finished: Tue, 15 Jun 2021 23:45:20 UTC
Tags: rhaos-4.8-rhel-8-candidate RHBA-2021:2435-pending
...
"""
stdout, stderr = exectools.cmd_assert(cmd, retries=3)
return 0, stdout, stderr # In this used to be cmd_gather, so return rc=0.

Expand Down Expand Up @@ -758,7 +777,7 @@ def get_latest_build(self):

for brew_build in self.get_all_builds():
component, version, release = self.unpack_nvr(brew_build)
release = int(re.search(r'\d+', release).group())
release = int(re.search(r'\d+', release).group()) # extract datetime from release; e.g. 202106152230
if component == self.metadata_component and version == self.metadata_version and release > candidate_release:
candidate_release = release
candidate = brew_build
Expand All @@ -777,6 +796,9 @@ def get_all_builds(self):
yield line.split(' ')[0]

def unpack_nvr(self, nvr):
"""
e.g. ('ose-clusterresourceoverride-operator-container', 'v4.8.0', '202106152230.p0.git.09010e9.assembly.stream')
"""
return tuple(nvr.rsplit('-', 2))

@property
Expand Down

0 comments on commit 1834dc3

Please sign in to comment.