-
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
feat: Add default field in parameters.valueFrom #2500
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -425,14 +425,24 @@ func (we *WorkflowExecutor) SaveParameters() error { | |
log.Infof("Copying %s from base image layer", param.ValueFrom.Path) | ||
output, err = we.RuntimeExecutor.GetFileContents(mainCtrID, param.ValueFrom.Path) | ||
if err != nil { | ||
return err | ||
// We have a default value to use instead of returning an error | ||
if param.ValueFrom.Default != "" { | ||
output = param.ValueFrom.Default | ||
} else { | ||
return err | ||
} | ||
} | ||
} else { | ||
log.Infof("Copying %s from from volume mount", param.ValueFrom.Path) | ||
mountedPath := filepath.Join(common.ExecutorMainFilesystemDir, param.ValueFrom.Path) | ||
out, err := ioutil.ReadFile(mountedPath) | ||
if err != nil { | ||
return err | ||
// We have a default value to use instead of returning an error | ||
if param.ValueFrom.Default != "" { | ||
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. test? 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. I didn't include tests for this because it would be difficult to mock this behavior and I have already included a non-E2E test that covers the same behavior here: https://github.com/argoproj/argo/pull/2500/files#diff-4ed679a69dc8fdd934fb1e7f7c0f3259R109-R139 If you think it's necessary, I can invest the time into mocking this or creating an e2e test |
||
output = param.ValueFrom.Default | ||
} else { | ||
return err | ||
} | ||
} | ||
output = string(out) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -308,10 +308,15 @@ func (we *WorkflowExecutor) SaveResourceParameters(resourceNamespace string, res | |
log.Info(cmd.Args) | ||
out, err := cmd.Output() | ||
if err != nil { | ||
if exErr, ok := err.(*exec.ExitError); ok { | ||
log.Errorf("`%s` stderr:\n%s", cmd.Args, string(exErr.Stderr)) | ||
// We have a default value to use instead of returning an error | ||
if param.ValueFrom.Default != "" { | ||
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. test? 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. I didn't include tests for this because it would be difficult to mock this behavior and I have already included a non-E2E test that covers the same behavior here: https://github.com/argoproj/argo/pull/2500/files#diff-4ed679a69dc8fdd934fb1e7f7c0f3259R109-R139 If you think it's necessary, I can invest the time into mocking this or creating an e2e test |
||
out = []byte(param.ValueFrom.Default) | ||
} else { | ||
if exErr, ok := err.(*exec.ExitError); ok { | ||
log.Errorf("`%s` stderr:\n%s", cmd.Args, string(exErr.Stderr)) | ||
} | ||
return errors.InternalWrapError(err) | ||
} | ||
return errors.InternalWrapError(err) | ||
} | ||
output := string(out) | ||
we.Template.Outputs.Parameters[i].Value = &output | ||
|
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.
test?
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.
I've added an E2E test for this.