pub struct Component {Show 15 fields
pub source: ComponentSource,
pub description: String,
pub variables: IndexMap<LowerSnakeId, String>,
pub environment: IndexMap<String, String>,
pub files: Vec<WasiFilesMount>,
pub exclude_files: Vec<String>,
pub allowed_http_hosts: Vec<String>,
pub allowed_outbound_hosts: Vec<String>,
pub key_value_stores: Vec<String>,
pub sqlite_databases: Vec<String>,
pub ai_models: Vec<String>,
pub build: Option<ComponentBuildConfig>,
pub tool: IndexMap<String, Table>,
pub dependencies_inherit_configuration: bool,
pub dependencies: ComponentDependencies,
}
Expand description
A Spin component.
Fields§
§source: ComponentSource
The file, package, or URL containing the component Wasm binary.
Example: source = "bin/cart.wasm"
Learn more: https://spinframework.dev/writing-apps#the-component-source
description: String
A human-readable description of the component.
Example: description = "Shopping cart"
variables: IndexMap<LowerSnakeId, String>
Configuration variables available to the component. Names must be
in lower_snake_case
. Values are strings, and may refer
to application variables using {{ ... }}
syntax.
variables = { users_endpoint = "https://{{ api_host }}/users"}
Learn more: https://spinframework.dev/variables#adding-variables-to-your-applications
environment: IndexMap<String, String>
Environment variables to be set for the Wasm module.
environment = { DB_URL = "mysql://spin:spin@localhost/dev" }
files: Vec<WasiFilesMount>
The files the component is allowed to read. Each list entry is either:
-
a glob pattern (e.g. “assets/**/*.jpg”); or
-
a source-destination pair indicating where a host directory should be mapped in the guest (e.g. { source = “assets”, destination = “/” })
Learn more: https://spinframework.dev/writing-apps#including-files-with-components
exclude_files: Vec<String>
Any files or glob patterns that should not be available to the Wasm module at runtime, even though they match a `files`` entry.
Example: exclude_files = ["secrets/*"]
Learn more: https://spinframework.dev/writing-apps#including-files-with-components
allowed_http_hosts: Vec<String>
Deprecated. Use allowed_outbound_hosts
instead.
Example: allowed_http_hosts = ["example.com"]
allowed_outbound_hosts: Vec<String>
The network destinations which the component is allowed to access. Each entry is in the form “(scheme)://(host)[:port]”. Each element allows * as a wildcard e.g. “https://*” (HTTPS on the default port to any destination) or “*://localhost:*” (any protocol to any port on localhost). The host part allows segment wildcards for subdomains e.g. “https://*.example.com”. Application variables are allowed using `{{ my_var }}`` syntax.
Example: allowed_outbound_hosts = ["redis://myredishost.com:6379"]
Learn more: https://spinframework.dev/http-outbound#granting-http-permissions-to-components
key_value_stores: Vec<String>
The key-value stores which the component is allowed to access. Stores are identified by label e.g. “default” or “customer”. Stores other than “default” must be mapped to a backing store in the runtime config.
Example: key_value_stores = ["default", "my-store"]
Learn more: https://spinframework.dev/kv-store-api-guide#custom-key-value-stores
sqlite_databases: Vec<String>
The SQLite databases which the component is allowed to access. Databases are identified by label e.g. “default” or “analytics”. Databases other than “default” must be mapped to a backing store in the runtime config. Use “spin up –sqlite” to run database setup scripts.
Example: sqlite_databases = ["default", "my-database"]
Learn more: https://spinframework.dev/sqlite-api-guide#preparing-an-sqlite-database
ai_models: Vec<String>
The AI models which the component is allowed to access. For local execution, you must download all models; for hosted execution, you should check which models are available in your target environment.
Example: ai_models = ["llama2-chat"]
Learn more: https://spinframework.dev/serverless-ai-api-guide#using-serverless-ai-from-applications
build: Option<ComponentBuildConfig>
The component build configuration.
Learn more: https://spinframework.dev/build
tool: IndexMap<String, Table>
Settings for custom tools or plugins. Spin ignores this field.
dependencies_inherit_configuration: bool
If true, dependencies can invoke Spin APIs with the same permissions as the main component. If false, dependencies have no permissions (e.g. network, key-value stores, SQLite databases).
Learn more: https://spinframework.dev/writing-apps#dependency-permissions
dependencies: ComponentDependencies
Specifies how to satisfy Wasm Component Model imports of this component.
Learn more: https://spinframework.dev/writing-apps#using-component-dependencies
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Component
impl<'de> Deserialize<'de> for Component
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for Component
impl JsonSchema for Component
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref
keyword. Read more