Meta-variables: variables pre-populated with component/application metadata
how can I read the current wasm component or application metadata?
for example, to display the version?
are application variables meant to be used for this? if so, is there some template syntax to get the application version, etc?
PS this is somewhat related to https://github.com/fermyon/spin/issues/1738.
Variables would certainly be the most appropriate way to accomplish this but there is no concept of "meta" variables that are prepopulated with certain information so for now you'd have to copy that information into a Spin.toml manifest's variables section.
I will change this issue to track the feature request for having meta variables.
It would be great to know what some use cases are for those so that it's clearer which variables would be useful to include by default.
Got it. Thank you! For now, I think I will shortcut this, and just include this in a separate source file before compiling the app.
Only have two use-cases, mainly for troubleshoot purposes:
- Get the application information (e.g. its version) at runtime, so I can have it somewhere available to show in the UI/API/logs.
- Get the host information (e.g. the name of the runtime and its version).
I've just found out about https://github.com/bytecodealliance/wasm-tools, which contains this nugget:
wasm-tools metadata showwasm-metadata Show name and producer metadata in a component or module
It seems to be the metadata that I'm looking for. Is there a way to set it and access it from the spin sdk?