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.
This PR proposes an alternative approach to the Any Variables experiment which is fully compatible with Task v3 (Unlike the original proposal). Instead of removing the
sh
key and allowing native maps variables, we keep thesh
key for dynamic variables and create a new key:map
for specifying a map value. All other variable types (scalars & array) will be defined directly.Keeping these subkeys lets us do some other fancy things too. For example, I've added the
json
andyaml
keys which let you specify a JSON/YAML string to be converted to an object/array. This to similar to{{fromJson}}
, but with the key difference that templating functions must always return a string whereas thejson
/yaml
keys allow you to store the variable as a object/array type.I've also added a
ref
subkey which adds support for passing a variable around and maintaining its type as opposed to passing it via the templating engine (which always results in a string). I think this is really important if we're going to support any type of variable as otherwise we will get so many issues asking how to pass types around.I've thoroughly documented all of this functionality in more detail in the changes to the docs included in this PR. If reviewing, I think it's worth spinning them up locally with
task docs:start
and taking a look at the Any Variables page.To enable this alternative experiment functionality, you can run set the
TASK_X_ANY_VARIABLES
flag to a value of2
. e.g.TASK_X_ANY_VARIABLES=2 go run ./cmd/task --dir ./testdata/vars/any2
.In addition to the above changes, this PR also includes:
silent
values were not deep copied in dependencies