s3: Factor providers list out and auto generate textual version
This commit is contained in:
parent
9959712a06
commit
77ea22ac5b
1 changed files with 117 additions and 95 deletions
|
@ -62,29 +62,17 @@ import (
|
||||||
"golang.org/x/net/http/httpguts"
|
"golang.org/x/net/http/httpguts"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Register with Fs
|
// The S3 providers
|
||||||
func init() {
|
//
|
||||||
fs.Register(&fs.RegInfo{
|
// Please keep these in alphabetical order, but with AWS first and
|
||||||
Name: "s3",
|
// Other last.
|
||||||
Description: "Amazon S3 Compliant Storage Providers including AWS, Alibaba, ArvanCloud, Ceph, China Mobile, Cloudflare, GCS, DigitalOcean, Dreamhost, Huawei OBS, IBM COS, IDrive e2, IONOS Cloud, Leviia, Liara, Lyve Cloud, Minio, Netease, Petabox, RackCorp, Scaleway, SeaweedFS, StackPath, Storj, Synology, Tencent COS, Qiniu and Wasabi",
|
//
|
||||||
NewFs: NewFs,
|
// NB if you add a new provider here, then add it in the setQuirks
|
||||||
CommandHelp: commandHelp,
|
// function and set the correct quirks. Test the quirks are correct by
|
||||||
Config: func(ctx context.Context, name string, m configmap.Mapper, config fs.ConfigIn) (*fs.ConfigOut, error) {
|
// running the integration tests "go test -v -remote NewS3Provider:".
|
||||||
switch config.State {
|
var providerOption = fs.Option{
|
||||||
case "":
|
|
||||||
return nil, setEndpointValueForIDriveE2(m)
|
|
||||||
}
|
|
||||||
return nil, fmt.Errorf("unknown state %q", config.State)
|
|
||||||
},
|
|
||||||
MetadataInfo: &fs.MetadataInfo{
|
|
||||||
System: systemMetadataInfo,
|
|
||||||
Help: `User metadata is stored as x-amz-meta- keys. S3 metadata keys are case insensitive and are always returned in lower case.`,
|
|
||||||
},
|
|
||||||
Options: []fs.Option{{
|
|
||||||
Name: fs.ConfigProvider,
|
Name: fs.ConfigProvider,
|
||||||
Help: "Choose your S3 provider.",
|
Help: "Choose your S3 provider.",
|
||||||
// NB if you add a new provider here, then add it in the
|
|
||||||
// setQuirks function and set the correct quirks
|
|
||||||
Examples: []fs.OptionExample{{
|
Examples: []fs.OptionExample{{
|
||||||
Value: "AWS",
|
Value: "AWS",
|
||||||
Help: "Amazon Web Services (AWS) S3",
|
Help: "Amazon Web Services (AWS) S3",
|
||||||
|
@ -173,7 +161,41 @@ func init() {
|
||||||
Value: "Other",
|
Value: "Other",
|
||||||
Help: "Any other S3 compatible provider",
|
Help: "Any other S3 compatible provider",
|
||||||
}},
|
}},
|
||||||
}, {
|
}
|
||||||
|
|
||||||
|
var providersList string
|
||||||
|
|
||||||
|
// Register with Fs
|
||||||
|
func init() {
|
||||||
|
var s strings.Builder
|
||||||
|
for i, provider := range providerOption.Examples {
|
||||||
|
if provider.Value == "Other" {
|
||||||
|
_, _ = s.WriteString(" and others")
|
||||||
|
} else {
|
||||||
|
if i != 0 {
|
||||||
|
_, _ = s.WriteString(", ")
|
||||||
|
}
|
||||||
|
_, _ = s.WriteString(provider.Value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
providersList = s.String()
|
||||||
|
fs.Register(&fs.RegInfo{
|
||||||
|
Name: "s3",
|
||||||
|
Description: "Amazon S3 Compliant Storage Providers including " + providersList,
|
||||||
|
NewFs: NewFs,
|
||||||
|
CommandHelp: commandHelp,
|
||||||
|
Config: func(ctx context.Context, name string, m configmap.Mapper, config fs.ConfigIn) (*fs.ConfigOut, error) {
|
||||||
|
switch config.State {
|
||||||
|
case "":
|
||||||
|
return nil, setEndpointValueForIDriveE2(m)
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("unknown state %q", config.State)
|
||||||
|
},
|
||||||
|
MetadataInfo: &fs.MetadataInfo{
|
||||||
|
System: systemMetadataInfo,
|
||||||
|
Help: `User metadata is stored as x-amz-meta- keys. S3 metadata keys are case insensitive and are always returned in lower case.`,
|
||||||
|
},
|
||||||
|
Options: []fs.Option{providerOption, {
|
||||||
Name: "env_auth",
|
Name: "env_auth",
|
||||||
Help: "Get AWS credentials from runtime (environment variables or EC2/ECS meta data if no env vars).\n\nOnly applies if access_key_id and secret_access_key is blank.",
|
Help: "Get AWS credentials from runtime (environment variables or EC2/ECS meta data if no env vars).\n\nOnly applies if access_key_id and secret_access_key is blank.",
|
||||||
Default: false,
|
Default: false,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue