mirror of
https://github.com/onepanelio/onepanel.git
synced 2025-10-16 02:31:04 +08:00
Fixing labels and ENV VARs not persisting on CronWorkflow change.
This commit is contained in:
@@ -63,7 +63,7 @@ func (c *Client) UpdateCronWorkflow(namespace string, name string, cronWorkflow
|
||||
|
||||
for _, wf := range workflows {
|
||||
argoCronWorkflow.Spec.WorkflowSpec = wf.Spec
|
||||
argoCreatedCronWorkflow, err := c.updateCronWorkflow(namespace, name, &argoCronWorkflow, opts)
|
||||
argoCreatedCronWorkflow, err := c.updateCronWorkflow(namespace, name, &wf, &argoCronWorkflow, opts)
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{
|
||||
"Namespace": namespace,
|
||||
@@ -299,7 +299,7 @@ func (c *Client) ListCronWorkflows(namespace, workflowTemplateUID string) (cronW
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Client) updateCronWorkflow(namespace string, name string, cwf *wfv1.CronWorkflow, opts *WorkflowExecutionOptions) (updatedCronWorkflow *wfv1.CronWorkflow, err error) {
|
||||
func (c *Client) updateCronWorkflow(namespace string, name string, wf *wfv1.Workflow, cwf *wfv1.CronWorkflow, opts *WorkflowExecutionOptions) (updatedCronWorkflow *wfv1.CronWorkflow, err error) {
|
||||
//Make sure the CronWorkflow exists before we edit it
|
||||
toUpdateCWF, err := c.ArgoprojV1alpha1().CronWorkflows(namespace).Get(name, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
@@ -351,6 +351,23 @@ func (c *Client) updateCronWorkflow(namespace string, name string, cwf *wfv1.Cro
|
||||
cwf.ObjectMeta.Labels = *opts.Labels
|
||||
}
|
||||
|
||||
//todo move this earlier in the process
|
||||
if err = c.injectAutomatedFields(namespace, wf, opts); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cwf.Spec.WorkflowSpec = wf.Spec
|
||||
cwf.Spec.WorkflowMetadata = &wf.ObjectMeta
|
||||
|
||||
//merge the labels
|
||||
mergedLabels := wf.ObjectMeta.Labels
|
||||
if mergedLabels == nil {
|
||||
mergedLabels = make(map[string]string)
|
||||
}
|
||||
for k, v := range *opts.Labels {
|
||||
mergedLabels[k] = v
|
||||
}
|
||||
cwf.Spec.WorkflowMetadata.Labels = mergedLabels
|
||||
|
||||
cwf.Name = name
|
||||
cwf.ResourceVersion = toUpdateCWF.ResourceVersion
|
||||
updatedCronWorkflow, err = c.ArgoprojV1alpha1().CronWorkflows(namespace).Update(cwf)
|
||||
|
Reference in New Issue
Block a user