feat: improved resource referencing and throw errors for invalid expressions #54
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 overhauls the placeholder referencing functionality and makes it more predictable and reliable in advance of a formal resource provisioning system.
So
${resources.unknown.nil}
now throw an error.All metadata keys and values are now available under
${metadata.<key>(.<key>)*}
. nested maps can be indexed by key, strings are output as is, all other types are encoded as json.So
${metadata.name}
->hello-world
. But${metadata.info.author}
might return{"email": "[email protected]"}
.The
environment.default
resource type is formalized so that${resources.env.foo}
is translated to${FOO}
.Keys are normalized, so
${resources.env.my-key}
will translate to${MY_KEY}
.Any other resource lookup falls back to the existing behavior of translating into a prefixed environment variable. eg:
${resources.db.foo}
->${DB_FOO}
. However now it does require that the resourcedb
was actually declared.So
${resources.something.key.key}
would fall back to${SOMETHING_KEY_KEY}
.In a future resource provisioning system, this behavior can be disabled or changed to opt-in.
volume.default resources are implemented as a static resource with no outputs - however the user must still provide the volume at this time. A future PR with resource provisioning will provide a default volume here.
Note that (3) will soon be replaced with a real resource provisioning system which will usually throw errors in this case unless the fallback behavior is opted-in.
Types of changes
Checklist: