-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Allow overriding workflow labels in 'argo submit' #1475
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,6 +141,7 @@ type SubmitOpts struct { | |
Parameters []string // --parameter | ||
ParameterFile string // --parameter-file | ||
ServiceAccount string // --serviceaccount | ||
Labels string // --labels | ||
OwnerReference *metav1.OwnerReference // useful if your custom controller creates argo workflow resources | ||
} | ||
|
||
|
@@ -155,14 +156,17 @@ func SubmitWorkflow(wfIf v1alpha1.WorkflowInterface, wf *wfv1.Workflow, opts *Su | |
if opts.ServiceAccount != "" { | ||
wf.Spec.ServiceAccountName = opts.ServiceAccount | ||
} | ||
labels := wf.GetLabels() | ||
if opts.Labels != "" { | ||
labels, _ = cmdutil.ParseLabels(opts.Labels) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we silently ignore an error from this method? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Labels from a workflow are completely ignored if labels are set by the command line flag. I think we should merge the labels. |
||
} | ||
if labels == nil { | ||
labels = make(map[string]string) | ||
} | ||
if opts.InstanceID != "" { | ||
labels := wf.GetLabels() | ||
if labels == nil { | ||
labels = make(map[string]string) | ||
} | ||
labels[common.LabelKeyControllerInstanceID] = opts.InstanceID | ||
wf.SetLabels(labels) | ||
} | ||
wf.SetLabels(labels) | ||
if len(opts.Parameters) > 0 || opts.ParameterFile != "" { | ||
newParams := make([]wfv1.Parameter, 0) | ||
passedParams := make(map[string]bool) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you write tests for this method?