Skip to content

Commit c9c4521

Browse files
committed
feature(boolean): Add boolean modifier
Signed-off-by: Fran Mulero <[email protected]>
1 parent f97d8f6 commit c9c4521

16 files changed

+32
-31
lines changed

README.md

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -118,39 +118,10 @@ Currently supported modifiers:
118118
- `[array]` Indicates that the value of the parameter must be set to `[]`.
119119
- `[object]` Indicates that the value of the parameter must be set to `{}`.
120120
- `[string]` Indicates that the value of the parameter must be set to `""`.
121+
- `[boolean]` Indicates that the value of the parameter must be set to `false`.
121122
- `[nullable]` Indicates that the parameter value can be set to `null`.
122123
- `[default: DEFAULT_VALUE]` Sets the default value to `DEFAULT_VALUE`.
123124

124-
The modifiers are also customizable via the [configuration file](#configuration-file).
125-
126-
In case you are adding a `custom modifier` to a parameter that does not have value in the values file
127-
you must add one of the `supported modifiers` as last modifier.
128-
129-
Example:
130-
131-
Values file
132-
133-
```yaml
134-
# @param noDefaultValue [number, nullable] Description
135-
# noDefaultValue: 1
136-
```
137-
138-
Custom configuration snippet:
139-
140-
```json
141-
{
142-
...
143-
"modifiers": {
144-
"array": "array",
145-
"object": "object"
146-
"string": "string"
147-
"nullable": "nullable",
148-
"number": "number"
149-
},
150-
...
151-
}
152-
```
153-
154125
## Configuration file
155126

156127
The configuration file has the following structure:
@@ -172,6 +143,7 @@ The configuration file has the following structure:
172143
"array": "array", <-- Modifier that indicates an array type
173144
"object": "object" <-- Modifier that indicates an object type
174145
"string": "string" <-- Modifier that indicates a string type
146+
"boolean": "boolean" <-- Modifier that indicates a boolean type
175147
"nullable": "nullable" <-- Modifier that indicates a parameter that can be set to null
176148
},
177149
"regexp": {

config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"array": "array",
1515
"object": "object",
1616
"string": "string",
17+
"boolean": "boolean",
1718
"nullable": "nullable",
1819
"default": "default"
1920
},

lib/builder.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ function applyModifiers(param, config) {
3939
param.value = '""';
4040
}
4141
break;
42+
case `${config.modifiers.boolean}`:
43+
param.type = modifier;
44+
// Default value is false
45+
param.value = false;
46+
break;
4247
case `${config.modifiers.nullable}`:
4348
if (param.value === undefined) {
4449
param.value = 'nil';

tests/expected-readme.config.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ This description starts in a new line instead of the same line of description st
199199
| `vault.annotations.vault.hashicorp.com/agent-inject` | Some desc | `true` |
200200
| `stack.mode` | way to deploy | `nil` |
201201
| `stack.version` | version of the stack | `8.10.3` |
202+
| `booleanValue` | A boolean value | `false` |
202203

203204
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
204205

tests/expected-readme.first-execution.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,4 @@ This description starts in a new line instead of the same line of description st
161161
| `vault.annotations.vault.hashicorp.com/agent-inject` | Some desc | `true` |
162162
| `stack.mode` | way to deploy | `nil` |
163163
| `stack.version` | version of the stack | `8.10.3` |
164+
| `booleanValue` | A boolean value | `false` |

tests/expected-readme.last-section-text-below.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ This description starts in a new line instead of the same line of description st
199199
| `vault.annotations.vault.hashicorp.com/agent-inject` | Some desc | `true` |
200200
| `stack.mode` | way to deploy | `nil` |
201201
| `stack.version` | version of the stack | `8.10.3` |
202+
| `booleanValue` | A boolean value | `false` |
202203

203204
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
204205

tests/expected-readme.last-section.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,4 @@ This description starts in a new line instead of the same line of description st
199199
| `vault.annotations.vault.hashicorp.com/agent-inject` | Some desc | `true` |
200200
| `stack.mode` | way to deploy | `nil` |
201201
| `stack.version` | version of the stack | `8.10.3` |
202+
| `booleanValue` | A boolean value | `false` |

tests/expected-readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ This description starts in a new line instead of the same line of description st
199199
| `vault.annotations.vault.hashicorp.com/agent-inject` | Some desc | `true` |
200200
| `stack.mode` | way to deploy | `nil` |
201201
| `stack.version` | version of the stack | `8.10.3` |
202+
| `booleanValue` | A boolean value | `false` |
202203

203204
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
204205

tests/expected-schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,11 @@
731731
"default": "8.10.3"
732732
}
733733
}
734+
},
735+
"booleanValue": {
736+
"type": "boolean",
737+
"description": "A boolean value",
738+
"default": false
734739
}
735740
}
736741
}

tests/test-config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"array": "array",
1515
"object": "object",
1616
"string": "string",
17+
"boolean": "boolean",
1718
"nullable": "nullable",
1819
"default": "default"
1920
},

0 commit comments

Comments
 (0)