Fix bootstrap_repositories.py
This commit is contained in:
		@ -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,6 +113,7 @@ def process_repositories(args, service):
 | 
			
		||||
    workdir.mkdir(exist_ok=True)
 | 
			
		||||
 | 
			
		||||
    for repo in service["repositories"]:
 | 
			
		||||
        if repo["cloud_environments"][0] == args.cloud_environment:
 | 
			
		||||
            logging.debug(f"Processing repository {repo}")
 | 
			
		||||
            repo_dir = pathlib.Path(workdir, repo["type"], repo["repo"])
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user