mirror of
				https://github.com/onepanelio/onepanel.git
				synced 2025-10-31 08:46:20 +08:00 
			
		
		
		
	Changed name to uid for WatchWorkflowExecution.
This commit is contained in:
		 Aleksandr Melnikov
					Aleksandr Melnikov
				
			
				
					committed by
					
						 rushtehrani
						rushtehrani
					
				
			
			
				
	
			
			
			 rushtehrani
						rushtehrani
					
				
			
						parent
						
							2048b7a4eb
						
					
				
				
					commit
					c1ce0ad17b
				
			| @@ -646,25 +646,25 @@ func (c *Client) CountWorkflowExecutions(namespace, workflowTemplateUID, workflo | ||||
| 	return | ||||
| } | ||||
|  | ||||
| func (c *Client) WatchWorkflowExecution(namespace, name string) (<-chan *WorkflowExecution, error) { | ||||
| 	_, err := c.GetWorkflowExecution(namespace, name) | ||||
| func (c *Client) WatchWorkflowExecution(namespace, uid string) (<-chan *WorkflowExecution, error) { | ||||
| 	_, err := c.GetWorkflowExecution(namespace, uid) | ||||
| 	if err != nil { | ||||
| 		log.WithFields(log.Fields{ | ||||
| 			"Namespace": namespace, | ||||
| 			"Name":      name, | ||||
| 			"UID":       uid, | ||||
| 			"Error":     err.Error(), | ||||
| 		}).Error("Workflow template not found.") | ||||
| 		return nil, util.NewUserError(codes.NotFound, "Workflow not found.") | ||||
| 	} | ||||
|  | ||||
| 	fieldSelector, _ := fields.ParseSelector(fmt.Sprintf("metadata.name=%s", name)) | ||||
| 	fieldSelector, _ := fields.ParseSelector(fmt.Sprintf("metadata.name=%s", uid)) | ||||
| 	watcher, err := c.ArgoprojV1alpha1().Workflows(namespace).Watch(metav1.ListOptions{ | ||||
| 		FieldSelector: fieldSelector.String(), | ||||
| 	}) | ||||
| 	if err != nil { | ||||
| 		log.WithFields(log.Fields{ | ||||
| 			"Namespace": namespace, | ||||
| 			"Name":      name, | ||||
| 			"UID":       uid, | ||||
| 			"Error":     err.Error(), | ||||
| 		}).Error("Watch Workflow error.") | ||||
| 		return nil, util.NewUserError(codes.Unknown, "Error with watching workflow.") | ||||
| @@ -688,11 +688,11 @@ func (c *Client) WatchWorkflowExecution(namespace, name string) (<-chan *Workflo | ||||
| 			} | ||||
|  | ||||
| 			if workflow == nil && !ok { | ||||
| 				workflow, err = c.ArgoprojV1alpha1().Workflows(namespace).Get(name, metav1.GetOptions{}) | ||||
| 				workflow, err = c.ArgoprojV1alpha1().Workflows(namespace).Get(uid, metav1.GetOptions{}) | ||||
| 				if err != nil { | ||||
| 					log.WithFields(log.Fields{ | ||||
| 						"Namespace": namespace, | ||||
| 						"Name":      name, | ||||
| 						"UID":       uid, | ||||
| 						"Workflow":  workflow, | ||||
| 						"Error":     err.Error(), | ||||
| 					}).Error("Unable to get workflow.") | ||||
| @@ -709,7 +709,7 @@ func (c *Client) WatchWorkflowExecution(namespace, name string) (<-chan *Workflo | ||||
| 			if err != nil { | ||||
| 				log.WithFields(log.Fields{ | ||||
| 					"Namespace": namespace, | ||||
| 					"Name":      name, | ||||
| 					"UID":       uid, | ||||
| 					"Workflow":  workflow, | ||||
| 					"Error":     err.Error(), | ||||
| 				}).Error("Error with trying to JSON Marshal workflow.Status.") | ||||
|   | ||||
| @@ -160,12 +160,12 @@ func (s *WorkflowServer) GetWorkflowExecution(ctx context.Context, req *api.GetW | ||||
|  | ||||
| func (s *WorkflowServer) WatchWorkflowExecution(req *api.WatchWorkflowExecutionRequest, stream api.WorkflowService_WatchWorkflowExecutionServer) error { | ||||
| 	client := stream.Context().Value("kubeClient").(*v1.Client) | ||||
| 	allowed, err := auth.IsAuthorized(client, req.Namespace, "get", "argoproj.io", "workflows", req.Name) | ||||
| 	allowed, err := auth.IsAuthorized(client, req.Namespace, "get", "argoproj.io", "workflows", req.Uid) | ||||
| 	if err != nil || !allowed { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	watcher, err := client.WatchWorkflowExecution(req.Namespace, req.Name) | ||||
| 	watcher, err := client.WatchWorkflowExecution(req.Namespace, req.Uid) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user