Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions pkg/cmd/cli/cmd/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,16 +302,17 @@ func RunProcess(f *clientcmd.Factory, out io.Writer, cmd *cobra.Command, args []
func injectUserVars(values []string, t *templateapi.Template) []error {
var errors []error
for _, keypair := range values {
p := strings.Split(keypair, "=")
p := strings.SplitN(keypair, "=", 2)
if len(p) != 2 {
errors = append(errors, fmt.Errorf("invalid parameter assignment in %q: %q\n", t.Name, keypair))
}
if v := template.GetParameterByName(t, p[0]); v != nil {
v.Value = p[1]
v.Generate = ""
template.AddParameter(t, *v)
} else {
errors = append(errors, fmt.Errorf("unknown parameter name %q\n", p[0]))
if v := template.GetParameterByName(t, p[0]); v != nil {
v.Value = p[1]
v.Generate = ""
template.AddParameter(t, *v)
} else {
errors = append(errors, fmt.Errorf("unknown parameter name %q\n", p[0]))
}
}
}
return errors
Expand Down
6 changes: 4 additions & 2 deletions test/cmd/process.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@ os::cmd::expect_failure_and_text "oc process -f '${OS_ROOT}/test/testdata/basic-

# not providing required parameter should fail
os::cmd::expect_failure_and_text "oc process -f '${required_params}'" 'parameter required_param is required and must be specified'
# not providiing an optional param is OK
# not providing an optional param is OK
os::cmd::expect_success "oc process -f '${required_params}' --value=required_param=someval | oc create -f -"
# parameters with multiple equal signs are OK
os::cmd::expect_success "oc process -f '${required_params}' required_param=someval=moreval | oc create -f -"
# we should have overwritten the template param
os::cmd::expect_success_and_text 'oc get user someval -o jsonpath={.Name}' 'someval'
# providing a value not in the template should fail
os::cmd::expect_failure_and_text "oc process -f '${required_params}' --value=required_param=someval --value=other_param=otherval" 'unknown parameter name "other_param"'
# failure on values fails the entire call
os::cmd::expect_failure_and_text "oc process -f '${required_params}' --value=required_param=someval --value=optional_param=some=series=of=values=" 'invalid parameter assignment in'
os::cmd::expect_failure_and_text "oc process -f '${required_params}' --value=required_param=someval --value=optional_param" 'invalid parameter assignment in'
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this test doing now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same thing it did before. ensuring that if you supply an invalid parameter arg, the whole call fails w/ the correct error message. it's just that now it's incorrect because there's no equal sign as part of the arg, instead of before when it was incorrect because there were multiple equals in the arg.

# failure on labels fails the entire call
os::cmd::expect_failure_and_text "oc process -f '${required_params}' --value=required_param=someval --labels======" 'error parsing labels'

Expand Down