PsiACE commented on code in PR #30:
URL: https://github.com/apache/opendal-oli/pull/30#discussion_r3339498255
##########
src/commands/config.rs:
##########
@@ -98,3 +172,507 @@ fn ordered_entries(options: &HashMap<String, String>) ->
Vec<(&String, &String)>
entries.sort_by(|a, b| a.0.cmp(b.0));
entries
}
+
+#[derive(Clone, Copy)]
+struct ProfileSchema {
+ name: &'static str,
+ fields: &'static [ProfileField],
+}
+
+#[derive(Clone, Copy)]
+struct ProfileField {
+ name: &'static str,
+ kind: FieldKind,
+ required: bool,
+}
+
+#[derive(Clone, Copy)]
+enum FieldKind {
+ Text,
+ Bool,
+}
+
+const fn field(name: &'static str) -> ProfileField {
+ ProfileField {
+ name,
+ kind: FieldKind::Text,
+ required: false,
+ }
+}
+
+const fn required_field(name: &'static str) -> ProfileField {
+ ProfileField {
+ name,
+ kind: FieldKind::Text,
+ required: true,
+ }
+}
+
+const fn bool_field(name: &'static str) -> ProfileField {
+ ProfileField {
+ name,
+ kind: FieldKind::Bool,
+ required: false,
+ }
+}
+
+const SCHEMAS: &[ProfileSchema] = &[
+ ProfileSchema {
+ name: "azblob",
+ fields: &[
+ field("root"),
+ required_field("container"),
+ field("endpoint"),
+ field("account_name"),
+ field("account_key"),
+ field("encryption_key"),
+ field("encryption_key_sha256"),
+ field("encryption_algorithm"),
+ field("sas_token"),
+ field("batch_max_operations"),
+ ],
+ },
+ ProfileSchema {
+ name: "azdls",
+ fields: &[
+ field("root"),
+ required_field("filesystem"),
+ field("endpoint"),
+ field("account_name"),
+ field("account_key"),
+ field("client_secret"),
+ field("tenant_id"),
+ field("client_id"),
+ field("sas_token"),
+ field("authority_host"),
+ bool_field("enable_hns"),
+ ],
+ },
+ ProfileSchema {
+ name: "azfile",
+ fields: &[
+ field("root"),
+ field("endpoint"),
+ required_field("share_name"),
+ field("account_name"),
+ field("account_key"),
+ field("sas_token"),
+ ],
+ },
+ ProfileSchema {
+ name: "cos",
+ fields: &[
+ field("root"),
+ field("endpoint"),
+ field("secret_id"),
+ field("secret_key"),
+ field("bucket"),
+ bool_field("enable_versioning"),
+ bool_field("disable_config_load"),
+ ],
+ },
+ ProfileSchema {
+ name: "dropbox",
+ fields: &[
+ field("root"),
+ field("access_token"),
+ field("refresh_token"),
+ field("client_id"),
+ field("client_secret"),
+ ],
+ },
+ ProfileSchema {
+ name: "fs",
+ fields: &[field("root"), field("atomic_write_dir")],
+ },
+ ProfileSchema {
+ name: "gcs",
+ fields: &[
+ field("root"),
+ required_field("bucket"),
+ field("endpoint"),
+ field("scope"),
+ field("service_account"),
+ field("credential"),
+ field("credential_path"),
+ field("predefined_acl"),
+ field("default_storage_class"),
+ bool_field("allow_anonymous"),
+ bool_field("disable_vm_metadata"),
+ bool_field("disable_config_load"),
+ field("token"),
+ ],
+ },
+ ProfileSchema {
+ name: "ghac",
+ fields: &[
+ field("root"),
+ field("version"),
+ field("endpoint"),
+ field("runtime_token"),
+ ],
+ },
+ ProfileSchema {
+ name: "http",
+ fields: &[
+ field("endpoint"),
+ field("username"),
+ field("password"),
+ field("token"),
+ field("root"),
+ ],
+ },
+ ProfileSchema {
+ name: "ipmfs",
+ fields: &[field("root"), field("endpoint")],
+ },
+ ProfileSchema {
+ name: "memory",
+ fields: &[field("root")],
+ },
+ ProfileSchema {
+ name: "obs",
+ fields: &[
+ field("root"),
+ field("endpoint"),
+ field("access_key_id"),
+ field("secret_access_key"),
+ field("bucket"),
+ bool_field("enable_versioning"),
+ ],
+ },
+ ProfileSchema {
Review Comment:
It looks like we have to maintain a long list for every service, which
doesn’t seem very manageable. Can we derive it directly from the parameter
mapping?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]