add is_system to workflow_templates for sys workflows

This commit is contained in:
rushtehrani
2020-05-10 20:42:33 -07:00
parent 1a387f6c72
commit 6c785ed2a6
4 changed files with 11 additions and 1 deletions

View 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;

View File

@@ -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

View File

@@ -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")

View File

@@ -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