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. Versions int64 `db:"versions"` // How many versions there are of this template total.
IsLatest bool IsLatest bool
IsArchived bool `db:"is_archived"` IsArchived bool `db:"is_archived"`
IsSystem bool `db:"is_system"`
ArgoWorkflowTemplate *wfv1.WorkflowTemplate ArgoWorkflowTemplate *wfv1.WorkflowTemplate
Labels map[string]string Labels map[string]string
WorkflowExecutionStatisticReport *WorkflowExecutionStatisticReport WorkflowExecutionStatisticReport *WorkflowExecutionStatisticReport

View File

@@ -41,6 +41,7 @@ func (c *Client) createWorkflowTemplate(namespace string, workflowTemplate *Work
"uid": uid, "uid": uid,
"name": workflowTemplate.Name, "name": workflowTemplate.Name,
"namespace": namespace, "namespace": namespace,
"is_system": workflowTemplate.IsSystem,
}). }).
Suffix("RETURNING id"). Suffix("RETURNING id").
RunWith(tx). 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"). GroupBy("wt.id", "wt.created_at", "wt.uid", "wt.name", "wt.is_archived").
Where(sq.Eq{ Where(sq.Eq{
"wt.is_archived": false, "wt.is_archived": false,
"wt.is_system": false,
}). }).
OrderBy("wt.created_at DESC") OrderBy("wt.created_at DESC")

View File

@@ -423,11 +423,11 @@ func (c *Client) createWorkspaceTemplate(namespace string, workspaceTemplate *Wo
} }
defer tx.Rollback() defer tx.Rollback()
workspaceTemplate.WorkflowTemplate.IsSystem = true
workspaceTemplate.WorkflowTemplate, err = c.CreateWorkflowTemplate(namespace, workspaceTemplate.WorkflowTemplate) workspaceTemplate.WorkflowTemplate, err = c.CreateWorkflowTemplate(namespace, workspaceTemplate.WorkflowTemplate)
if err != nil { if err != nil {
return nil, err return nil, err
} }
workspaceTemplate.Version = workspaceTemplate.WorkflowTemplate.Version workspaceTemplate.Version = workspaceTemplate.WorkflowTemplate.Version
workspaceTemplate.IsLatest = true workspaceTemplate.IsLatest = true