mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-11-02 20:04:01 +08:00
Using GenerateUID to clean up the names.
This commit is contained in:
committed by
rushtehrani
parent
184bb1247d
commit
18a795f129
@@ -38,8 +38,11 @@ func (c *Client) UpdateCronWorkflow(namespace string, name string, cronWorkflow
|
||||
|
||||
// TODO: Need to pull system parameters from k8s config/secret here, example: HOST
|
||||
opts := &WorkflowExecutionOptions{}
|
||||
re, _ := regexp.Compile(`[^a-zA-Z0-9-]{1,}`)
|
||||
opts.GenerateName = strings.ToLower(re.ReplaceAllString(workflowTemplate.Name, `-`)) + "-"
|
||||
opts.GenerateName, err = uid.GenerateUID(workflowTemplate.Name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
opts.GenerateName += "-"
|
||||
for _, param := range workflow.Parameters {
|
||||
opts.Parameters = append(opts.Parameters, Parameter{
|
||||
Name: param.Name,
|
||||
@@ -228,7 +231,11 @@ func (c *Client) CreateCronWorkflow(namespace string, cronWorkflow *CronWorkflow
|
||||
|
||||
cronWorkflow.Name = argoCreatedCronWorkflow.Name
|
||||
cronWorkflow.CreatedAt = argoCreatedCronWorkflow.CreationTimestamp.UTC()
|
||||
cronWorkflow.UID = string(argoCreatedCronWorkflow.ObjectMeta.UID)
|
||||
|
||||
cronWorkflow.UID, err = uid.GenerateUID(argoCreatedCronWorkflow.Name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cronWorkflow.WorkflowExecution.WorkflowTemplate = workflowTemplate
|
||||
// Manifests could get big, don't return them in this case.
|
||||
cronWorkflow.WorkflowExecution.WorkflowTemplate.Manifest = ""
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/onepanelio/core/pkg/util/label"
|
||||
"github.com/onepanelio/core/pkg/util/pagination"
|
||||
"github.com/onepanelio/core/pkg/util/ptr"
|
||||
uid2 "github.com/onepanelio/core/pkg/util/uid"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
k8serrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
@@ -248,7 +249,10 @@ func (c *Client) createWorkflow(namespace string, workflowTemplateId uint64, wor
|
||||
return 0, nil, err
|
||||
}
|
||||
|
||||
uid := wf.Labels[label.WorkflowUid]
|
||||
uid, err := uid2.GenerateUID(createdWorkflow.Name)
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
//Create an entry for workflow_executions statistic
|
||||
//CURL code will hit the API endpoint that will update the db row
|
||||
newDbId, err = c.insertPreWorkflowExecutionStatistic(namespace, createdWorkflow.Name, workflowTemplateVersionId, createdWorkflow.CreationTimestamp.UTC(), uid, opts.Parameters)
|
||||
|
||||
Reference in New Issue
Block a user