-
Notifications
You must be signed in to change notification settings - Fork 53
[SEMVER-MAJOR] condition support to module params #350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
baebfcf
[SEMVER-MAJOR] condition support to module params
davidcheung 57917de
remove credentials
davidcheung cd0fd51
dynamically populate from struct
davidcheung 7713479
allow overwriting the env-var while apply
davidcheung f4073e4
add comments to public functions
davidcheung 5bdb4d2
fixup! add comments to public functions
davidcheung 8c0fc81
fixup! fixup! add comments to public functions
davidcheung a11fbca
fixup! fixup! fixup! add comments to public functions
davidcheung fec369d
fixup! fixup! fixup! fixup! add comments to public functions
davidcheung 1c62c0c
address comments
davidcheung a09474f
fixup! address comments
davidcheung 272f642
fixup! fixup! address comments
davidcheung 2d61408
project definition
davidcheung 28f807b
Update docs/module-definition.md
davidcheung b6c2fac
Update docs/project-definition.md
davidcheung c3b7b6f
better error message to users
davidcheung 89dbe41
explain template parameters
davidcheung 082bbe9
condition clarification between module and param
davidcheung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing info on some of the other things like the
contitionsandtemplatefields related to templating.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
definitely good call to add this documentation, I looked at conditions and thought oh its there, but theres actually 2 types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah the naming might be a bit confusing..