Skip to content
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

feat: improved resource referencing and throw errors for invalid expressions #54

Merged
merged 6 commits into from
Mar 5, 2024

Conversation

astromechza
Copy link
Member

@astromechza astromechza commented Mar 1, 2024

This PR overhauls the placeholder referencing functionality and makes it more predictable and reliable in advance of a formal resource provisioning system.

  1. ⚠️ Placeholder expressions that cannot be resolved now throw an error instead of returning empty string.

    So ${resources.unknown.nil} now throw an error.

  2. 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]"}.

  3. 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}.

  4. 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 resource db 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.

  5. 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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • New chore (expected functionality to be implemented)

Checklist:

  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
  • I've signed off with an email address that matches the commit author.

@astromechza astromechza changed the title feat: improved resource referencing and added useful volume resource … feat: improved resource referencing and added useful volume resource support Mar 1, 2024
@astromechza astromechza force-pushed the overhaul-resource-referencing branch from ddaa37a to 3d4b57c Compare March 1, 2024 18:44
@astromechza astromechza force-pushed the overhaul-resource-referencing branch from 3d4b57c to 9a49b73 Compare March 1, 2024 19:25
Signed-off-by: Ben Meier <[email protected]>
@astromechza astromechza force-pushed the overhaul-resource-referencing branch from 49b37fd to 98fcbde Compare March 1, 2024 19:49
@astromechza astromechza force-pushed the overhaul-resource-referencing branch from 98fcbde to 767a77e Compare March 1, 2024 19:52
@astromechza astromechza marked this pull request as ready for review March 1, 2024 19:53
@astromechza astromechza changed the title feat: improved resource referencing and added useful volume resource support feat: improved resource referencing and throw errors for invalid expressions Mar 1, 2024
@astromechza astromechza merged commit 8522fc1 into main Mar 5, 2024
5 checks passed
@astromechza astromechza deleted the overhaul-resource-referencing branch March 5, 2024 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants