Enabled code to inject ENV Vars and istio + other labels to

Workflows created by CronWorkflow.
This commit is contained in:
Aleksandr Melnikov
2020-04-07 16:01:45 -07:00
parent cb6c305ade
commit 2f8c923fe8

View File

@@ -134,7 +134,7 @@ func (c *Client) CreateCronWorkflow(namespace string, cronWorkflow *CronWorkflow
for _, wf := range workflows { for _, wf := range workflows {
argoCronWorkflow.Spec.WorkflowSpec = wf.Spec argoCronWorkflow.Spec.WorkflowSpec = wf.Spec
argoCreatedCronWorkflow, err := c.createCronWorkflow(namespace, workflowTemplate.UID, &argoCronWorkflow, opts) argoCreatedCronWorkflow, err := c.createCronWorkflow(namespace, &wf, &argoCronWorkflow, opts)
if err != nil { if err != nil {
log.WithFields(log.Fields{ log.WithFields(log.Fields{
"Namespace": namespace, "Namespace": namespace,
@@ -361,7 +361,7 @@ func (c *Client) updateCronWorkflow(namespace string, name string, cwf *wfv1.Cro
return return
} }
func (c *Client) createCronWorkflow(namespace string, workflowTemplateUid string, cwf *wfv1.CronWorkflow, opts *WorkflowExecutionOptions) (createdCronWorkflow *wfv1.CronWorkflow, err error) { func (c *Client) createCronWorkflow(namespace string, wf *wfv1.Workflow, cwf *wfv1.CronWorkflow, opts *WorkflowExecutionOptions) (createdCronWorkflow *wfv1.CronWorkflow, err error) {
if opts == nil { if opts == nil {
opts = &WorkflowExecutionOptions{} opts = &WorkflowExecutionOptions{}
} }
@@ -403,11 +403,11 @@ func (c *Client) createCronWorkflow(namespace string, workflowTemplateUid string
} }
//todo move this earlier in the process //todo move this earlier in the process
//if err = c.injectAutomatedFields(namespace, cwf.Spec.WorkflowSpec, opts); err != nil { if err = c.injectAutomatedFields(namespace, wf, opts); err != nil {
// return nil, err return nil, err
//} }
cwf.Spec.WorkflowSpec = wf.Spec
cwf.Spec.WorkflowMetadata = &metav1.ObjectMeta{Labels: *opts.Labels} cwf.Spec.WorkflowMetadata = &wf.ObjectMeta
createdCronWorkflow, err = c.ArgoprojV1alpha1().CronWorkflows(namespace).Create(cwf) createdCronWorkflow, err = c.ArgoprojV1alpha1().CronWorkflows(namespace).Create(cwf)
if err != nil { if err != nil {
return nil, err return nil, err