@@ -49,6 +49,9 @@ pub struct Configuration {
49
49
/// Type of snapshot uploader to use
50
50
pub snapshot_uploader_type : SnapshotUploaderType ,
51
51
52
+ /// Bucket name where the snapshots are stored if snapshot_uploader_type is Gcp
53
+ pub snapshot_bucket_name : Option < String > ,
54
+
52
55
/// Server listening IP
53
56
pub server_ip : String ,
54
57
@@ -109,7 +112,11 @@ impl Configuration {
109
112
pub fn build_snapshot_store ( & self ) -> Result < Arc < dyn SnapshotStore > , Box < dyn Error > > {
110
113
match self . snapshot_store_type {
111
114
SnapshotStoreType :: Gcp => Ok ( Arc :: new ( RemoteSnapshotStore :: new (
112
- Box :: new ( GcpFileUploader :: default ( ) ) ,
115
+ Box :: new ( GcpFileUploader :: new (
116
+ self . snapshot_bucket_name . to_owned ( ) . ok_or_else ( || {
117
+ ConfigError :: Message ( "missing snapshot bucket name" . to_string ( ) )
118
+ } ) ?,
119
+ ) ) ,
113
120
self . url_snapshot_manifest . clone ( ) ,
114
121
) ) ) ,
115
122
SnapshotStoreType :: Local => Ok ( Arc :: new ( LocalSnapshotStore :: new (
@@ -123,15 +130,17 @@ impl Configuration {
123
130
}
124
131
125
132
/// Create a snapshot uploader from configuration settings.
126
- pub fn build_snapshot_uploader ( & self ) -> Arc < dyn SnapshotUploader > {
133
+ pub fn build_snapshot_uploader ( & self ) -> Result < Arc < dyn SnapshotUploader > , Box < dyn Error > > {
127
134
match self . snapshot_uploader_type {
128
- SnapshotUploaderType :: Gcp => Arc :: new ( RemoteSnapshotUploader :: new ( Box :: new (
129
- GcpFileUploader :: default ( ) ,
130
- ) ) ) ,
131
- SnapshotUploaderType :: Local => Arc :: new ( LocalSnapshotUploader :: new (
135
+ SnapshotUploaderType :: Gcp => Ok ( Arc :: new ( RemoteSnapshotUploader :: new ( Box :: new (
136
+ GcpFileUploader :: new ( self . snapshot_bucket_name . to_owned ( ) . ok_or_else ( || {
137
+ ConfigError :: Message ( "missing snapshot bucket name" . to_string ( ) )
138
+ } ) ?) ,
139
+ ) ) ) ) ,
140
+ SnapshotUploaderType :: Local => Ok ( Arc :: new ( LocalSnapshotUploader :: new (
132
141
self . get_server_url ( ) ,
133
142
& self . snapshot_directory ,
134
- ) ) ,
143
+ ) ) ) ,
135
144
}
136
145
}
137
146
0 commit comments