Skip to content

Bug 1605136 - allow empty string values for non-generated parameters#21371

Merged
openshift-merge-robot merged 3 commits intoopenshift:masterfrom
johnkim76:BZ1605136
Dec 2, 2018
Merged

Bug 1605136 - allow empty string values for non-generated parameters#21371
openshift-merge-robot merged 3 commits intoopenshift:masterfrom
johnkim76:BZ1605136

Conversation

@johnkim76
Copy link
Copy Markdown

Fixes BZ1605136

  • allow empty string values to be set for non-generated parameters
  • ignores empty string values for generated parameters

Requires UI changes in the origin-web-catalog as discussed in BZ comment here

@openshift-ci-robot openshift-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Oct 27, 2018
secret.Data[k] = []byte(v)
for _, param := range template.Parameters {
if param.Name == k && ((v == "" && param.Generate == "") || v != "") {
secret.Data[k] = []byte(v)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

have you confirmed that setting emptystring here ultimately results in the default value for the parameter being used during instantiation?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yes

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@johnkim76 can you please add unit test to exercise this?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@mfojtik will do

@johnkim76 johnkim76 changed the title Bug 1605136 - allow empty string values for non-generated parameters [WIP] Bug 1605136 - allow empty string values for non-generated parameters Oct 27, 2018
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 27, 2018
@spadgett
Copy link
Copy Markdown
Member

@johnkim76 Can you give this PR a shot?

openshift/console#711

@johnkim76
Copy link
Copy Markdown
Author

@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.

@johnkim76 johnkim76 changed the title [WIP] Bug 1605136 - allow empty string values for non-generated parameters Bug 1605136 - allow empty string values for non-generated parameters Oct 29, 2018
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 29, 2018
}

// allow empty string values for non-generated parameters.
// empty string values will be ignored for generated parameter/
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: drop the trailing /

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

thank you, I will update

for k, v := range preq.Parameters {
secret.Data[k] = []byte(v)
for _, param := range template.Parameters {
if param.Name == k && ((v == "" && param.Generate == "") || v != "") {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

style: we generally use len(s) == 0 to check for an empty string

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

thank you, I'll fix

@mfojtik
Copy link
Copy Markdown
Contributor

mfojtik commented Oct 29, 2018

Before merging this, can you please add unit test that exercise this behavior? Other than small nits, this looks good to me.

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 5, 2018
@johnkim76
Copy link
Copy Markdown
Author

@mfojtik I've made the updates as requested

@johnkim76
Copy link
Copy Markdown
Author

/retest

@mfojtik
Copy link
Copy Markdown
Contributor

mfojtik commented Nov 28, 2018

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 28, 2018
@openshift-ci-robot
Copy link
Copy Markdown

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 28, 2018
@jmontleon
Copy link
Copy Markdown
Contributor

/test cmd

@jmontleon
Copy link
Copy Markdown
Contributor

/test e2e-aws

@jmontleon
Copy link
Copy Markdown
Contributor

/test e2e-gcp

@jmontleon
Copy link
Copy Markdown
Contributor

/test e2e-aws

2 similar comments
@jmontleon
Copy link
Copy Markdown
Contributor

/test e2e-aws

@johnkim76
Copy link
Copy Markdown
Author

/test e2e-aws

@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link
Copy Markdown
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit f049170 into openshift:master Dec 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants