Fix bootstrap_repositories.py
This commit is contained in:
parent
fdcbf4047f
commit
f5bdf81d2d
@ -341,3 +341,34 @@ class Services(object):
|
||||
break
|
||||
break
|
||||
return res
|
||||
|
||||
def get_service_with_repo_by_service_type(self, service_type):
|
||||
"""Retrieve service with repos by service_type
|
||||
|
||||
:param str service_type: Filter by service_type
|
||||
"""
|
||||
res = dict()
|
||||
res = {}
|
||||
services = self.all_services
|
||||
for service in services:
|
||||
if service["service_type"] == service_type:
|
||||
res = service
|
||||
for repositories in self.all_repositories:
|
||||
if repositories["service_type"] == service["service_type"]:
|
||||
res["repositories"] = repositories["repositories"]
|
||||
break
|
||||
break
|
||||
return res
|
||||
|
||||
def services_with_repos(self):
|
||||
"""Retrieve all services with repos
|
||||
"""
|
||||
res = []
|
||||
services = self.all_services
|
||||
for i, service in enumerate(services):
|
||||
res.append(service)
|
||||
for repositories in self.all_repositories:
|
||||
if repositories["service_type"] == service["service_type"]:
|
||||
res[i]["repositories"] = repositories["repositories"]
|
||||
break
|
||||
return res
|
@ -113,17 +113,18 @@ def process_repositories(args, service):
|
||||
workdir.mkdir(exist_ok=True)
|
||||
|
||||
for repo in service["repositories"]:
|
||||
logging.debug(f"Processing repository {repo}")
|
||||
repo_dir = pathlib.Path(workdir, repo["type"], repo["repo"])
|
||||
if repo["cloud_environments"][0] == args.cloud_environment:
|
||||
logging.debug(f"Processing repository {repo}")
|
||||
repo_dir = pathlib.Path(workdir, repo["type"], repo["repo"])
|
||||
|
||||
if repo["environment"] != args.target_environment:
|
||||
continue
|
||||
if repo["environment"] != args.target_environment:
|
||||
continue
|
||||
|
||||
checkout_exists = repo_dir.exists()
|
||||
logging.debug(f"Repository {repo} exists {checkout_exists}")
|
||||
repo_dir.parent.mkdir(parents=True, exist_ok=True)
|
||||
if True: # not checkout_exists:
|
||||
create_repo(repo, repo_dir, service)
|
||||
checkout_exists = repo_dir.exists()
|
||||
logging.debug(f"Repository {repo} exists {checkout_exists}")
|
||||
repo_dir.parent.mkdir(parents=True, exist_ok=True)
|
||||
if True: # not checkout_exists:
|
||||
create_repo(repo, repo_dir, service)
|
||||
|
||||
|
||||
def main():
|
||||
@ -139,14 +140,20 @@ def main():
|
||||
required=True,
|
||||
help="Working directory to use for repository checkout.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--cloud-environment",
|
||||
required=True,
|
||||
default="eu_de",
|
||||
help="Cloud Environment. Default: eu_de",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
services = []
|
||||
if args.service_type:
|
||||
services = [data.service_dict.get(args.service_type)]
|
||||
services = [data.get_service_with_repo_by_service_type(service_type=args.service_type)]
|
||||
else:
|
||||
services = data.all_services
|
||||
services = data.services_with_repos()
|
||||
|
||||
for service in services:
|
||||
process_repositories(args, service)
|
||||
|
Loading…
x
Reference in New Issue
Block a user