readme-generator-for-helm
readme-generator-for-helm copied to clipboard
nullable does not allow null as a value
Using a paramater like:
config:
site:
## @param config.site.version [string,nullable] Version of config archive
##
version: null
gives a schema definition of:
"version": {
"type": "string",
"description": "Only valid with source: Nexus. Version of config archive",
"default": "null",
"nullable": true
},
which doesn't allow for actual null values.
config.site.version: Invalid type. Expected: string, given: null
if I manually change the schema to:
"version": {
"type": ["string", "null"],
"description": "Only valid with source: Nexus. Version of config archive",
"default": "null",
"nullable": true
},
then it seems to work correctly
workaround I'm using for anyone experiencing similar:
cat <<< $(jq '(..|objects|select(.nullable)).type |= ["string","null"]' values.schema.json) > values.schema.json
Hi @chasain ,
thanks for reporting it. It looks like you are right, it should be null
not "null"
@chasain can you take a look at the referenced PR? It fixes the reported issue
doesn't look like it, I now have the schema of
"config": {
"type": "string",
"description": "Only valid with source: Nexus. Name of config archive",
"default": null,
"nullable": true
},
but I still get
- config.site.config: Invalid type. Expected: string, given: null
I was only able to get rid of it by changing type to
"type": ["string", "null"],
Could you provide more information on where do you get the error:
- config.site.config: Invalid type. Expected: string, given: null
?
Just tested the latest version to see if this fixed my issue but it unfortunately has not. I'm running the command
readme-generator -r README.md -v values.yaml -s values.schema.json
then testing the schema with a helm template .
command and that fails with the given error until I change the type to ["string", "null"]
My helm version is version.BuildInfo{Version:"v3.7.0", GitCommit:"eeac83883cb4014fe60267ec6373570374ce770b", GitTreeState:"clean", GoVersion:"go1.16.8"}
@chasain I am able to get this error:
Error: values don't meet the specifications of the schema(s) in the following chart(s):
rabbitmq:
has a primitive type that is NOT VALID -- given: // Expected valid values are:[array boolean integer number null object string]
But it does not show the parameter that is failing, how did you figure out that?
Hmm, odd that's a pretty different error than I get, mine just looks like this:
helm template .
Error: values don't meet the specifications of the schema(s) in the following chart(s):
chart-name:
- config.model.hostname: Invalid type. Expected: string, given: null
- config.model.bucketURL: Invalid type. Expected: string, given: null
- config.model.prefix: Invalid type. Expected: string, given: null
- config.model.config: Invalid type. Expected: string, given: null
- config.model.version: Invalid type. Expected: string, given: null
- config.model.fileOrDirectory: Invalid type. Expected: string, given: null
for a values file like
config:
model:
## @param config.model.source Location to pull configs from, valid values are Disk/Nexus/Bucket
##
source: Disk
## @param config.model.config [string,nullable] Only valid with source: Nexus. Name of config archive
##
config: null
## @param config.model.version [string,nullable] Only valid with source: Nexus. Version of config archive
##
version: null
## @param config.model.prefix [string,nullable] Only valid with source: Nexus/Bucket. A path to strip from the config directory
##
prefix: null
## @param config.model.mountPath Path to mount the config directory inside the containers
##
mountPath: /app/model
## @param config.model.hostname [string,nullable] Only valid with source: Nexus/Bucket. The hostname in the configs archive, stripped from the config directory
##
hostname: null
## @param config.model.bucketURL [string,nullable] Only valid with source: Bucket. The gsutil URL of the bucket to pull
##
bucketURL: null
## @param config.model.fileOrDirectory [string,nullable] Only valid with source: Bucket, default Directory, valid values Directory/File.
## Determines whether gsutil uses cp or rsync, type File will not sync changes to the source file and should be avoided.
##
fileOrDirectory: null
## @param config.model.hostPath [string,nullable] Only valid with source: Disk. The location on disk to mount from, can include .repository.path
##
mmm looks like the schema generated is correct. I just found that there is a difference between OpenAPI version 3.0 and 3.1 here. Does it work if you specify it on the 3.1 format?
Ok, look like helm is using this library which is pinned to Draft 07 of jsonschema.org and doesn't support OpenAPI's version of the schema. If I manually edit the schema to the 3.1 format as specified in that stackoverflow article it does work, ie.
"config": {
"type": "object",
"properties": {
"site": {
"type": "object",
"properties": {
"source": {
"type": "string",
"description": "Location to pull configs from, valid values are Disk/Nexus/Bucket",
"default": "Disk"
},
"config": {
"type": [
"string",
"null"
],
"description": "Only valid with source: Nexus. Name of config archive",
"default": null,
"nullable": true
},
"version": {
"type": [
"string",
"null"
],
"description": "Only valid with source: Nexus. Version of config archive",
"default": null,
"nullable": true
},
...
you can test the fix yourself with the workaround I commented earlier
cat <<< $(jq '(..|objects|select(.nullable)).type |= ["string","null"]' values.schema.json) > values.schema.json
Thank you very much for the confirmation. I will create a task to fix this.