bitnami / readme-generator-for-helm

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

Default values of object parameters #32

Closed philippwaller closed 2 years ago

philippwaller commented 2 years ago

I would like to display the default value of an object parameter but it is not transferred to the readme file. Enclosed you will find an example:

source

# values.yaml

## @section Container Configuration

## @param nodeSelector [object] Node labels for pod assignment
nodeSelector:
  node-role.kubernetes.io/control-plane: "true"

expected result

## Container Configuration

| Name                 | Description                        | Value                                            |
| -------------------- | ---------------------------------- | ------------------------------------------------ |
| `nodeSelector`       | Node labels for pod assignment     | `node-role.kubernetes.io/control-plane: "true"`  |

result

## Container Configuration

| Name                 | Description                        | Value    |
| -------------------- | ---------------------------------- | -------- |
| `nodeSelector`       | Node labels for pod assignment     | `{}`     |
miguelaeh commented 2 years ago

Hi @philippwaller , Remove the [object] modifier that you are applying. i.e:

- ## @param nodeSelector [object] Node labels for pod assignment
+ ## @param nodeSelector Node labels for pod assignment
philippwaller commented 2 years ago

Hey @miguelaeh, thanks for your response. By removing the modifier, the value is interpreted as a template object. This leads to the following error message:

INFO: Checking missing metadata...

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

ERROR: Missing metadata for key: nodeSelector.node-role.kubernetes.io/control-plane
ERROR: Metadata provided for non existing key: nodeSelector
/usr/local/lib/node_modules/readme-generator-for-helm/lib/checker.js:92
    throw new Error('ERROR: Wrong metadata!');
    ^

Error: ERROR: Wrong metadata!
    at checkKeys (/usr/local/lib/node_modules/readme-generator-for-helm/lib/checker.js:92:11)
    at getValuesSections (/usr/local/lib/node_modules/readme-generator-for-helm/index.js:23:3)
    at runReadmeGenerator (/usr/local/lib/node_modules/readme-generator-for-helm/index.js:45:20)
    at Object.<anonymous> (/usr/local/lib/node_modules/readme-generator-for-helm/bin/index.js:21:1)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)
    at internal/main/run_main_module.js:17:47
miguelaeh commented 2 years ago

Hi @philippwaller , Sorry, I did not notice the format you are trying to use there. The nodeSelectors, and also annotations, follow a format in the values that is not supported yet by the tool. That's the reason why the bitnami charts use the [object] modifier, to show it as an empty object instead.

The metadata is properly read from the values.yaml when you set the @param as testAnnotation.node-role.kubernetes.io/control-plane, but then the value is not correctly taken since the YAML library looks for something like:

testAnnotation:
  node:
    role:
      kubernetes:
        io:
 ....

We would need to add some kind of flag to indicate the special format when parsing the comments from the values.yaml in order to be able to read the value for those kind of elements.

miguelaeh commented 2 years ago

Hi, the annotations have been now supported, using the latest version of the tool you should be able to document annotations