Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add {{workspace.uid}} to parameters as a replaceable value #849

Merged
merged 2 commits into from
Jan 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions pkg/workflow_execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,16 @@ func (c *Client) createWorkflow(namespace string, workflowTemplateID uint64, wor
}

newParameters := make([]wfv1.Parameter, 0)

// Only used for workspaces. sysName is the workspace uid
sysName := ""
for i := range wf.Spec.Arguments.Parameters {
param := wf.Spec.Arguments.Parameters[i]
if param.Name == "sys-name" {
sysName = *param.Value
}
}

for i := range wf.Spec.Arguments.Parameters {
param := wf.Spec.Arguments.Parameters[i]
if param.Value != nil {
Expand All @@ -469,6 +479,15 @@ func (c *Client) createWorkflow(namespace string, workflowTemplateID uint64, wor
return nil, reErr
}
value := re.ReplaceAllString(*param.Value, namespace)

if sysName != "" {
reWorkspaceUID, reErr := regexp.Compile(`{{\s*workspace.uid\s*}}`)
if reErr != nil {
return nil, reErr
}
value = reWorkspaceUID.ReplaceAllString(*param.Value, sysName)
}

param.Value = &value
}

Expand Down