Skip to content
Snippets Groups Projects
Commit de1f38bb authored by Seblu's avatar Seblu
Browse files

selecting of repo in isrepo is smarter

parent 5fd63e37
No related branches found
No related tags found
No related merge requests found
...@@ -83,12 +83,15 @@ try: ...@@ -83,12 +83,15 @@ try:
args = p_main.parse_args() args = p_main.parse_args()
# load config # load config
config = ConfigFile("isrepo", args.config) config = ConfigFile("isrepo", args.config)
# get config repositories # filtering on repository name if present
repos = config.repos if args.repo_name is not None:
repos = filter(lambda x: x.name == args.repo_name, config.repos)
else:
repos = config.repos
if len(repos) == 1: if len(repos) == 1:
args.repo = repos[repos.keys()[0]] args.repo = repos[0]
elif args.repo_name in repos.keys(): elif len(repos) > 1:
args.repo = repos[args.repo_name] raise Exception("Please select a repository with -r")
else: else:
raise Exception("No image repository found") raise Exception("No image repository found")
debug("Image repo: %s" % args.repo.image) debug("Image repo: %s" % args.repo.image)
......
...@@ -49,7 +49,7 @@ class ConfigFile(object): ...@@ -49,7 +49,7 @@ class ConfigFile(object):
if "image" not in cp.options(rep): if "image" not in cp.options(rep):
continue continue
# get all options in repo # get all options in repo
self._repos.append( RepositoryConfig(rep, **dict(cp.items(rep)))) self._repos.append(RepositoryConfig(rep, **dict(cp.items(rep))))
except Exception as e: except Exception as e:
raise raise
raise Exception("Unable load file %s: %s" % (self.path, e)) raise Exception("Unable load file %s: %s" % (self.path, e))
...@@ -89,6 +89,6 @@ class ConfigFile(object): ...@@ -89,6 +89,6 @@ class ConfigFile(object):
@property @property
def repos(self): def repos(self):
'''Get a dict of repository available''' '''Get a list of repository available'''
# deep copy # deep copy
return list(self._repos) return list(self._repos)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment