bitnami / readme-generator-for-helm

Auto generate READMEs for Helm Charts
https://bitnami.com
Apache License 2.0
222 stars 48 forks source link

Adding modifier to some param in array item breaks metadata validation #11

Closed jacek-jablonski closed 3 years ago

jacek-jablonski commented 3 years ago

Hi,

it seems like adding modifier to array item key breaks metadata validation. Here is minimal example:

## @section Jobs definition

## Jobs definition
##
jobs:
  -
    ## @param jobs[0].nameOverride String to partially override jobs.names.fullname
    ##
    nameOverride: ""
    ## @param jobs[0].fullnameOverride String to fully override jobs.names.fullname
    ##
    fullnameOverride: ""
    ## @param jobs[0].resources.limits The resources limits override for the Job
    ##
    resources:
      limits: {}

Above works fine, but generates undefined for jobs[0].resources.limits:

### Jobs definition

| Name                       | Description                                      | Value       |
| -------------------------- | ------------------------------------------------ | ----------- |
| `jobs[0].nameOverride`     | String to partially override jobs.names.fullname | `""`        |
| `jobs[0].fullnameOverride` | String to fully override jobs.names.fullname     | `""`        |
| `jobs[0].resources.limits` | The resources limits override for the Job        | `undefined` |

So, lets annotate jobs[0].resources.limits with [object] modifier:

## @section Jobs definition

## Jobs definition
##
jobs:
  -
    ## @param jobs[0].nameOverride String to partially override jobs.names.fullname
    ##
    nameOverride: ""
    ## @param jobs[0].fullnameOverride String to fully override jobs.names.fullname
    ##
    fullnameOverride: ""
    ## @param jobs[0].resources.limits [object] The resources limits override for the Job
    ##
    resources:
      limits: {}

This however breaks metadata validation:

❯ npx readme-generator -v values2.yaml -r README.md
Skipping check for jobs[0].nameOverride
Skipping check for jobs[0].fullnameOverride
Skipping check for jobs[0].resources.limits
INFO: Checking missing metadata...

######
The following errors must be fixed before proceeding
######

ERROR: Metadata provided for non existing key: jobs[0].nameOverride
ERROR: Metadata provided for non existing key: jobs[0].fullnameOverride
ERROR: Metadata provided for non existing key: jobs[0].resources.limits
ERROR: Wrong metadata!

Generally I am trying to document quite a big and complicated array element. Is it a recommended way to do it with [0] in parameter's path or is there more generic way? Thanks.

miguelaeh commented 3 years ago

Hi @jacek-jablonski , sorry for the delay in the response, we were not tracking properly the issues for this repo.

Thank you very much for reporting this bug. You should not need to set the object modifier since the tool should be able to identify that is an object. I can see that for the other two elements of the object the empty string is properly identified. We have some errors for arrays yet, I was able to reproduce the error and will try to fix it. In the meanwhile, even it is not the real value and your metadata could be confusing you could set an array modifier to the full jobs object, but it will show you that field in the README as [].