config: Symplify .config.yaml file handling
If no configuration file is specified, we try to load a single .config.yaml from KAS_WORK_DIR and set the top_repo_path to the repo root of this file with fallback to the containing directory. This process is identical to loading explicitly specified configuration files and can therefore be combined into one case. Signed-off-by: Johann Neuhauser <jneuhauser@dh-electronics.com> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
		
				
					committed by
					
						 Jan Kiszka
						Jan Kiszka
					
				
			
			
				
	
			
			
			
						parent
						
							cbdba7e8e1
						
					
				
				
					commit
					bce8a916fa
				
			| @@ -41,23 +41,22 @@ class Config: | ||||
|         self._override_target = target | ||||
|         self._override_task = task | ||||
|         self._config = {} | ||||
|         if filename: | ||||
|             self.filenames = [os.path.abspath(configfile) | ||||
|                               for configfile in filename.split(':')] | ||||
|             self.top_repo_path = Repo.get_root_path( | ||||
|                 os.path.dirname(self.filenames[0])) | ||||
|         if not filename: | ||||
|             filename = os.path.join(ctx.kas_work_dir, CONFIG_YAML_FILE) | ||||
|  | ||||
|             repo_paths = [Repo.get_root_path(os.path.dirname(configfile), | ||||
|                                              fallback=False) | ||||
|                           for configfile in self.filenames] | ||||
|         self.filenames = [os.path.abspath(configfile) | ||||
|                           for configfile in filename.split(':')] | ||||
|         self.top_repo_path = Repo.get_root_path( | ||||
|             os.path.dirname(self.filenames[0])) | ||||
|  | ||||
|             if len(set(repo_paths)) > 1: | ||||
|                 raise IncludeException('All concatenated config files must ' | ||||
|                                        'belong to the same repository or all ' | ||||
|                                        'must be outside of versioning control') | ||||
|         else: | ||||
|             self.filenames = [os.path.join(ctx.kas_work_dir, CONFIG_YAML_FILE)] | ||||
|             self.top_repo_path = Repo.get_root_path(ctx.kas_work_dir) | ||||
|         repo_paths = [Repo.get_root_path(os.path.dirname(configfile), | ||||
|                                          fallback=False) | ||||
|                       for configfile in self.filenames] | ||||
|  | ||||
|         if len(set(repo_paths)) > 1: | ||||
|             raise IncludeException('All concatenated config files must ' | ||||
|                                    'belong to the same repository or all ' | ||||
|                                    'must be outside of versioning control') | ||||
|  | ||||
|         self.handler = IncludeHandler(self.filenames, self.top_repo_path) | ||||
|         self.repo_dict = self._get_repo_dict() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user