|
| 1 | +## Module Definition: `zero-module.yml` |
| 2 | +This file is the definition of a Zero module. It contains a list of all the required parameters to be able to prompt a user for choices during `zero init`, information about how to template the contents of the module during `zero create`, and the information needed for the module to run (`zero apply`). |
| 3 | +It also declares the module's dependencies to determine the order of execution in relation to other modules. |
| 4 | + |
| 5 | +| Parameters | type | Description | |
| 6 | +|---------------|-----------------|--------------------------------------------------| |
| 7 | +| `name` | string | Name of module | |
| 8 | +| `description` | string | Description of the module | |
| 9 | +| `template` | template | default settings for templating out the module | |
| 10 | +| `author` | string | Author of the module | |
| 11 | +| `icon` | string | Path to logo image | |
| 12 | +| `parameters` | list(Parameter) | Parameters to prompt users | |
| 13 | + |
| 14 | + |
| 15 | +### Template |
| 16 | +| Parameters | Type | Description | |
| 17 | +|--------------|---------|-----------------------------------------------------------------------| |
| 18 | +| `strictMode` | boolean | whether strict mode is enabled | |
| 19 | +| `delimiters` | tuple | A tuple of open delimiter and ending delimiter eg: `<%` and `%>` | |
| 20 | +| `inputDir` | string | Folder to template from the module, becomes the module root for users | |
| 21 | +| `outputDir` | string | local directory name for the module, gets commited to version control | |
| 22 | + |
| 23 | +### Condition(module) |
| 24 | +Module conditions are considered during template phase (`zero create`), based on parameters supplied from project-definition, |
| 25 | +modules can decide to have specific files ignored from the user's module. For example if user picks `userAuth: no`, we can ignore the auth resources via templating. |
| 26 | + |
| 27 | +| Parameters | Type | Description | |
| 28 | +|--------------|--------------|-------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 29 | +| `action` | enum(string) | type of condition, currently supports [`ignoreFile`] | |
| 30 | +| `matchField` | string | Allows you to condition prompt based on another parameter's value | |
| 31 | +| `WhenValue` | string | Matches for this value to satisfy the condition | |
| 32 | +| `data` | list(string) | Supply extra data for condition to run `ignoreFile`: provide list of paths (file or directory path) to omit from module when condition is satisfied | |
| 33 | + |
| 34 | +### Parameter: |
| 35 | +Parameter defines the prompt during zero-init. |
| 36 | +There are multiple ways of obtaining the value for each parameter. |
| 37 | +Parameters may have `Conditions` and must be fulfilled when supplied, otherwise it skips the field entirely. |
| 38 | + |
| 39 | +The precedence for different types of parameter prompts are as follow. |
| 40 | +1. Execute |
| 41 | +2. type: specific ways of obtaining values (in AWS credential case it will set 2 values to the map) |
| 42 | +3. value: directly assigns a value to a parameter |
| 43 | +4. prompt: requires users to select an option OR input a string |
| 44 | +Note: Default is supplied as the starting point of the user's manual input (Not when value passed in is empty) |
| 45 | + |
| 46 | +| Parameters | Type | Description | |
| 47 | +|-----------------------|-----------------|---------------------------------------------------------------------------------------------------------------------------| |
| 48 | +| `field` | string | key to store result for project definition | |
| 49 | +| `label` | string | displayed name for the prompt | |
| 50 | +| `options` | list(string) | A list of values for users to pick from | |
| 51 | +| `default` | string | Defaults to this value during prompt | |
| 52 | +| `value` | string | Skips prompt entirely when set | |
| 53 | +| `info` | string | Displays during prompt as extra information guiding user's input | |
| 54 | +| `fieldValidation` | Validation | Validations for the prompt value | |
| 55 | +| `type` | enum(string) | Built in custom prompts: currently supports [`AWSProfilePicker`] | |
| 56 | +| `execute` | string | executes commands and takes stdout as prompt result | |
| 57 | +| `omitFromProjectFile` | bool | Field is skipped from adding to project definition | |
| 58 | +| `conditions` | list(Condition) | Conditions for prompt to run, if supplied all conditions must pass | |
| 59 | +| `envVarName` | string | During `zero apply` parameters are available as env-vars, defaults to field name but can be overwritten with `envVarName` | |
| 60 | + |
| 61 | +### Condition(paramters) |
| 62 | +Parameters conditions are considered while running user prompts, prompts are |
| 63 | +executed in order of the yml, and will be skipped if conditions are not satisfied. |
| 64 | +For example if a user decide to not use circleCI, condition can be used to skip the circleCI_api_key prompt. |
| 65 | + |
| 66 | +| Parameters | Type | Description | |
| 67 | +|--------------|--------------|-------------------------------------------------------------------| |
| 68 | +| `action` | enum(string) | type of condition, currently supports [`KeyMatchCondition`] | |
| 69 | +| `matchField` | string | Allows you to condition prompt based on another parameter's value | |
| 70 | +| `WhenValue` | string | Matches for this value to satisfy the condition | |
| 71 | +| `data` | list(string) | Supply extra data for condition to run | |
| 72 | + |
| 73 | +### Validation |
| 74 | + |
| 75 | +| Parameters | type | Description | |
| 76 | +|----------------|--------------|-------------------------------------| |
| 77 | +| `type` | enum(string) | Currently supports [`regex`] | |
| 78 | +| `value` | string | Regular expression string | |
| 79 | +| `errorMessage` | string | Error message when validation fails | |
0 commit comments