// UpdateWorkflow Updates a workflow resource, re-syncing if necessary
UpdateWorkflow Updates a workflow resource, re-syncing if necessary
// UpdateWorkflow Updates a workflow resource re - syncing if necessary
func UpdateWorkflow(client *rest.RESTClient, workflow *workflowsv1.Workflow, updater WorkflowUpdater) error {
	updater(workflow)
	err := client.Put().
		Name(workflow.ObjectMeta.Name).
		Namespace(workflow.ObjectMeta.Namespace).
		Resource(workflowsv1.WorkflowsPluralName).
		Body(workflow).
		Do().
		Error()
	if kubeerr.IsConflict(err) {
		log.Debugf(`Workflow "%v" was changed, need to re-sync`, workflow.ObjectMeta.Name)
		result := client.Get().
			Name(workflow.ObjectMeta.Name).
			Namespace(workflow.ObjectMeta.Namespace).
			Resource(workflowsv1.WorkflowsPluralName).
			Do()
		err = result.Error()
		if err != nil {
			return err
		}
		updatedWorkflowRaw, err := result.Get()
		if err != nil {
			return err
		}
		updatedWorkflow, ok := updatedWorkflowRaw.(*workflowsv1.Workflow)
		if !ok {
			return errors.New(`Invalid workflow retrieved while trying to re-sync "` +
				workflow.ObjectMeta.Name + `"`)
		}
		updater(updatedWorkflow)
		err = client.Put().
			Name(workflow.ObjectMeta.Name).
			Namespace(workflow.ObjectMeta.Namespace).
			Resource(workflowsv1.WorkflowsPluralName).
			Body(workflow).
			Do().
			Error()
		if err != nil {
			return err
		}
	} else if err != nil {
		return err
	}
	log.Debugf(`Workflow "%v" updated`, workflow.ObjectMeta.Name)
	return nil
}
func UpdateWorkflow ( client * rest . RESTClient , workflow * workflowsv1 . Workflow , updater WorkflowUpdater ) error { updater ( workflow ) err := client . Put ( ) . Name ( workflow . ObjectMeta . Name ) . Namespace ( workflow . ObjectMeta . Namespace ) . Resource ( workflowsv1 . WorkflowsPluralName ) . Body ( workflow ) . Do ( ) . Error ( ) if kubeerr . IsConflict ( err ) { log . Debugf ( `Workflow "%v" was changed, need to re-sync` , workflow . ObjectMeta . Name ) result := client . Get ( ) . Name ( workflow . ObjectMeta . Name ) . Namespace ( workflow . ObjectMeta . Namespace ) . Resource ( workflowsv1 . WorkflowsPluralName ) . Do ( ) err = result . Error ( ) if err != nil { return err } updatedWorkflowRaw , err := result . Get ( ) if err != nil { return err } updatedWorkflow , ok := updatedWorkflowRaw . ( * workflowsv1 . Workflow ) if ! ok { return errors . New ( `Invalid workflow retrieved while trying to re-sync "` + workflow . ObjectMeta . Name + `"` ) } updater ( updatedWorkflow ) err = client . Put ( ) . Name ( workflow . ObjectMeta . Name ) . Namespace ( workflow . ObjectMeta . Namespace ) . Resource ( workflowsv1 . WorkflowsPluralName ) . Body ( workflow ) . Do ( ) . Error ( ) if err != nil { return err } } else if err != nil { return err } log . Debugf ( `Workflow "%v" updated` , workflow . ObjectMeta . Name ) return nil }
UpdateWorkflow Updates a workflow resource, re-syncing if necessary
UpdateWorkflow Updates a workflow resource re - syncing if necessary