mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-11-02 20:04:01 +08:00
increase column size to 63 for cron workflows and workflo executions
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE workflow_executions ALTER COLUMN uid TYPE varchar(63);
|
||||
ALTER TABLE workflow_executions ALTER COLUMN name TYPE varchar(63);
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE workflow_executions ALTER COLUMN uid TYPE varchar(30);
|
||||
ALTER TABLE workflow_executions ALTER COLUMN uid TYPE text;
|
||||
7
db/20200522171359_alter_cron_workflows_column_sizes.sql
Normal file
7
db/20200522171359_alter_cron_workflows_column_sizes.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE cron_workflows ALTER COLUMN uid TYPE varchar(63);
|
||||
ALTER TABLE cron_workflows ALTER COLUMN name TYPE varchar(63);
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE cron_workflows ALTER COLUMN uid TYPE varchar(30);
|
||||
ALTER TABLE cron_workflows ALTER COLUMN name TYPE varchar(30);
|
||||
@@ -38,7 +38,7 @@ func (c *Client) UpdateCronWorkflow(namespace string, uid string, cronWorkflow *
|
||||
|
||||
// TODO: Need to pull system parameters from k8s config/secret here, example: HOST
|
||||
opts := &WorkflowExecutionOptions{}
|
||||
opts.GenerateName, err = uid2.GenerateUID(workflowTemplate.Name)
|
||||
opts.GenerateName, err = uid2.GenerateUID(workflowTemplate.Name, 63)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -164,7 +164,7 @@ func (c *Client) CreateCronWorkflow(namespace string, cronWorkflow *CronWorkflow
|
||||
|
||||
//// TODO: Need to pull system parameters from k8s config/secret here, example: HOST
|
||||
opts := &WorkflowExecutionOptions{}
|
||||
opts.GenerateName, err = uid2.GenerateUID(workflowTemplate.Name)
|
||||
opts.GenerateName, err = uid2.GenerateUID(workflowTemplate.Name, 63)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -235,7 +235,7 @@ func (c *Client) CreateCronWorkflow(namespace string, cronWorkflow *CronWorkflow
|
||||
cronWorkflow.Name = argoCreatedCronWorkflow.Name
|
||||
cronWorkflow.CreatedAt = argoCreatedCronWorkflow.CreationTimestamp.UTC()
|
||||
|
||||
cronWorkflow.UID, err = uid2.GenerateUID(argoCreatedCronWorkflow.Name)
|
||||
cronWorkflow.UID, err = uid2.GenerateUID(argoCreatedCronWorkflow.Name, 63)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -2,15 +2,16 @@ package uid
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func GenerateUID(input string) (string, error) {
|
||||
func GenerateUID(input string, max int) (string, error) {
|
||||
re, _ := regexp.Compile(`[^a-zA-Z0-9-]{1,}`)
|
||||
cleanUp := strings.ToLower(re.ReplaceAllString(input, `-`))
|
||||
if len(cleanUp) > 30 {
|
||||
return "", errors.New("Length of string exceeds 30.")
|
||||
if len(cleanUp) > max {
|
||||
return "", errors.New(fmt.Sprintf("Length of string exceeds %d", max))
|
||||
}
|
||||
return strings.ToLower(re.ReplaceAllString(input, `-`)), nil
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ func (c *Client) createWorkflow(namespace string, workflowTemplateId uint64, wor
|
||||
return 0, nil, err
|
||||
}
|
||||
|
||||
uid, err := uid2.GenerateUID(createdWorkflow.Name)
|
||||
uid, err := uid2.GenerateUID(createdWorkflow.Name, 63)
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
@@ -344,7 +344,7 @@ func (c *Client) CreateWorkflowExecution(namespace string, workflow *WorkflowExe
|
||||
Labels: &map[string]string{},
|
||||
Parameters: workflow.Parameters,
|
||||
}
|
||||
opts.GenerateName, err = uid2.GenerateUID(workflowTemplate.Name)
|
||||
opts.GenerateName, err = uid2.GenerateUID(workflowTemplate.Name, 63)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import (
|
||||
)
|
||||
|
||||
func (c *Client) createWorkflowTemplate(namespace string, workflowTemplate *WorkflowTemplate) (*WorkflowTemplate, *WorkflowTemplateVersion, error) {
|
||||
uid, err := uid2.GenerateUID(workflowTemplate.Name)
|
||||
uid, err := uid2.GenerateUID(workflowTemplate.Name, 30)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -717,7 +717,7 @@ func createArgoWorkflowTemplate(workflowTemplate *WorkflowTemplate, version int6
|
||||
return nil, err
|
||||
}
|
||||
|
||||
worfklowTemplateName, err := uid2.GenerateUID(workflowTemplate.Name)
|
||||
worfklowTemplateName, err := uid2.GenerateUID(workflowTemplate.Name, 30)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -431,7 +431,7 @@ metadata:
|
||||
}
|
||||
|
||||
func (c *Client) createWorkspaceTemplate(namespace string, workspaceTemplate *WorkspaceTemplate) (*WorkspaceTemplate, error) {
|
||||
uid, err := uid2.GenerateUID(workspaceTemplate.Name)
|
||||
uid, err := uid2.GenerateUID(workspaceTemplate.Name, 30)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user