1414
1515use std:: collections:: HashMap ;
1616
17+ #[ cfg( feature = "dev-schema" ) ]
18+ use schemars:: JsonSchema ;
1719use serde:: Deserialize ;
1820
1921use crate :: serde_utils:: {
@@ -34,6 +36,7 @@ pub type InstanceName = String;
3436
3537#[ allow( non_camel_case_types) ]
3638#[ derive( Deserialize , Debug , Default , Clone , Copy ) ]
39+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
3740pub enum HttpCompressionAlgorithm {
3841 /// No compression.
3942 #[ default]
@@ -54,6 +57,7 @@ pub enum HttpCompressionAlgorithm {
5457/// and cloud-clients to use another.
5558#[ derive( Deserialize , Debug , Default ) ]
5659#[ serde( deny_unknown_fields) ]
60+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
5761pub struct HttpCompressionConfig {
5862 /// The compression algorithm that the server will use when sending
5963 /// responses to clients. Enabling this will likely save a lot of
@@ -77,6 +81,7 @@ pub struct HttpCompressionConfig {
7781
7882#[ derive( Deserialize , Debug ) ]
7983#[ serde( deny_unknown_fields) ]
84+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
8085pub struct AcStoreConfig {
8186 /// The store name referenced in the `stores` map in the main config.
8287 /// This store name referenced here may be reused multiple times.
@@ -91,6 +96,7 @@ pub struct AcStoreConfig {
9196
9297#[ derive( Deserialize , Debug ) ]
9398#[ serde( deny_unknown_fields) ]
99+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
94100pub struct CasStoreConfig {
95101 /// The store name referenced in the `stores` map in the main config.
96102 /// This store name referenced here may be reused multiple times.
@@ -100,6 +106,7 @@ pub struct CasStoreConfig {
100106
101107#[ derive( Deserialize , Debug , Default ) ]
102108#[ serde( deny_unknown_fields) ]
109+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
103110pub struct CapabilitiesRemoteExecutionConfig {
104111 /// Scheduler used to configure the capabilities of remote execution.
105112 #[ serde( deserialize_with = "convert_string_with_shellexpand" ) ]
@@ -108,6 +115,7 @@ pub struct CapabilitiesRemoteExecutionConfig {
108115
109116#[ derive( Deserialize , Debug , Default ) ]
110117#[ serde( deny_unknown_fields) ]
118+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
111119pub struct CapabilitiesConfig {
112120 /// Configuration for remote execution capabilities.
113121 /// If not set the capabilities service will inform the client that remote
@@ -117,6 +125,7 @@ pub struct CapabilitiesConfig {
117125
118126#[ derive( Deserialize , Debug ) ]
119127#[ serde( deny_unknown_fields) ]
128+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
120129pub struct ExecutionConfig {
121130 /// The store name referenced in the `stores` map in the main config.
122131 /// This store name referenced here may be reused multiple times.
@@ -131,6 +140,7 @@ pub struct ExecutionConfig {
131140
132141#[ derive( Deserialize , Debug , Default ) ]
133142#[ serde( deny_unknown_fields) ]
143+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
134144pub struct ByteStreamConfig {
135145 /// Name of the store in the "stores" configuration.
136146 pub cas_stores : HashMap < InstanceName , StoreRefName > ,
@@ -161,6 +171,7 @@ pub struct ByteStreamConfig {
161171
162172#[ derive( Deserialize , Debug ) ]
163173#[ serde( deny_unknown_fields) ]
174+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
164175pub struct WorkerApiConfig {
165176 /// The scheduler name referenced in the `schedulers` map in the main config.
166177 #[ serde( deserialize_with = "convert_string_with_shellexpand" ) ]
@@ -169,6 +180,7 @@ pub struct WorkerApiConfig {
169180
170181#[ derive( Deserialize , Debug , Default ) ]
171182#[ serde( deny_unknown_fields) ]
183+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
172184pub struct PrometheusConfig {
173185 /// Path to register prometheus metrics. If path is "/metrics", and your
174186 /// domain is "example.com", you can reach the endpoint with:
@@ -181,6 +193,7 @@ pub struct PrometheusConfig {
181193
182194#[ derive( Deserialize , Debug , Default ) ]
183195#[ serde( deny_unknown_fields) ]
196+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
184197pub struct AdminConfig {
185198 /// Path to register the admin API. If path is "/admin", and your
186199 /// domain is "example.com", you can reach the endpoint with:
@@ -193,6 +206,7 @@ pub struct AdminConfig {
193206
194207#[ derive( Deserialize , Debug , Default ) ]
195208#[ serde( deny_unknown_fields) ]
209+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
196210pub struct HealthConfig {
197211 /// Path to register the health status check. If path is "/status", and your
198212 /// domain is "example.com", you can reach the endpoint with:
@@ -204,6 +218,7 @@ pub struct HealthConfig {
204218}
205219
206220#[ derive( Deserialize , Debug ) ]
221+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
207222pub struct BepConfig {
208223 /// The store to publish build events to.
209224 /// The store name referenced in the `stores` map in the main config.
@@ -212,6 +227,7 @@ pub struct BepConfig {
212227}
213228
214229#[ derive( Deserialize , Clone , Debug , Default ) ]
230+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
215231pub struct IdentityHeaderSpec {
216232 /// The name of the header to look for the identity in.
217233 /// Default: "x-identity"
@@ -224,6 +240,7 @@ pub struct IdentityHeaderSpec {
224240}
225241
226242#[ derive( Deserialize , Clone , Debug ) ]
243+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
227244pub struct OriginEventsPublisherSpec {
228245 /// The store to publish nativelink events to.
229246 /// The store name referenced in the `stores` map in the main config.
@@ -232,6 +249,7 @@ pub struct OriginEventsPublisherSpec {
232249}
233250
234251#[ derive( Deserialize , Clone , Debug ) ]
252+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
235253pub struct OriginEventsSpec {
236254 /// The publisher configuration for origin events.
237255 pub publisher : OriginEventsPublisherSpec ,
@@ -247,6 +265,7 @@ pub struct OriginEventsSpec {
247265
248266#[ derive( Deserialize , Debug ) ]
249267#[ serde( deny_unknown_fields) ]
268+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
250269pub struct ServicesConfig {
251270 /// The Content Addressable Storage (CAS) backend config.
252271 /// The key is the `instance_name` used in the protocol and the
@@ -301,6 +320,7 @@ pub struct ServicesConfig {
301320
302321#[ derive( Deserialize , Debug ) ]
303322#[ serde( deny_unknown_fields) ]
323+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
304324pub struct TlsConfig {
305325 /// Path to the certificate file.
306326 #[ serde( deserialize_with = "convert_string_with_shellexpand" ) ]
@@ -329,6 +349,7 @@ pub struct TlsConfig {
329349/// specified.
330350#[ derive( Deserialize , Debug , Default ) ]
331351#[ serde( deny_unknown_fields) ]
352+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
332353pub struct HttpServerConfig {
333354 /// Interval to send keep-alive pings via HTTP2.
334355 /// Note: This is in seconds.
@@ -396,13 +417,15 @@ pub struct HttpServerConfig {
396417
397418#[ allow( non_camel_case_types) ]
398419#[ derive( Deserialize , Debug ) ]
420+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
399421pub enum ListenerConfig {
400422 /// Listener for HTTP/HTTPS/HTTP2 sockets.
401423 http( HttpListener ) ,
402424}
403425
404426#[ derive( Deserialize , Debug ) ]
405427#[ serde( deny_unknown_fields) ]
428+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
406429pub struct HttpListener {
407430 /// Address to listen on. Example: `127.0.0.1:8080` or `:8080` to listen
408431 /// to all IPs.
@@ -427,6 +450,7 @@ pub struct HttpListener {
427450
428451#[ derive( Deserialize , Debug ) ]
429452#[ serde( deny_unknown_fields) ]
453+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
430454pub struct ServerConfig {
431455 /// Name of the server. This is used to help identify the service
432456 /// for telemetry and logs.
@@ -449,6 +473,7 @@ pub struct ServerConfig {
449473
450474#[ allow( non_camel_case_types) ]
451475#[ derive( Deserialize , Debug ) ]
476+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
452477pub enum WorkerProperty {
453478 /// List of static values.
454479 /// Note: Generally there should only ever be 1 value, but if the platform
@@ -464,6 +489,7 @@ pub enum WorkerProperty {
464489/// Generic config for an endpoint and associated configs.
465490#[ derive( Deserialize , Debug , Default ) ]
466491#[ serde( deny_unknown_fields) ]
492+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
467493pub struct EndpointConfig {
468494 /// URI of the endpoint.
469495 #[ serde( deserialize_with = "convert_string_with_shellexpand" ) ]
@@ -479,6 +505,7 @@ pub struct EndpointConfig {
479505
480506#[ allow( non_camel_case_types) ]
481507#[ derive( Copy , Clone , Deserialize , Debug , Default ) ]
508+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
482509pub enum UploadCacheResultsStrategy {
483510 /// Only upload action results with an exit code of 0.
484511 #[ default]
@@ -496,6 +523,7 @@ pub enum UploadCacheResultsStrategy {
496523
497524#[ allow( non_camel_case_types) ]
498525#[ derive( Clone , Deserialize , Debug ) ]
526+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
499527pub enum EnvironmentSource {
500528 /// The name of the platform property in the action to get the value from.
501529 property( String ) ,
@@ -543,6 +571,7 @@ pub enum EnvironmentSource {
543571
544572#[ derive( Deserialize , Debug , Default ) ]
545573#[ serde( deny_unknown_fields) ]
574+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
546575pub struct UploadActionResultConfig {
547576 /// Underlying AC store that the worker will use to publish execution results
548577 /// into. Objects placed in this store should be reachable from the
@@ -603,6 +632,7 @@ pub struct UploadActionResultConfig {
603632
604633#[ derive( Deserialize , Debug , Default ) ]
605634#[ serde( deny_unknown_fields) ]
635+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
606636pub struct LocalWorkerConfig {
607637 /// Name of the worker. This is give a more friendly name to a worker for logging
608638 /// and metric publishing. This is also the prefix of the worker id
@@ -695,13 +725,15 @@ pub struct LocalWorkerConfig {
695725
696726#[ allow( non_camel_case_types) ]
697727#[ derive( Deserialize , Debug ) ]
728+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
698729pub enum WorkerConfig {
699730 /// A worker type that executes jobs locally on this machine.
700731 local( LocalWorkerConfig ) ,
701732}
702733
703734#[ derive( Deserialize , Debug , Clone , Copy ) ]
704735#[ serde( deny_unknown_fields) ]
736+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
705737pub struct GlobalConfig {
706738 /// Maximum number of open files that can be opened at one time.
707739 /// This value is not strictly enforced, it is a best effort. Some internal libraries
@@ -747,6 +779,7 @@ pub struct GlobalConfig {
747779
748780#[ derive( Deserialize , Debug ) ]
749781#[ serde( deny_unknown_fields) ]
782+ #[ cfg_attr( feature = "dev-schema" , derive( JsonSchema ) ) ]
750783pub struct CasConfig {
751784 /// List of stores available to use in this config.
752785 /// The keys can be used in other configs when needing to reference a store.
0 commit comments