Skip to content

Commit

Permalink
Support Azure blob storage in a similar fashion to S3. (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
tamwuff authored Nov 13, 2024
1 parent 8d49089 commit 81a8b8b
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 21 deletions.
1 change: 1 addition & 0 deletions src/pages/config/schema/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ impl Builder<Schemas, ()> {
"sqlite",
"rocksdb",
"s3",
"azure",
"fs",
"sql-read-replica",
"distributed-blob",
Expand Down
81 changes: 60 additions & 21 deletions src/pages/config/schema/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ impl Builder<Schemas, ()> {
("s3", "S3-compatible"),
("redis", "Redis/Memcached"),
("elasticsearch", "ElasticSearch"),
("azure", "Azure blob storage"),
("fs", "Filesystem"),
("sql-read-replica", "SQL with Replicas ⭐"),
("distributed-blob", "Distributed Blob ⭐"),
Expand Down Expand Up @@ -159,7 +160,7 @@ impl Builder<Schemas, ()> {
.new_field("timeout")
.label("Timeout")
.help("Connection timeout to the database")
.display_if_eq("type", ["postgresql", "mysql", "redis", "s3"])
.display_if_eq("type", ["postgresql", "mysql", "redis", "s3", "azure"])
.typ(Type::Duration)
.default("15s")
.build()
Expand Down Expand Up @@ -240,6 +241,32 @@ impl Builder<Schemas, ()> {
.typ(Type::Input)
.input_check([Transformer::Trim], [Validator::Required, Validator::IsUrl])
.build()
// Maximum number of retries
.new_field("max-retries")
.label("Retry limit")
.help(concat!(
"The maximum number of times to retry failed requests. ",
"Set to 0 to disable retries"
))
.display_if_eq("type", ["s3", "azure"])
.placeholder("3")
.default("3")
.typ(Type::Input)
.input_check(
[Transformer::Trim],
[
Validator::MinValue(1.into()),
Validator::MaxValue(10.into()),
],
)
.build()
// Key prefix (for blob stores)
.new_field("key-prefix")
.label("Key Prefix")
.help("A prefix that will be added to the keys of all objects stored in the blob store")
.display_if_eq("type", ["s3", "azure"])
.input_check([Transformer::Trim], [])
.build()
// SQL directory specific
.new_field("query.name")
.label("Account by Name")
Expand Down Expand Up @@ -456,10 +483,6 @@ impl Builder<Schemas, ()> {
.label("Region")
.help("The geographical region where the bucket resides")
.placeholder("us-east-1")
.new_field("key-prefix")
.label("Key Prefix")
.help("A prefix that will be added to the keys of all objects stored in the S3 bucket")
.input_check([Transformer::Trim], [])
.new_field("endpoint")
.help(concat!(
"The network address (hostname and optionally a port) of the S3 service. ",
Expand All @@ -484,22 +507,30 @@ impl Builder<Schemas, ()> {
.typ(Type::Secret)
.new_field("security-token")
.label("Security Token")
.new_field("max-retries")
.label("Retry limit")
.help(concat!(
"The maximum number of times to retry failed requests. ",
"Set to 0 to disable retries"
))
.placeholder("3")
.default("3")
.build()
// Azure specific
.new_field("storage-account")
.typ(Type::Input)
.input_check(
[Transformer::Trim],
[
Validator::MinValue(1.into()),
Validator::MaxValue(10.into()),
],
)
.label("Storage Account Name")
.help("The Azure Storage Account where blobs (e-mail messages, Sieve scripts, etc.) will be stored")
.input_check([Transformer::Trim], [Validator::Required])
.placeholder("mycompany")
.display_if_eq("type", ["azure"])
.new_field("container")
.typ(Type::Input)
.label("Container")
.help("The name of the container in the Storage Account")
.input_check([Transformer::Trim], [Validator::Required])
.placeholder("stalwart")
.new_field("azure-access-key")
.label("Access Key")
.help("The access key for the Azure Storage Account")
.typ(Type::Secret)
.input_check([Transformer::Trim], [])
.new_field("sas-token")
.label("SAS Token (if not using access-key based authentication)")
.typ(Type::Secret)
.input_check([Transformer::Trim], [])
.build()
// FS specific
.new_field("depth")
Expand Down Expand Up @@ -588,15 +619,22 @@ impl Builder<Schemas, ()> {
.fields(["bucket", "key-prefix"])
.build()
.new_form_section()
.title("Storage Account")
.display_if_eq("type", ["azure"])
.fields(["storage-account", "container", "key-prefix"])
.build()
.new_form_section()
.title("Authentication")
.display_if_eq("type", ["postgresql", "mysql", "elasticsearch", "s3"])
.display_if_eq("type", ["postgresql", "mysql", "elasticsearch", "s3", "azure"])
.display_if_eq("redis-type", ["cluster"])
.fields([
"user",
"password",
"access-key",
"secret-key",
"security-token",
"azure-access-key",
"sas-token",
])
.build()
.new_form_section()
Expand All @@ -611,6 +649,7 @@ impl Builder<Schemas, ()> {
"foundationdb",
"fs",
"s3",
"azure",
"sql-read-replica",
"distributed-blob",
],
Expand Down

0 comments on commit 81a8b8b

Please sign in to comment.