You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Move variable definitions from components to packages (zarf-dev#621)
* WIP update schema and examples to match vision
* Update schema to explicitly dissallow ###ZARF_VAR_ in default variable
* Set default variables on package create
* Create an initial pass at the --set flag
* Make package create test more robust
* Do not replace values when the default key is not present and --set is not used
* Cleanup package create test
* WIP start on deploy templating
* Create the weird one
* Mostly working now (needs more testing and stuff)
* Flesh out the variable test example
* Add more layers to more fully test variables
* Remove image from configmap
* Refactor to reduce complexity (i'm addicted pls help)
* Remove xtra comments
* Grammer fixes
* Add validation for variables on package create
* Add prompting to the deploy stage
* Update CLI docs with --set option
* Update Zarf schema
* Remove time from Zarf schema autogen
* Jeff breaking everything (though to be fair I reviewed his commit)
* Fixup feedback (rando example and debug message)
* Add --set to prepare find-images
* Remove inspect variables load (unnecessary)
* Address a TODO in a test
* Catch error from survey.AskOne()
* Update to new package variable/constant specification
* Fix and test for some potentially bad bugs
* Remove todo from SetActiveVariables
* Fix import path schema
* Small fixes to verbiage
* put a better comment in the package variable example
* Make Jeff's changes real
* Move variables logic into its own file
* Refactor SetActiveVariables to be better and include regex link for import path
* Fixing error around taking the default
* Update default to remove and add adr
* Spelling mistakes and comments
* Fix default on confirm check
Co-authored-by: Jonathan Perry <YrrepNoj@gmail.com>
Co-authored-by: Megamind <882485+jeff-mccoy@users.noreply.github.com>
Currently, Zarf only allows variables to be specified within components which introduces the following limitations:
12
+
13
+
- Variables are scoped to the component making reuse between components impossible
14
+
- Variables cannot be used for elements within the package definition itself
15
+
- Variables can only be set at create time, not by a user at deploy time
16
+
17
+
This forces a package creator to copy information within their package/component definitions and also requires them to make bespoke packages per environment even if only small changes are needed to the overall spec (such as changing a domain name).
18
+
19
+
## Decision
20
+
21
+
The decision was made to move variable definitions to the package level and to split "variables" into three distinct types:
22
+
23
+
- Variables (specified with the `variables` yaml key) allow for the templating of component files similar to the component variables before them. The main changes are that they are now specified at the package level (allowing for reuse between components) and have additional prompting and defaulting features to allow a package creator to ask for more information during `zarf package deploy`.
24
+
- Constants (specified with the `constants` yaml key) also template component files, but must be specified at package create time. This allows a package creator to use the same value in multiple places without the need for copying it and without the package deployer being able to override it.
25
+
- Package Variables (specified by using `###ZARF_PKG_VAR_*###` in the package definition) allow package creators to template the same information multiple times within the package definition or dynamically specify values or defaults in constants and variables.
26
+
27
+
## Consequences
28
+
29
+
This makes it easier to build a single package that will apply to multiple environments and helps package creators to develop automation around their packages while keeping their package definitions DRY. Choosing to have constants *and* variables also allows us to reduce potential confusion from package deployers who would otherwise be able to accidentally override values that are meant to be static.
30
+
31
+
As for drawbacks, the largest one is that this provides the potential for a user to build imperative packages depending on what they template or are allowed to template. This will need to be considered carefully in the future. The current implementation also ties us to only templating string values for the time being and we will have to think through what should be technically variablizable in the future (for example variables cannot be used in component import paths because this would introduce a lot of fragility for not much perceived user benefit).
Copy file name to clipboardexpand all lines: docs/4-user-guide/1-the-zarf-cli/100-cli-commands/zarf_connect.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ Uses a k8s port-forward to connect to resources within the cluster referenced by
8
8
Three default options for this command are <REGISTRY|LOGGING|GIT>. These will connect to the Zarf created resources (assuming they were selected when performing the `zarf init` command).
9
9
10
10
Packages can provide service manifests that define their own shortcut connection options. These options will be printed to the terminal when the package finishes deploying.
11
-
If you don't remember what connection shortcuts your deployed package offers, you can search your cluster for services that have the 'zarf.dev/connect-name' label. The value of that label is the name you will pass into the 'zarf connect' command.
11
+
If you don't remember what connection shortcuts your deployed package offers, you can search your cluster for services that have the 'zarf.dev/connect-name' label. The value of that label is the name you will pass into the 'zarf connect' command.
12
12
13
13
Even if the packages you deploy don't define their own shortcut connection options, you can use the command flags to connect into specific resources. You can read the command flag descriptions below to get a better idea how to connect to whatever resource you are trying to connect to.
Copy file name to clipboardexpand all lines: docs/4-user-guide/1-the-zarf-cli/100-cli-commands/zarf_init.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ Prepares a k8s cluster for the deployment of Zarf packages
4
4
5
5
### Synopsis
6
6
7
-
Injects a docker registry as well as other optional useful things (such as a git server and a logging stack) into a k8s cluster under the 'zarf' namespace to support future application deployments.
7
+
Injects a docker registry as well as other optional useful things (such as a git server and a logging stack) into a k8s cluster under the 'zarf' namespace to support future application deployments.
8
8
If you do not have a k8s cluster already configured, this command will give you the ability to install a cluster locally.
9
9
10
10
This command looks for a zarf-init package in the local directory that the command was executed from. If no package is found in the local directory and the Zarf CLI exists somewhere outside of the current directory, Zarf will failover and attempt to find a zarf-init package in the directory that the Zarf binary is located in.
@@ -38,4 +38,4 @@ zarf init [flags]
38
38
39
39
*[zarf](zarf.md) - DevSecOps Airgap Toolkit
40
40
41
-
###### Auto generated by spf13/cobra on 17-Jul-2022
41
+
###### Auto generated by spf13/cobra on 25-Jul-2022
Copy file name to clipboardexpand all lines: docs/4-user-guide/1-the-zarf-cli/100-cli-commands/zarf_prepare.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -20,8 +20,8 @@ Tools to help prepare assets for packaging
20
20
21
21
*[zarf](zarf.md) - DevSecOps Airgap Toolkit
22
22
*[zarf prepare find-images](zarf_prepare_find-images.md) - Evaluates components in a zarf file to identify images specified in their helm charts and manifests
23
-
*[zarf prepare patch-git](zarf_prepare_patch-git.md) - Converts all .git URLs to the specified Zarf HOST and with the Zarf URL pattern in a given FILE. NOTE:
23
+
*[zarf prepare patch-git](zarf_prepare_patch-git.md) - Converts all .git URLs to the specified Zarf HOST and with the Zarf URL pattern in a given FILE. NOTE:
24
24
This should only be used for manifests that are not mutated by the Zarf Agent Mutating Webhook.
25
25
*[zarf prepare sha256sum](zarf_prepare_sha256sum.md) - Generate a SHA256SUM for the given file
26
26
27
-
###### Auto generated by spf13/cobra on 17-Jul-2022
27
+
###### Auto generated by spf13/cobra on 25-Jul-2022
0 commit comments