spin icon indicating copy to clipboard operation
spin copied to clipboard

Meta-variables: variables pre-populated with component/application metadata

Open rgl opened this issue 1 year ago • 3 comments

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.

rgl avatar Jan 21 '24 17:01 rgl

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.

rylev avatar Jan 23 '24 09:01 rylev

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:

  1. Get the application information (e.g. its version) at runtime, so I can have it somewhere available to show in the UI/API/logs.
  2. Get the host information (e.g. the name of the runtime and its version).

rgl avatar Jan 23 '24 18:01 rgl

I've just found out about https://github.com/bytecodealliance/wasm-tools, which contains this nugget:

wasm-tools metadata show wasm-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?

rgl avatar Jan 27 '24 13:01 rgl