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:
args = p_main.parse_args()
# load config
config = ConfigFile("isrepo", args.config)
# get config repositories
repos = config.repos
# filtering on repository name if present
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:
args.repo = repos[repos.keys()[0]]
elif args.repo_name in repos.keys():
args.repo = repos[args.repo_name]
args.repo = repos[0]
elif len(repos) > 1:
raise Exception("Please select a repository with -r")
else:
raise Exception("No image repository found")
debug("Image repo: %s" % args.repo.image)
......
......@@ -49,7 +49,7 @@ class ConfigFile(object):
if "image" not in cp.options(rep):
continue
# 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:
raise
raise Exception("Unable load file %s: %s" % (self.path, e))
......@@ -89,6 +89,6 @@ class ConfigFile(object):
@property
def repos(self):
'''Get a dict of repository available'''
'''Get a list of repository available'''
# deep copy
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