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

How to define object parameters with complex validation #1459

Closed
cy-ddg opened this issue Feb 19, 2021 · 7 comments
Closed

How to define object parameters with complex validation #1459

cy-ddg opened this issue Feb 19, 2021 · 7 comments
Assignees
Labels
1 - 🍫 Eat chocolate _after_ emergency donuts bug Oops, sorry! cnab Related to the CNAB spec
Milestone

Comments

@cy-ddg
Copy link

cy-ddg commented Feb 19, 2021

I am trying to define parameters that use the full power of the available JSONSchema validations available in the CNAB spec, but so far I have only middling success.

The following parameter definition

parameters:
- name: values
  type: object
  properties:
    replicaCount:
      $id: '#/properties/replicaCount'
      type: integer

builds successfully but trying to set the parameter value on install like this

parameters:
- name: values
  source:
    value: '{"replicaCount": 3}'

results in this error on running the install command:

Error: invalid parameters: unable to convert parameter's values value {"replicaCount": 3} to the destination parameter type object: invalid definition

A parameter definition like

parameters:
- name: values
  type: object
  additionalProperties:
    type: string

does not even build and fails with the error:

Error: 1 error occurred:
	* encountered error while validating parameter values: unable to load schema: json: unsupported type: map[interface {}]interface {}

So my question is this: Am I doing something wrong or is this a limitation of the current implementation?

@cy-ddg cy-ddg added the question Halp plz label Feb 19, 2021
@vdice
Copy link
Member

vdice commented Feb 19, 2021

Thanks for bringing this to our attention @cy-ddg . Your approach above looks sound. This definitely appears to be a bug in Porter.

@vdice vdice added the bug Oops, sorry! label Feb 19, 2021
@carolynvs carolynvs added 1 - 🍫 Eat chocolate _after_ emergency donuts cnab Related to the CNAB spec and removed question Halp plz labels Feb 19, 2021
@carolynvs carolynvs added this to the 1.0 milestone Feb 19, 2021
@vdice vdice self-assigned this May 12, 2021
@vdice
Copy link
Member

vdice commented May 13, 2021

We can close this once the cnab-go fix (or similar) is integrated into Porter.

@vdice
Copy link
Member

vdice commented Jun 4, 2021

I can confirm that this issue is fixed as of ed52bc1 on the v1 branch.

@carolynvs
Copy link
Member

I am working on getting a build out of our v1 prerelease so that people can try this out. I'm going to close this issue since we have a fix merged, and will send out an announcement when I have a v1 build ready for people to try out.

Make sure to join our mailing list or slack to know when a build is ready to test.

@carolynvs
Copy link
Member

This has been fixed in the v1.0.0-alpha.2 prerelease. Please give it a try and let us know if you run into any problems!

@cy-ddg
Copy link
Author

cy-ddg commented Aug 24, 2021

The new version looks very good! The example above is working now. I've found one more problem though when trying to define an array parameter with a specific schema for the items:

parameters:
  - name: values
    type: array
    items:
      type: integer

This builds successfully but trying to install it with the following parameters:

{
  "parameters": [
    {
      "name": "values",
      "source": {
        "value": "[]"
      }
    }
  ]
}

I get the following error message:

Error: 1 error occurred:
	* encountered error while validating parameter values: unable to load schema: json: unsupported type: map[interface {}]interface {}


Error: 1 error occurred:
	* container exit code: 1, message: <nil>

But besides that it is working pretty well. Good job!

@carolynvs
Copy link
Member

@cy-ddg I've made a new issue to track the bug you reported. 👍

#1733

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 - 🍫 Eat chocolate _after_ emergency donuts bug Oops, sorry! cnab Related to the CNAB spec
Projects
None yet
Development

No branches or pull requests

3 participants