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

Add parameter-file support #966

Merged
merged 4 commits into from
Aug 24, 2018
Merged

Conversation

vosmith
Copy link
Contributor

@vosmith vosmith commented Aug 23, 2018

For workflows that have many parameters, or cases where the workflows should be run with slightly different requirements, it can be useful to have a file containing parameters instead of submitting via the command line.

This commit adds support for the --parameter-file (-f) command line option to provide a new-line-delimited file of parameters. These parameters can still be overridden by the --parameter (-p) flags.

Comments in parameter files are also supported and denoted by a # character.

See #796 for more information

For workflows that have many parameters, or cases where the workflows should be run with slightly different requirements, it can be useful to have a file containing parameters instead of submitting via the command line.

This commit adds support for the `--parameter-file` (`-f`) command line option to provide a new-line-delimited file of parameters.  These parameters can still be overridden by the `--parameter` (`-p`) flags.

Comments in parameter files are also supported and denoted by a `#` character.

See argoproj#796 for more information
}
for i, line := range strings.Split(string(body), "\n") {
// Ignore comments
fileParam := strings.TrimSpace(strings.Split(line, "#")[0])
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would break lines like CASE_NUMBER="#12345"

@wookasz
Copy link

wookasz commented Aug 23, 2018

Thanks for taking this on. Have you considered making the parameter file yaml/json and using https://github.com/go-yaml/yaml.

I think this is more consistent with configuration in a kubernetes ecosystem and the package provides the parsing for you.

@vosmith
Copy link
Contributor Author

vosmith commented Aug 23, 2018

Thanks @wookasz for the quick review! I had thought about yaml, but I decided to start simple and see where it goes. I'll push a new commit with that support!

@vosmith
Copy link
Contributor Author

vosmith commented Aug 23, 2018

I updated the PR to use YAML/JSON as the format for the parameters file, which should naturally also take care of the comment parsing issue. The only caveat here is the files have to marshal into a map[string]string.

@jessesuen
Copy link
Member

Thanks for your contribution!

The only caveat here is the files have to marshal into a map[string]string.

One approach is that you can unmarshal to a map[string]interface{}, then when setting the value from the interface object, you use .Value = fmt.Sprintf("%v", itemVal)

@vosmith
Copy link
Contributor Author

vosmith commented Aug 23, 2018

Sounds good to me 👍

@jessesuen jessesuen merged commit 67792eb into argoproj:master Aug 24, 2018
@kivio
Copy link
Contributor

kivio commented Jan 24, 2019

Hi, where i can find documentation how to use it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants