Skip to content

Commit 043977e

Browse files
authored
chore(services): unify scheme usage (#6764)
1 parent a2d7c0d commit 043977e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+259
-178
lines changed

core/src/services/aliyun_drive/backend.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl Builder for AliyunDriveBuilder {
141141
ErrorKind::ConfigInvalid,
142142
"access_token and a set of client_id, client_secret, and refresh_token are both missing.")
143143
.with_operation("Builder::build")
144-
.with_context("service", Scheme::AliyunDrive)),
144+
.with_context("service", ALIYUN_DRIVE_SCHEME)),
145145
},
146146
};
147147

core/src/services/alluxio/backend.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl Builder for AlluxioBuilder {
104104
Some(endpoint) => Ok(endpoint.clone()),
105105
None => Err(Error::new(ErrorKind::ConfigInvalid, "endpoint is empty")
106106
.with_operation("Builder::build")
107-
.with_context("service", Scheme::Alluxio)),
107+
.with_context("service", ALLUXIO_SCHEME)),
108108
}?;
109109
debug!("backend use endpoint {}", &endpoint);
110110

core/src/services/alluxio/config.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use std::fmt::Debug;
2020
use serde::Deserialize;
2121
use serde::Serialize;
2222

23+
use super::ALLUXIO_SCHEME;
2324
use super::backend::AlluxioBuilder;
2425

2526
/// Config for alluxio services support.
@@ -54,7 +55,7 @@ impl crate::Configurator for AlluxioConfig {
5455
fn from_uri(uri: &crate::types::OperatorUri) -> crate::Result<Self> {
5556
let authority = uri.authority().ok_or_else(|| {
5657
crate::Error::new(crate::ErrorKind::ConfigInvalid, "uri authority is required")
57-
.with_context("service", crate::Scheme::Alluxio)
58+
.with_context("service", ALLUXIO_SCHEME)
5859
})?;
5960

6061
let mut map = uri.options().clone();

core/src/services/azblob/backend.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,15 +299,15 @@ impl Builder for AzblobBuilder {
299299
false => Ok(&self.config.container),
300300
true => Err(Error::new(ErrorKind::ConfigInvalid, "container is empty")
301301
.with_operation("Builder::build")
302-
.with_context("service", Scheme::Azblob)),
302+
.with_context("service", AZBLOB_SCHEME)),
303303
}?;
304304
debug!("backend use container {}", &container);
305305

306306
let endpoint = match &self.config.endpoint {
307307
Some(endpoint) => Ok(endpoint.clone()),
308308
None => Err(Error::new(ErrorKind::ConfigInvalid, "endpoint is empty")
309309
.with_operation("Builder::build")
310-
.with_context("service", Scheme::Azblob)),
310+
.with_context("service", AZBLOB_SCHEME)),
311311
}?;
312312
debug!("backend use endpoint {}", &container);
313313

@@ -333,7 +333,7 @@ impl Builder for AzblobBuilder {
333333
format!("invalid account_key: cannot decode as base64: {e}"),
334334
)
335335
.with_operation("Builder::build")
336-
.with_context("service", Scheme::Azblob)
336+
.with_context("service", AZBLOB_SCHEME)
337337
.with_context("key", "account_key"));
338338
}
339339
config_loader.account_key = Some(v);

core/src/services/azdls/backend.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,15 +248,15 @@ impl Builder for AzdlsBuilder {
248248
false => Ok(&self.config.filesystem),
249249
true => Err(Error::new(ErrorKind::ConfigInvalid, "filesystem is empty")
250250
.with_operation("Builder::build")
251-
.with_context("service", Scheme::Azdls)),
251+
.with_context("service", AZDLS_SCHEME)),
252252
}?;
253253
debug!("backend use filesystem {}", &filesystem);
254254

255255
let endpoint = match &self.config.endpoint {
256256
Some(endpoint) => Ok(endpoint.clone().trim_end_matches('/').to_string()),
257257
None => Err(Error::new(ErrorKind::ConfigInvalid, "endpoint is empty")
258258
.with_operation("Builder::build")
259-
.with_context("service", Scheme::Azdls)),
259+
.with_context("service", AZDLS_SCHEME)),
260260
}?;
261261
debug!("backend use endpoint {}", &endpoint);
262262

core/src/services/azdls/config.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use std::fmt::Debug;
2020
use serde::Deserialize;
2121
use serde::Serialize;
2222

23+
use super::AZDLS_SCHEME;
2324
use super::backend::AzdlsBuilder;
2425

2526
/// Azure Data Lake Storage Gen2 Support.
@@ -75,7 +76,7 @@ impl crate::Configurator for AzdlsConfig {
7576
fn from_uri(uri: &crate::types::OperatorUri) -> crate::Result<Self> {
7677
let authority = uri.authority().ok_or_else(|| {
7778
crate::Error::new(crate::ErrorKind::ConfigInvalid, "uri authority is required")
78-
.with_context("service", crate::Scheme::Azdls)
79+
.with_context("service", AZDLS_SCHEME)
7980
})?;
8081

8182
let mut map = uri.options().clone();
@@ -97,7 +98,7 @@ impl crate::Configurator for AzdlsConfig {
9798
crate::ErrorKind::ConfigInvalid,
9899
"filesystem is required in uri path",
99100
)
100-
.with_context("service", crate::Scheme::Azdls));
101+
.with_context("service", AZDLS_SCHEME));
101102
}
102103
map.insert("filesystem".to_string(), filesystem.to_string());
103104
if !rest.is_empty() {
@@ -113,7 +114,7 @@ impl crate::Configurator for AzdlsConfig {
113114
crate::ErrorKind::ConfigInvalid,
114115
"filesystem is required",
115116
)
116-
.with_context("service", crate::Scheme::Azdls));
117+
.with_context("service", AZDLS_SCHEME));
117118
}
118119

