mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-10-27 23:31:27 +08:00
add is_system to workflow_templates for sys workflows
This commit is contained in:
7
db/20200510202248_AddIsSystemToWorkflowTemplates.sql
Normal file
7
db/20200510202248_AddIsSystemToWorkflowTemplates.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE workflow_templates ADD COLUMN is_system BOOLEAN DEFAULT false;
|
||||
UPDATE workflow_templates SET is_system = false;
|
||||
ALTER TABLE workflow_templates ALTER COLUMN is_system SET NOT NULL;
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE workflow_templates DROP COLUMN is_system;
|
||||
@@ -169,6 +169,7 @@ type WorkflowTemplate struct {
|
||||
Versions int64 `db:"versions"` // How many versions there are of this template total.
|
||||
IsLatest bool
|
||||
IsArchived bool `db:"is_archived"`
|
||||
IsSystem bool `db:"is_system"`
|
||||
ArgoWorkflowTemplate *wfv1.WorkflowTemplate
|
||||
Labels map[string]string
|
||||
WorkflowExecutionStatisticReport *WorkflowExecutionStatisticReport
|
||||
|
||||
@@ -41,6 +41,7 @@ func (c *Client) createWorkflowTemplate(namespace string, workflowTemplate *Work
|
||||
"uid": uid,
|
||||
"name": workflowTemplate.Name,
|
||||
"namespace": namespace,
|
||||
"is_system": workflowTemplate.IsSystem,
|
||||
}).
|
||||
Suffix("RETURNING id").
|
||||
RunWith(tx).
|
||||
@@ -308,6 +309,7 @@ func (c *Client) listWorkflowTemplates(namespace string, paginator *pagination.P
|
||||
GroupBy("wt.id", "wt.created_at", "wt.uid", "wt.name", "wt.is_archived").
|
||||
Where(sq.Eq{
|
||||
"wt.is_archived": false,
|
||||
"wt.is_system": false,
|
||||
}).
|
||||
OrderBy("wt.created_at DESC")
|
||||
|
||||
|
||||
@@ -423,11 +423,11 @@ func (c *Client) createWorkspaceTemplate(namespace string, workspaceTemplate *Wo
|
||||
}
|
||||
defer tx.Rollback()
|
||||
|
||||
workspaceTemplate.WorkflowTemplate.IsSystem = true
|
||||
workspaceTemplate.WorkflowTemplate, err = c.CreateWorkflowTemplate(namespace, workspaceTemplate.WorkflowTemplate)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
workspaceTemplate.Version = workspaceTemplate.WorkflowTemplate.Version
|
||||
workspaceTemplate.IsLatest = true
|
||||
|
||||
|
||||
Reference in New Issue
Block a user