Skip to content

Commit

Permalink
Add support for *info in clone command
Browse files Browse the repository at this point in the history
Add -d/--distro <distro> option to `rdopkg clone` (default is rdo)
Add rdoinfo.get_distroinfo(distro)
Keep rdoinfo.get_rdo_info as a compat method
Move RDO_INFO_FILES into config singleton

Change-Id: Iff50e8cd2d2bf25decde844fc4ba8663a58d93bf
  • Loading branch information
hguemar committed Nov 29, 2018
1 parent 5916ede commit a6e6497
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 11 deletions.
31 changes: 25 additions & 6 deletions rdopkg/actionmods/rdoinfo.py
Expand Up @@ -4,14 +4,11 @@
import distroinfo.query
from distroinfo.info import DistroInfo

from rdopkg import helpers
from rdopkg import exception, helpers
from rdopkg.utils import log
from rdopkg.conf import cfg


RDO_INFO_FILES = 'rdo-full.yml'


def print_releases(info):
print("{t.bold}RDO releases & repos:{t.normal}".format(t=log.term))
for rls in info['releases']:
Expand Down Expand Up @@ -87,10 +84,32 @@ def print_pkg(pkg):
dp(pkg)


def get_distroinfo(distro='rdo'):
"""Retrieve distroinfo (default is 'rdo')
"""
info_url_conf = distro.upper() + 'INFO_RAW_URL'
info_files_conf = distro.upper() + '_INFO_FILES'
try:
remote_info = cfg[info_url_conf]
except KeyError:
raise exception.InvalidUsage(
why="Couldn't find config option %s for distro: %s"
% (info_url_conf, distro))
try:
info_files = cfg[info_files_conf]
except KeyError:
raise exception.InvalidUsage(
why="Couldn't find config option %s for distro: %s"
% (info_files_conf, distro))
return DistroInfo(info_files, remote_info=remote_info)


def get_rdoinfo():
return DistroInfo(RDO_INFO_FILES, remote_info=cfg['RDOINFO_RAW_URL'])
"""Compat function
"""
return get_distroinfo(distro='rdo')


def get_default_inforepo(apply_tag=None, include_fns=None):
raise DeprecationWarning("rdopkg >= 0.47.0 uses distroinfo, please use "
"`get_rdoinfo` instead.")
"`get_distroinfo` instead.")
2 changes: 2 additions & 0 deletions rdopkg/actions/distgit/__init__.py
Expand Up @@ -28,6 +28,8 @@
"'gerrit-origin' and 'gerrit-patches'"),
Arg('review_user', shortcut='-u', metavar='USER',
help="gerrit username for reviews"),
Arg('distro', shortcut='-d', metavar='DISTRO',
help="distroinfo configuration"),
]),
Action('pkgenv', help="show detected package environment",
steps=[
Expand Down
5 changes: 3 additions & 2 deletions rdopkg/actions/distgit/actions.py
Expand Up @@ -320,8 +320,9 @@ def clone(
force_fetch=False,
use_master_distgit=False,
gerrit_remotes=False,
review_user=None):
rdo = rdoinfo.get_rdoinfo()
review_user=None,
distro='rdo'):
rdo = rdoinfo.get_distroinfo(distro=distro)
ri = rdo.get_info()
pkg = get_package(ri, package)
if not pkg:
Expand Down
10 changes: 7 additions & 3 deletions rdopkg/actions/info/actions.py
Expand Up @@ -8,11 +8,13 @@
from rdopkg import helpers
from rdopkg.utils import git
from rdopkg.utils import log
from rdopkg.conf import cfg


def info(pkgs=None, local_info=None, apply_tag=None, force_fetch=False):
if local_info:
di = DistroInfo(rdoinfo.RDO_INFO_FILES,
rdo_info_files = cfg['RDO_INFO_FILES']
di = DistroInfo(rdo_info_files,
local_info=local_info)
else:
di = rdoinfo.get_rdoinfo()
Expand Down Expand Up @@ -41,7 +43,8 @@ def info(pkgs=None, local_info=None, apply_tag=None, force_fetch=False):

def info_tags_diff(local_info, buildsys_tags=False):
# TODO: support custom info files as an optional argument
di = DistroInfo(rdoinfo.RDO_INFO_FILES, local_info=local_info)
rdo_info_files = cfg['RDO_INFO_FILES']
di = DistroInfo(rdo_info_files, local_info=local_info)
if buildsys_tags:
tagsname = 'buildsys-tags'
else:
Expand All @@ -60,7 +63,8 @@ def info_tags_diff(local_info, buildsys_tags=False):

def findpkg(query, strict=False, local_info=None, force_fetch=False):
if local_info:
di = DistroInfo(rdoinfo.RDO_INFO_FILES, local_info=local_info)
rdo_info_files = cfg['RDO_INFO_FILES']
di = DistroInfo(rdo_info_files, local_info=local_info)
else:
di = rdoinfo.get_rdoinfo()
info = di.get_info()
Expand Down
1 change: 1 addition & 0 deletions rdopkg/conf.py
Expand Up @@ -36,6 +36,7 @@ def __repr__(self):

cfg = Config({
'HOME_DIR': os.path.expanduser("~/.rdopkg"),
'RDO_INFO_FILES': 'rdo-full.yml',
'RDOINFO_REPO': 'https://github.com/redhat-openstack/rdoinfo.git',
'RDOINFO_RAW_URL': ('https://raw.githubusercontent.com/'
'redhat-openstack/rdoinfo/master/'),
Expand Down

0 comments on commit a6e6497

Please sign in to comment.