add SIP - packaging components - #3697
Conversation
09abd4c to
2f54552
Compare
Signed-off-by: Michelle Dhanani <mdhanani@akamai.com>
2f54552 to
e4799de
Compare
itowlson
left a comment
There was a problem hiding this comment.
Good stuff, thanks for getting this under way!
| | `environments_variables` | Environment variables the component needs. Each entry is a bare name, or `{ name, default }`. | | ||
| | `files` | Files the component may read: a glob, or `{ source, destination }` mount. | | ||
|
|
||
| `[requires]` is descriptive: it documents what an application must provide when it |
There was a problem hiding this comment.
I like this emphasis. The component cannot grant itself the permissions because we can't trust it, but we need to know what it wants from us.
(no action, just wanted to applaud)
|
|
||
| ### Building a component | ||
|
|
||
| `spin build` recognizes a component manifest, runs its `[build].command`, and embeds |
There was a problem hiding this comment.
Recognises it by the manifest version declaration?
| pre-built). | ||
|
|
||
| Only `spin build` operates on component manifests. `spin up`, `spin deploy`, and | ||
| similar commands continue to require an application manifest, because a lone |
There was a problem hiding this comment.
PEDANTRY CORNER: spin up -f bare.wasm does work. (but your point is still right of course)
| only a `source`. A `watch` field (globs for `spin watch`) is intentionally *not* | ||
| included yet — `spin watch` does not operate on component manifests, so the field | ||
| would have no effect. It will be added together with `spin watch` support for | ||
| component manifests (see [Future work](#future-work)). |
There was a problem hiding this comment.
Correct to say a standalone component cannot have dependencies?
There was a problem hiding this comment.
For now at least. Not forever.
| ``` | ||
|
|
||
| - The version portion is a semver requirement; when omitted, the latest | ||
| non-yanked release is pulled. |
There was a problem hiding this comment.
I'm getting a bit confused across OCI and wkg at this point, sorry. The draft uses OCI terminology and references in some places, and wkg in others (which is what is mentioned in the preamble).
| - The version portion is a semver requirement; when omitted, the latest | ||
| non-yanked release is pulled. | ||
| - `--output` selects where the component Wasm is written; it defaults to | ||
| `<name>.wasm` in the current directory. |
There was a problem hiding this comment.
spin registry pull with applications puts them in the Spin cache I believe.
|
Great stuff @michelleN Although I am on the same page because it would streamline What about keeping everything in
I drafted a bit and ended up with something like this (not really different from the current approach, but adds more granular variable handling). # ...
[variables]
app_name = { default = "My Spin App" }
[[trigger.http]]
route = "/api/..."
component = "api"
[component.api]
source = "api/target/wasm32-wasip2/release/api.wasm"
allowed_outbound_hosts = []
key_value_stores = ["default"]
dependencies = ["cors", "correlation-id", "header-injection"]
[component.cors]
source = { path = "../cors/target/wasm32-wasip2/release/cors.wasm" }
[component.cors.variables]
allowed_methods = "POST,GET,PUT,DELETE"
allowed_origings = "*"
# allowed_headers is unset (component might have smart defaults)
[component.correlation-id]
source = { path = "../cors/target/wasm32-wasip2/release/cid.wasm"}
[component.correlation-id.variables]
header_name = "X-CORRELATION-ID"
[component.header-injection]
source = {path = "./components/hi/target/wasm32-wasip2/release/hi.wasm" }
[component.header-injection.build]
workdir = "./components/hi"
command = "cargo build --target wasm32-wasip2 --release"
[component.header-injection.variables]
header_name = "X-APP-NAME"
header_value = "{{ app_name }}" |
| ] | ||
| allowed_outbound_hosts = ["https://github.com", "https://api.github.com"] | ||
| key_value_stores = ["default"] | ||
| sql_variables = ["default"] |
There was a problem hiding this comment.
| sql_variables = ["default"] | |
| sqlite_databases = ["default"] |
| key_value_stores = ["default"] | ||
| sql_variables = ["default"] | ||
| ai_models = ["llama2-chat"] | ||
| environment_variables = ["staging", { name = "region", default = "us" }] |
There was a problem hiding this comment.
| environment_variables = ["staging", { name = "region", default = "us" }] | |
| environment = ["staging", { name = "region", default = "us" }] |
| | --- | --- | | ||
| | `variables` | Configuration variables the component consumes. Each entry is a bare name, or `{ name, default, secret }`. | | ||
| | `key_value_stores` | Key-value store labels the component accesses. | | ||
| | `sql_variables` | SQLite database labels the component accesses. | |
There was a problem hiding this comment.
| | `sql_variables` | SQLite database labels the component accesses. | | |
| | `sqlite_databases` | SQLite database labels the component accesses. | |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| | `sql_variables` | SQLite database labels the component accesses. | | ||
| | `ai_models` | AI models the component accesses. | | ||
| | `allowed_outbound_hosts` | Outbound network destinations the component is allowed to reach. | | ||
| | `environments_variables` | Environment variables the component needs. Each entry is a bare name, or `{ name, default }`. | |
There was a problem hiding this comment.
| | `environments_variables` | Environment variables the component needs. Each entry is a bare name, or `{ name, default }`. | | |
| | `environment` | Environment variables the component needs. Each entry is a bare name, or `{ name, default }`. | |
| #### `[requires]` — host capabilities (optional) | ||
|
|
||
| Declares the capabilities the component expects the host application to grant it. | ||
| These mirror the capability fields of a `spin.toml` component: |
There was a problem hiding this comment.
I maybe wouldn't say these mirror the capability fields in spin.toml -- it's likely, at least some of these, will diverge from the schema associated with the name used in spin.toml (e.g. environment is divergent).
| | `ai_models` | AI models the component accesses. | | ||
| | `allowed_outbound_hosts` | Outbound network destinations the component is allowed to reach. | | ||
| | `environments_variables` | Environment variables the component needs. Each entry is a bare name, or `{ name, default }`. | | ||
| | `files` | Files the component may read: a glob, or `{ source, destination }` mount. | |
There was a problem hiding this comment.
We should probably not allow glob patterns here; globs are relative to the consuming app's directory and the dependency component has no idea what's there. What the component actually knows is the guest path it expects to read so i'd consider restricting this to { destination }.
There was a problem hiding this comment.
That's an interesting thought @fibonacci1729. I like the idea of being able to say "I expect to find whatever files you want me to use at /foo, but it's up to you where you source them."
There is another use case, but I am not sure about generality: static assets. Here the component / dep / middleware doesn't want to put it on the app to supply files, because it already has specific ones it wants to use. E.g. the HTML, JavaScript and CSS for the "authorisation failed" page, or a CSV file of internal data. However, while this (I think) makes sense for a local component (a TOML file), we can't currently publish it as a standalone Wasm binary.
|
|
||
| ### Building a component | ||
|
|
||
| `spin build` recognizes a component manifest, runs its `[build].command`, and embeds |
There was a problem hiding this comment.
I think we'll need to enable push to embed metadata since build is optional.
|
@ThorstenHans we can't keep everything in the
Strongly agree and that's the argument for a standalone manifest. The moment you "generalize and distribute independently," you need an independent build/version/publish story, which is what |
No description provided.