@@ -24,6 +24,8 @@ use serde::Deserialize;
24
24
use tempfile:: tempdir_in;
25
25
use tracing:: info;
26
26
27
+ const CONFIG_VERSION : & str = "0.0.1" ;
28
+
27
29
#[ derive( Debug , Deserialize ) ]
28
30
#[ serde( tag = "type" ) ]
29
31
enum ThroughputConfig {
@@ -36,6 +38,8 @@ enum ThroughputConfig {
36
38
#[ derive( Debug , Deserialize ) ]
37
39
#[ serde( deny_unknown_fields) ]
38
40
struct ConfigOptions {
41
+ /// Version of the configuration format
42
+ config_version : String ,
39
43
/// Directory to mount the bucket at
40
44
mountpoint : String ,
41
45
/// AWS region of the bucket, e.g. "us-east-2"
@@ -165,6 +169,17 @@ impl ConfigOptions {
165
169
}
166
170
}
167
171
}
172
+
173
+ fn validate_version ( & self ) -> Result < ( ) > {
174
+ if self . config_version != CONFIG_VERSION {
175
+ Err ( anyhow ! (
176
+ "Unsupported version of the configuration format, supported version is {}" ,
177
+ CONFIG_VERSION
178
+ ) )
179
+ } else {
180
+ Ok ( ( ) )
181
+ }
182
+ }
168
183
}
169
184
170
185
fn load_config < P : AsRef < Path > > ( path : P ) -> Result < ConfigOptions > {
@@ -248,6 +263,7 @@ fn main() -> Result<()> {
248
263
let args = Args :: parse ( ) ;
249
264
// Read the config
250
265
let config = load_config ( & args. config ) . context ( "Failed to load config" ) ?;
266
+ config. validate_version ( ) ?;
251
267
// Set up the error logger
252
268
let error_logger = FileErrorLogger :: new ( & config. event_log_dir , || {
253
269
// trigger graceful shutdown (with umount) by sending a signal to self
0 commit comments