119120
Self::from_iter(map)

core/src/services/azfile/backend.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ impl Builder for AzfileBuilder {
179179
Some(endpoint) => Ok(endpoint.clone()),
180180
None => Err(Error::new(ErrorKind::ConfigInvalid, "endpoint is empty")
181181
.with_operation("Builder::build")
182-
.with_context("service", Scheme::Azfile)),
182+
.with_context("service", AZFILE_SCHEME)),
183183
}?;
184184
debug!("backend use endpoint {}", &endpoint);
185185

@@ -194,7 +194,7 @@ impl Builder for AzfileBuilder {
194194
None => Err(
195195
Error::new(ErrorKind::ConfigInvalid, "account_name is empty")
196196
.with_operation("Builder::build")
197-
.with_context("service", Scheme::Azfile),
197+
.with_context("service", AZFILE_SCHEME),
198198
),
199199
}?;
200200

core/src/services/azfile/config.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use std::fmt::Debug;
2020
use serde::Deserialize;
2121
use serde::Serialize;
2222

23+
use super::AZFILE_SCHEME;
2324
use super::backend::AzfileBuilder;
2425

2526
/// Azure File services support.
@@ -55,7 +56,7 @@ impl crate::Configurator for AzfileConfig {
5556
fn from_uri(uri: &crate::types::OperatorUri) -> crate::Result<Self> {
5657
let authority = uri.authority().ok_or_else(|| {
5758
crate::Error::new(crate::ErrorKind::ConfigInvalid, "uri authority is required")
58-
.with_context("service", crate::Scheme::Azfile)
59+
.with_context("service", AZFILE_SCHEME)
5960
})?;
6061

6162
let mut map = uri.options().clone();
@@ -77,7 +78,7 @@ impl crate::Configurator for AzfileConfig {
7778
crate::ErrorKind::ConfigInvalid,
7879
"share name is required in uri path",
7980
)
80-
.with_context("service", crate::Scheme::Azfile));
81+
.with_context("service", AZFILE_SCHEME));
8182
}
8283
map.insert("share_name".to_string(), share.to_string());
8384
if !rest.is_empty() {
@@ -93,7 +94,7 @@ impl crate::Configurator for AzfileConfig {
9394
crate::ErrorKind::ConfigInvalid,
9495
"share name is required",
9596
)
96-
.with_context("service", crate::Scheme::Azfile));
97+
.with_context("service", AZFILE_SCHEME));
9798
}
9899

99100
Self::from_iter(map)

core/src/services/b2/backend.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl Builder for B2Builder {
136136
if self.config.bucket.is_empty() {
137137
return Err(Error::new(ErrorKind::ConfigInvalid, "bucket is empty")
138138
.with_operation("Builder::build")
139-
.with_context("service", Scheme::B2));
139+
.with_context("service", B2_SCHEME));
140140
}
141141

142142
debug!("backend use bucket {}", &self.config.bucket);
@@ -145,7 +145,7 @@ impl Builder for B2Builder {
145145
if self.config.bucket_id.is_empty() {
146146
return Err(Error::new(ErrorKind::ConfigInvalid, "bucket_id is empty")
147147
.with_operation("Builder::build")
148-
.with_context("service", Scheme::B2));
148+
.with_context("service", B2_SCHEME));
149149
}
150150

151151
debug!("backend bucket_id {}", &self.config.bucket_id);
@@ -155,7 +155,7 @@ impl Builder for B2Builder {
155155
None => Err(
156156
Error::new(ErrorKind::ConfigInvalid, "application_key_id is empty")
157157
.with_operation("Builder::build")
158-
.with_context("service", Scheme::B2),
158+
.with_context("service", B2_SCHEME),
159159
),
160160
}?;
161161

@@ -164,7 +164,7 @@ impl Builder for B2Builder {
164164
None => Err(
165165
Error::new(ErrorKind::ConfigInvalid, "application_key is empty")
166166
.with_operation("Builder::build")
167-
.with_context("service", Scheme::B2),
167+
.with_context("service", B2_SCHEME),
168168
),
169169
}?;
170170

core/src/services/cacache/backend.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl Builder for CacacheBuilder {
4646
fn build(self) -> Result<impl Access> {
4747
let datadir_path = self.config.datadir.ok_or_else(|| {
4848
Error::new(ErrorKind::ConfigInvalid, "datadir is required but not set")
49-
.with_context("service", Scheme::Cacache)
49+
.with_context("service", CACACHE_SCHEME)
5050
})?;
5151

5252
let core = CacacheCore {

0 commit comments

Comments
 (0)