Bug 1605136 - allow empty string values for non-generated parameters#21371
Bug 1605136 - allow empty string values for non-generated parameters#21371openshift-merge-robot merged 3 commits intoopenshift:masterfrom
Conversation
| secret.Data[k] = []byte(v) | ||
| for _, param := range template.Parameters { | ||
| if param.Name == k && ((v == "" && param.Generate == "") || v != "") { | ||
| secret.Data[k] = []byte(v) |
There was a problem hiding this comment.
have you confirmed that setting emptystring here ultimately results in the default value for the parameter being used during instantiation?
There was a problem hiding this comment.
@bparees I was able to verify the following
- if the default values were left alone, it's passed along as-is
- if the default values were removed/deleted, the parameters were set to an empty value
- empty values for the generated parameters were indeed generated, where it did not before.
However, I had difficulty getting any of the provisions to successfully complete with the cluster that @spadgett was nice enough to let me test with.
I'll change this PR as WIP, until I can fully verify a successful provision.
There was a problem hiding this comment.
However, I had difficulty getting any of the provisions to successfully complete with the cluster that @spadgett was nice enough to let me test with.
I'll change this PR as WIP, until I can fully verify a successful provision.
It looks like react-jsonschema-form leaves out string values that are cleared by the user. The empty string isn't treated as an error for required properties in JSON schema, so they switched to undefined.
rjsf-team/react-jsonschema-form#442
I'll have to look at how to handle this from the client.
There was a problem hiding this comment.
if the default values were removed/deleted, the parameters were set to an empty value
Just to clarify, if the parameter is missing entirely from the request, we'd still want to use the default value. We'd only want this behavior if it's explicitly set to "" (i.e., the user explicitly cleared the value in the web console form)
@bparees Does that make sense to you?
There was a problem hiding this comment.
@johnkim76 can you please add unit test to exercise this?
|
@johnkim76 Can you give this PR a shot? |
|
@spadgett Thank you!. that console PR seems to work! I did a quick test on my own v3.9.49 cluster Tand the provision was successful. I'll do more testing later today and remove the WIP. |
| } | ||
|
|
||
| // allow empty string values for non-generated parameters. | ||
| // empty string values will be ignored for generated parameter/ |
| for k, v := range preq.Parameters { | ||
| secret.Data[k] = []byte(v) | ||
| for _, param := range template.Parameters { | ||
| if param.Name == k && ((v == "" && param.Generate == "") || v != "") { |
There was a problem hiding this comment.
style: we generally use len(s) == 0 to check for an empty string
|
Before merging this, can you please add unit test that exercise this behavior? Other than small nits, this looks good to me. |
|
@mfojtik I've made the updates as requested |
|
/retest |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: johnkim76, mfojtik The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/test cmd |
|
/test e2e-aws |
|
/test e2e-gcp |
|
/test e2e-aws |
2 similar comments
|
/test e2e-aws |
|
/test e2e-aws |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
1 similar comment
|
/retest Please review the full test history for this PR and help us cut down flakes. |
Fixes BZ1605136
Requires UI changes in the origin-web-catalog as discussed in BZ comment here