@@ -5,43 +5,96 @@ use serde::{Deserialize, Serialize};
5
5
6
6
use wasm_pkg_common:: { package:: PackageRef , registry:: Registry } ;
7
7
8
- /// Variable definition
8
+ use super :: json_schema;
9
+
10
+ /// The name of the application variable.
9
11
#[ derive( Clone , Debug , Serialize , Deserialize , JsonSchema ) ]
10
12
#[ serde( deny_unknown_fields) ]
11
13
pub struct Variable {
12
- /// `required = true`
14
+ /// Whether a value must be supplied at runtime. If not specified, required defaults
15
+ /// to `false`, and `default` must be provided.
16
+ ///
17
+ /// Example: `required = true`
18
+ ///
19
+ /// Learn more: https://spinframework.dev/variables#adding-variables-to-your-applications
13
20
#[ serde( default , skip_serializing_if = "is_false" ) ]
14
21
pub required : bool ,
15
- /// `default = "default value"`
22
+ /// The value of the variable if no value is supplied at runtime. If specified,
23
+ /// the value must be a string. If not specified, `required`` must be `true`.
24
+ ///
25
+ /// Example: `default = "default value"`
26
+ ///
27
+ /// Learn more: https://spinframework.dev/variables#adding-variables-to-your-applications
16
28
#[ serde( default , skip_serializing_if = "Option::is_none" ) ]
17
29
pub default : Option < String > ,
18
- /// `secret = true`
30
+ /// If set, this variable should be treated as sensitive.
31
+ ///
32
+ /// Example: `secret = true`
33
+ ///
34
+ /// Learn more: https://spinframework.dev/variables#adding-variables-to-your-applications
19
35
#[ serde( default , skip_serializing_if = "is_false" ) ]
20
36
pub secret : bool ,
21
37
}
22
38
23
- /// Component source
39
+ /// The file, package, or URL containing the component Wasm binary. This may be:
40
+ ///
41
+ /// - The path to a Wasm file (relative to the manifest file)
42
+ ///
43
+ /// Example: `source = "bin/cart.wasm"`
44
+ ///
45
+ /// - The URL of a Wasm file downloadable over HTTP, accompanied by a digest to ensure integrity
46
+ ///
47
+ /// Example: `source = { url = "https://example.com/example.wasm", digest = "sha256:6503...2375" }`
48
+ ///
49
+ /// - The registry, package and version of a component from a registry
50
+ ///
51
+ /// Example: `source = { registry = "ttl.sh", package = "user:registrytest", version="1.0.0" }`
52
+ ///
53
+ /// Learn more: https://spinframework.dev/writing-apps#the-component-source
24
54
#[ derive( Clone , Debug , Serialize , Deserialize , JsonSchema ) ]
25
55
#[ serde( deny_unknown_fields, untagged) ]
26
56
pub enum ComponentSource {
27
- /// `"local.wasm"`
57
+ /// `source = "bin/cart.wasm"`
58
+ #[ schemars( description = "" ) ] // schema docs are on the parent
28
59
Local ( String ) ,
29
- /// `{ ... }`
60
+ /// `source = { url = "https://example.com/example.wasm", digest = "sha256:6503...2375" }`
61
+ #[ schemars( description = "" ) ] // schema docs are on the parent
30
62
Remote {
31
- /// `url = "https://example.test/remote.wasm"`
63
+ /// The URL of the Wasm component binary.
64
+ ///
65
+ /// Example: `url = "https://example.test/remote.wasm"`
66
+ ///
67
+ /// Learn more: https://spinframework.dev/writing-apps#the-component-source
32
68
url : String ,
33
- /// `digest = `"sha256:abc123..."`
69
+ /// The SHA256 digest of the Wasm component binary. This must be prefixed with `sha256:`.
70
+ ///
71
+ /// Example: `digest = `"sha256:abc123..."`
72
+ ///
73
+ /// Learn more: https://spinframework.dev/writing-apps#the-component-source
34
74
digest : String ,
35
75
} ,
36
- /// `{ ... }`
76
+ /// `source = { registry = "ttl.sh", package = "user:registrytest", version="1.0.0" }`
77
+ #[ schemars( description = "" ) ] // schema docs are on the parent
37
78
Registry {
38
- /// `registry = "example.com"`
79
+ /// The registry containing the Wasm component binary.
80
+ ///
81
+ /// Example: `registry = "example.com"`
82
+ ///
83
+ /// Learn more: https://spinframework.dev/writing-apps#the-component-source
39
84
#[ schemars( with = "Option<String>" ) ]
40
85
registry : Option < Registry > ,
41
- /// `package = "example:component"`
86
+ /// The package containing the Wasm component binary.
87
+ ///
88
+ /// Example: `package = "example:component"`
89
+ ///
90
+ /// Learn more: https://spinframework.dev/writing-apps#the-component-source
42
91
#[ schemars( with = "String" ) ]
43
92
package : PackageRef ,
44
- /// `version = "1.2.3"`
93
+ /// The version of the package containing the Wasm component binary.
94
+ ///
95
+ /// Example: `version = "1.2.3"`
96
+ ///
97
+ /// Learn more: https://spinframework.dev/writing-apps#the-component-source
45
98
version : String ,
46
99
} ,
47
100
}
@@ -66,17 +119,33 @@ impl Display for ComponentSource {
66
119
}
67
120
}
68
121
69
- /// WASI files mount
122
+ /// The files the component is allowed to read. Each list entry is either:
123
+ ///
124
+ /// - a glob pattern (e.g. "assets/**/*.jpg"); or
125
+ ///
126
+ /// - a source-destination pair indicating where a host directory should be mapped in the guest (e.g. { source = "assets", destination = "/" })
127
+ ///
128
+ /// Learn more: https://spinframework.dev/writing-apps#including-files-with-components
70
129
#[ derive( Clone , Debug , Serialize , Deserialize , JsonSchema ) ]
71
130
#[ serde( deny_unknown_fields, untagged) ]
72
131
pub enum WasiFilesMount {
73
132
/// `"images/*.png"`
133
+ #[ schemars( description = "" ) ] // schema docs are on the parent
74
134
Pattern ( String ) ,
75
135
/// `{ ... }`
136
+ #[ schemars( description = "" ) ] // schema docs are on the parent
76
137
Placement {
77
- /// `source = "content/dir"`
138
+ /// The directory to be made available in the guest.
139
+ ///
140
+ /// Example: `source = "content/dir"`
141
+ ///
142
+ /// Learn more: https://spinframework.dev/writing-apps#including-files-with-components
78
143
source : String ,
144
+ /// The path where the `source` directory appears in the guest. Must be absolute.
145
+ ///
79
146
/// `destination = "/"`
147
+ ///
148
+ /// Learn more: https://spinframework.dev/writing-apps#including-files-with-components
80
149
destination : String ,
81
150
} ,
82
151
}
@@ -85,13 +154,30 @@ pub enum WasiFilesMount {
85
154
#[ derive( Clone , Debug , Serialize , Deserialize , JsonSchema ) ]
86
155
#[ serde( deny_unknown_fields) ]
87
156
pub struct ComponentBuildConfig {
88
- /// `command = "cargo build"`
157
+ /// The command or commands to build the application. If multiple commands
158
+ /// are specified, they are run sequentially from left to right.
159
+ ///
160
+ /// Example: `command = "cargo build"`, `command = ["npm install", "npm run build"]`
161
+ ///
162
+ /// Learn more: https://spinframework.dev/build#setting-up-for-spin-build
89
163
pub command : Commands ,
90
- /// `workdir = "components/main"
164
+ /// The working directory for the build command. If omitted, the build working
165
+ /// directory is the directory containing `spin.toml`.
166
+ ///
167
+ /// Example: `workdir = "components/main"
168
+ ///
169
+ /// Learn more: https://spinframework.dev/build#overriding-the-working-directory
91
170
#[ serde( default , skip_serializing_if = "Option::is_none" ) ]
92
171
pub workdir : Option < String > ,
93
- /// watch = ["src/**/*.rs"]
172
+ /// Source files to use in `spin watch`. This is a set of paths or glob patterns (relative
173
+ /// to the build working directory). A change to any matching file causes
174
+ /// `spin watch` to rebuild the application before restarting the application.
175
+ ///
176
+ /// Example: `watch = ["src/**/*.rs"]`
177
+ ///
178
+ /// Learn more: https://spinframework.dev/running-apps#monitoring-applications-for-changes
94
179
#[ serde( default , skip_serializing_if = "Vec::is_empty" ) ]
180
+ #[ schemars( with = "Vec<json_schema::WatchCommand>" ) ]
95
181
pub watch : Vec < String > ,
96
182
}
97
183
@@ -106,13 +192,20 @@ impl ComponentBuildConfig {
106
192
}
107
193
}
108
194
109
- /// Component build command or commands
195
+ /// The command or commands to build the application. If multiple commands
196
+ /// are specified, they are run sequentially from left to right.
197
+ ///
198
+ /// Example: `command = "cargo build"`, `command = ["npm install", "npm run build"]`
199
+ ///
200
+ /// Learn more: https://spinframework.dev/build#setting-up-for-spin-build
110
201
#[ derive( Clone , Debug , Serialize , Deserialize , JsonSchema ) ]
111
202
#[ serde( untagged) ]
112
203
pub enum Commands {
113
204
/// `command = "cargo build"`
205
+ #[ schemars( description = "" ) ] // schema docs are on the parent
114
206
Single ( String ) ,
115
207
/// `command = ["cargo build", "wac encode compose-deps.wac -d my:pkg=app.wasm --registry fermyon.com"]`
208
+ #[ schemars( description = "" ) ] // schema docs are on the parent
116
209
Multiple ( Vec < String > ) ,
117
210
}
118
211
0 commit comments