Skip to content

Commit

Permalink
Tweaks and discoverability for files setting
Browse files Browse the repository at this point in the history
Signed-off-by: itowlson <[email protected]>
  • Loading branch information
itowlson committed Jan 3, 2024
1 parent d241849 commit a72c383
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion content/spin/v2/manifest-reference-v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Each table in the `component` array contains the following fields:
| `source` | Required | String or table | The Wasm module which should handle the component. This must be built to work with the application trigger. It can be in one of the following formats: | |
| | | String | * The path to a Wasm file (relative to the manifest file) | `dist/cart.wasm` |
| | | Table | * The URL of a Wasm file downloadable over HTTP. This must be a table containing a `url` field for the Wasm file, and a `digest` field contains a SHA256 hex digest, used to check integrity. | `{ url = "https://example.com/example.wasm", digest = "sha256:6503...2375" }` |
| `files` | Optional | Array of strings and/or tables | The files to be made available to the Wasm module at runtime. This is an array, and each element of the array is either: | `[ "images/*.jpg", { source = "assets/images", destination = "/pictures" } ]` |
| `files` | Optional | Array of strings and/or tables | The [files to be made available to the Wasm module at runtime](writing-apps#including-files-with-components). This is an array, and each element of the array is either: | `[ "images/*.jpg", { source = "assets/images", destination = "/pictures" } ]` |
| | | String | * A file path or glob pattern, relative to the manifest file. The matching file or files will be available in the Wasm module at the same relative paths. | `"images/*.jpg"` |
| | | Table | * A directory to be made available to the Wasm module at a specific path. This must be a table containing a `source` field for the directory relative to the manifest file, and a `destination` field containing the absolute path at which to make it available. | `{ source = "assets/images", destination = "/pictures" }` |
| `exclude_files` | Optional | Array of strings | Any files or glob patterns that should _not_ be available to the Wasm module at runtime, even though they match a `files` entry. | `[assets/images/test/**/*.*]` |
Expand Down
2 changes: 1 addition & 1 deletion content/spin/v2/manifest-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ The value of each key is a table with the following fields.
| `source` | Required | String or table | The Wasm module which should handle the component. This must be built to work with the application trigger. It can be in one of the following formats: | |
| | | String | * The path to a Wasm file (relative to the manifest file) | `dist/cart.wasm` |
| | | Table | * The URL of a Wasm file downloadable over HTTP. This must be a table containing a `url` field for the Wasm file, and a `digest` field contains a SHA256 hex digest, used to check integrity. | `{ url = "https://example.com/example.wasm", digest = "sha256:6503...2375" }` |
| `files` | Optional | Array of strings and/or tables | The files to be made available to the Wasm module at runtime. This is an array, and each element of the array is either: | `[ "images/*.jpg", { source = "assets/images", destination = "/pictures" } ]` |
| `files` | Optional | Array of strings and/or tables | The [files to be made available to the Wasm module at runtime](writing-apps#including-files-with-components). This is an array, and each element of the array is either: | `[ "images/*.jpg", { source = "assets/images", destination = "/pictures" } ]` |
| | | String | * A file path or glob pattern, relative to the manifest file. The matching file or files will be available in the Wasm module at the same relative paths. | `"images/*.jpg"` |
| | | Table | * A file or directory to be made available to the Wasm module at a specific path. This must be a table containing a `source` field for the file or directory relative to the manifest file, and a `destination` field containing the absolute path at which to make it available. | `{ source = "assets/images", destination = "/pictures" }` |
| `exclude_files` | Optional | Array of strings | Any files or glob patterns that should _not_ be available to the Wasm module at runtime, even though they match a `files` entry. | `[assets/images/test/**/*.*]` |
Expand Down
4 changes: 3 additions & 1 deletion content/spin/v2/writing-apps.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,15 @@ files = [ "images/**/*.jpg", { source = "styles/dist", destination = "/styles" }

The `files` field is an array listing the files, patterns and directories you want to include. Each element of the array can be:

* A glob pattern, such as `images/**/*.jpg`. In this case, the files that match the pattern are available to the Wasm code, at the same paths as they are in your file system. For example, if the glob pattern matches `images/photos/lake.jpg`, the Wasm module can access it using the path `images/photos/lake.jpg`. Glob patterns are relative to the directory containing `spin.toml`, and must be within that directory.
* A glob pattern, such as `images/**/*.jpg`, or single file path. In this case, the file or files that match the pattern are available to the Wasm code, at the same paths as they are in your file system. For example, if the glob pattern matches `images/photos/lake.jpg`, the Wasm module can access it using the path `images/photos/lake.jpg`. Glob patterns are relative to the directory containing `spin.toml`, and must be within that directory.
* A mapping from a `source` file or directory to a `destination` location, such as `{ source = "styles/dist", destination = "/styles" }`. In this case, the file, or the entire contents of the source directory, are available to the Wasm code at the destination location. In this example, if you have a file named `styles/dist/list/exciting.css`, the Wasm module can access it using the path `/styles/list/exciting.css`. Source locations are relative to the directory containing `spin.toml`; destination locations must be absolute.

If your files list would match some files or directories that you _don't_ want included, you can use the `exclude_files` field to omit them.

> By default, Spin takes a snapshot of your included files, and components access that snapshot. This ensures that when you test your application, you are checking it with the set of files it will be deployed with. However, it also means that your component does not pick up changes to the files while it is running. When testing a Web site, you might want to be able to edit a HTML or CSS file, and see the changes reflected without restarting Spin. You can tell Spin to give components access to the original, "live" files by passing the `--direct-mounts` flag to `spin up`.
> Each component can access _only_ the files included via its `files` section. It does not have access to files included by other components, to your source code, or to the compiled `.wasm` file (unless you add those to the `files` section).
## Adding Environment Variables to Components

Environment variables can be provided to components via the Spin application manifest.
Expand Down

0 comments on commit a72c383

Please sign in to comment.