spin icon indicating copy to clipboard operation
spin copied to clipboard

Provide the ability to import manifest and runtime-config as wasm modules (components)

Open mikkelhegn opened this issue 1 year ago • 10 comments

Instead of relying of toml for a Spin manifest and runtime config, in certain scenarios it would be great to be able to provide those as WASM modules (components), if e.g. you want to generate these programmatically.

mikkelhegn avatar May 23 '24 18:05 mikkelhegn

Could you provide more detail on use cases here? Doing something like this for the manifest would be an almost entirely separate feature from runtime config, and even for manifests there are at least two distinct places where we could do this generation depending on exact goals.

lann avatar May 24 '24 13:05 lann

I think this overlaps with some of what @tschneidereit has been thinking about with build-time customization.

lann avatar May 29 '24 14:05 lann

@tschneidereit / @lann is there a reference to

build-time customization

mikkelhegn avatar May 30 '24 09:05 mikkelhegn

Could you provide more detail on use cases here?

In the Aspire integration, @ThorstenHans has had to generate toml as part of the integration: https://github.com/fermyon/Aspire.Spin/blob/e1a676a5de27ba42b87da9d82254a15885449d97/Aspire.Hosting.Spin/RuntimeConfiguration/RuntimeConfiguration.cs#L22 - it would be nice if this could be easier for scenarios like this.

@ThorstenHans feel free to add more details.

mikkelhegn avatar May 30 '24 09:05 mikkelhegn

@mikkelhegn there isn't yet: I've been talking about this with a few people, but haven't written anything down so far, as it's not yet crystalized enough

tschneidereit avatar May 30 '24 12:05 tschneidereit

In the Aspire integration, @ThorstenHans has had to generate toml as part of the integration

If it helps, Spin also now accepts JSON for runtime config.

lann avatar May 30 '24 12:05 lann

In the Aspire integration, @ThorstenHans has had to generate toml as part of the integration

If it helps, Spin also now accepts JSON for runtime config.

Do we have a JSON schema somewhere?

ThorstenHans avatar May 30 '24 12:05 ThorstenHans

Do we have a JSON schema somewhere?

Nope. The schema is defined here (though honestly that isn't very useful if you aren't deeply familiar with surrounding code): https://github.com/fermyon/spin/blob/main/crates/trigger/src/runtime_config.rs#L198

Relevant parts should look like e.g.:

{
  "key_value_store": {
    "default": { "type": "redis", ... },
    "other": { "type": "azure_cosmos", ... }}
  },
  "sqlite_database": {
    "default": { "type": "spin", ... }
  },
  "llm_compute": { "type": "remote_http", ... }
}

(you should also be able to adapt any existing toml example with any toml-to-json converter like https://transform.tools/toml-to-json)

lann avatar May 30 '24 13:05 lann

I was asking for a schema because that would allow me to get nice auto completion when creating new runtime configuration files.

Thanks @lann

ThorstenHans avatar Jun 10 '24 07:06 ThorstenHans

I was asking for a schema because that would allow me to get nice auto completion when creating new runtime configuration files.

:+1: I'll keep this in mind for the Spin Factors project; I think there should be a nice way to generate JSON schema.

lann avatar Jun 10 '24 14:06 lann

@lann did this happen?

I'll keep this in mind for the Spin Factors project; I think there should be a nice way to generate JSON schema.

If it has been made simpler to programmatically provide runtime-config, I think we can close this issue.

mikkelhegn avatar Oct 20 '25 14:10 mikkelhegn

There has been no change here, though I also don't think we've had much feedback on runtime config in general.

lann avatar Oct 20 '25 15:10 lann

Agreed. I'll close this for now as I don't think there are any urgent use-cases I know of which will need this.

mikkelhegn avatar Oct 20 '25 15:10 mikkelhegn