The operator class has gotten fairly large, this is a first pass in refactoring operator.py into a submodule instead, with multiple operator instances which handle different types of objects. - The main k8s interface has been split into K8sOpApi which extends K8sApi and is shared across all operators. - Each operator extends BaseOperator which also has an instance of K8sOpApi - The CrawlOperator is still the bulk of the functionality, but will likely be further refactored to support QA jobs --------- Co-authored-by: Tessa Walsh <tessa@bitarchivist.net>
		
			
				
	
	
		
			29 lines
		
	
	
		
			739 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			739 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| """ operators module """
 | |
| 
 | |
| from .profiles import ProfileOperator
 | |
| from .bgjobs import BgJobOperator
 | |
| from .cronjobs import CronJobOperator
 | |
| from .crawls import CrawlOperator
 | |
| from .baseoperator import K8sOpAPI
 | |
| 
 | |
| operator_classes = [ProfileOperator, BgJobOperator, CronJobOperator, CrawlOperator]
 | |
| 
 | |
| 
 | |
| # ============================================================================
 | |
| def init_operator_api(app, *args):
 | |
|     """registers webhook handlers for metacontroller"""
 | |
| 
 | |
|     k8s = K8sOpAPI()
 | |
| 
 | |
|     operators = []
 | |
|     for cls in operator_classes:
 | |
|         oper = cls(k8s, *args)
 | |
|         oper.init_routes(app)
 | |
|         operators.append(oper)
 | |
| 
 | |
|     @app.get("/healthz", include_in_schema=False)
 | |
|     async def healthz():
 | |
|         return {}
 | |
| 
 | |
|     return k8s
 |