mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-10-05 05:36:50 +08:00
Refactoring per feedback.
- https://github.com/onepanelio/core/pull/226#discussion_r429046881 Removing helper methods that are not saving code. - This also fixes k8s / db methods that were exposed from the package. Instead, using an ArchiveWorkflowExecution function to achieve the same functionality.
This commit is contained in:
@@ -173,6 +173,26 @@ func (c *Client) injectAutomatedFields(namespace string, wf *wfv1.Workflow, opts
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Client) ArchiveWorkflowExecution(namespace, uid string) error {
|
||||
_, err := sb.Update("workflow_executions").Set("is_archived", true).Where(sq.Eq{
|
||||
"uid": uid,
|
||||
"namespace": namespace,
|
||||
}).RunWith(c.DB).Exec()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = c.ArgoprojV1alpha1().Workflows(namespace).Delete(uid, nil)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "not found") {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
/*
|
||||
Name is == to UID, no user friendly name.
|
||||
Workflow execution name == uid, example: name = my-friendly-wf-name-8skjz, uid = my-friendly-wf-name-8skjz
|
||||
@@ -1466,33 +1486,3 @@ func (c *Client) getWorkflowExecutionAndTemplate(namespace string, uid string) (
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Client) DeleteWorkflowExecutionK8S(namespace, uid string) error {
|
||||
err := c.ArgoprojV1alpha1().Workflows(namespace).Delete(uid, nil)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "not found") {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) ArchiveWorkflowExecutionDB(namespace, uid string) error {
|
||||
tx, err := c.DB.Begin()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer tx.Rollback()
|
||||
_, err = sb.Update("workflow_executions").Set("is_archived", true).Where(sq.Eq{
|
||||
"uid": uid,
|
||||
"namespace": namespace,
|
||||
}).RunWith(tx).Exec()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := tx.Commit(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user