-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SEMVER-MAJOR] condition support to module params (#350)
* [SEMVER-MAJOR] condition support to module params changes includes - removing global config - module config’s parameter to support condition - module config’s parameter to support custom typed prompts - prompts to not return value, instead update map(can support multi-value) * remove credentials * dynamically populate from struct * allow overwriting the env-var while apply * add comments to public functions * address comments * project definition * Update docs/module-definition.md Co-authored-by: Bill Monkman <bmonkman@gmail.com> * Update docs/project-definition.md Co-authored-by: Bill Monkman <bmonkman@gmail.com> * better error message to users * explain template parameters * condition clarification between module and param Co-authored-by: Bill Monkman <bmonkman@gmail.com>
- Loading branch information
1 parent
7c3a230
commit 7f4c7a3
Showing
24 changed files
with
643 additions
and
622 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
## Module Definition: `zero-module.yml` | ||
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`). | ||
It also declares the module's dependencies to determine the order of execution in relation to other modules. | ||
|
||
| Parameters | type | Description | | ||
|---------------|-----------------|--------------------------------------------------| | ||
| `name` | string | Name of module | | ||
| `description` | string | Description of the module | | ||
| `template` | template | default settings for templating out the module | | ||
| `author` | string | Author of the module | | ||
| `icon` | string | Path to logo image | | ||
| `parameters` | list(Parameter) | Parameters to prompt users | | ||
|
||
|
||
### Template | ||
| Parameters | Type | Description | | ||
|--------------|---------|-----------------------------------------------------------------------| | ||
| `strictMode` | boolean | whether strict mode is enabled | | ||
| `delimiters` | tuple | A tuple of open delimiter and ending delimiter eg: `<%` and `%>` | | ||
| `inputDir` | string | Folder to template from the module, becomes the module root for users | | ||
| `outputDir` | string | local directory name for the module, gets commited to version control | | ||
|
||
### Condition(module) | ||
Module conditions are considered during template phase (`zero create`), based on parameters supplied from project-definition, | ||
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. | ||
|
||
| Parameters | Type | Description | | ||
|--------------|--------------|-------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| `action` | enum(string) | type of condition, currently supports [`ignoreFile`] | | ||
| `matchField` | string | Allows you to condition prompt based on another parameter's value | | ||
| `WhenValue` | string | Matches for this value to satisfy the condition | | ||
| `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 | | ||
|
||
### Parameter: | ||
Parameter defines the prompt during zero-init. | ||
There are multiple ways of obtaining the value for each parameter. | ||
Parameters may have `Conditions` and must be fulfilled when supplied, otherwise it skips the field entirely. | ||
|
||
The precedence for different types of parameter prompts are as follow. | ||
1. Execute | ||
2. type: specific ways of obtaining values (in AWS credential case it will set 2 values to the map) | ||
3. value: directly assigns a value to a parameter | ||
4. prompt: requires users to select an option OR input a string | ||
Note: Default is supplied as the starting point of the user's manual input (Not when value passed in is empty) | ||
|
||
| Parameters | Type | Description | | ||
|-----------------------|-----------------|---------------------------------------------------------------------------------------------------------------------------| | ||
| `field` | string | key to store result for project definition | | ||
| `label` | string | displayed name for the prompt | | ||
| `options` | list(string) | A list of values for users to pick from | | ||
| `default` | string | Defaults to this value during prompt | | ||
| `value` | string | Skips prompt entirely when set | | ||
| `info` | string | Displays during prompt as extra information guiding user's input | | ||
| `fieldValidation` | Validation | Validations for the prompt value | | ||
| `type` | enum(string) | Built in custom prompts: currently supports [`AWSProfilePicker`] | | ||
| `execute` | string | executes commands and takes stdout as prompt result | | ||
| `omitFromProjectFile` | bool | Field is skipped from adding to project definition | | ||
| `conditions` | list(Condition) | Conditions for prompt to run, if supplied all conditions must pass | | ||
| `envVarName` | string | During `zero apply` parameters are available as env-vars, defaults to field name but can be overwritten with `envVarName` | | ||
|
||
### Condition(paramters) | ||
Parameters conditions are considered while running user prompts, prompts are | ||
executed in order of the yml, and will be skipped if conditions are not satisfied. | ||
For example if a user decide to not use circleCI, condition can be used to skip the circleCI_api_key prompt. | ||
|
||
| Parameters | Type | Description | | ||
|--------------|--------------|-------------------------------------------------------------------| | ||
| `action` | enum(string) | type of condition, currently supports [`KeyMatchCondition`] | | ||
| `matchField` | string | Allows you to condition prompt based on another parameter's value | | ||
| `WhenValue` | string | Matches for this value to satisfy the condition | | ||
| `data` | list(string) | Supply extra data for condition to run | | ||
|
||
### Validation | ||
|
||
| Parameters | type | Description | | ||
|----------------|--------------|-------------------------------------| | ||
| `type` | enum(string) | Currently supports [`regex`] | | ||
| `value` | string | Regular expression string | | ||
| `errorMessage` | string | Error message when validation fails | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
### Project Definition: `zero-project.yml` | ||
Each project is defined by this file. This manifest reflects all the options a user chose during the `zero init` step. It defines which modules are part of the project, each of their parameters, and is the source of truth for the templating (`zero create`) and provision (`zero apply`) steps. | ||
|
||
_Note: This file contains credentials, so make sure it is not shared with others._ | ||
|
||
| Parameters | Type | Description | | ||
|--------------------------|--------------|------------------------------------------------| | ||
| `name` | string | name of the project | | ||
| `shouldPushRepositories` | boolean | whether to push the modules to version control | | ||
| `modules` | map(modules) | a map containing modules of your project | | ||
|
||
|
||
### Modules | ||
| Parameters | Type | Description | | ||
|--------------|-----------------|-------------------------------------------------------------------------| | ||
| `parameters` | map(string) | key-value map of all the parameters to run the module | | ||
| `files` | File | Stores information such as source-module location and destination | | ||
| `dependsOn` | list(string) | a list of dependencies that should be fulfilled before this module | | ||
| `conditions` | list(condition) | conditions to apply while templating out the module based on parameters | | ||
|
||
### Condition | ||
| Parameters | Type | Description | | ||
|--------------|--------------|-------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| `action` | enum(string) | type of condition, currently supports [`ignoreFile`] | | ||
| `matchField` | string | Allows you to condition prompt based on another parameter's value | | ||
| `WhenValue` | string | Matches for this value to satisfy the condition | | ||
| `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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.