Skip to content

Commit

Permalink
feat: add selector for the endpoint by the eplist #84
Browse files Browse the repository at this point in the history
  • Loading branch information
saltbo committed Jun 14, 2021
1 parent a122ca0 commit 0db0d14
Show file tree
Hide file tree
Showing 73 changed files with 80 additions and 69 deletions.
1 change: 1 addition & 0 deletions internal/app/model/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type Storage struct {
Bucket string `json:"bucket" gorm:"size:32;not null"`
Provider string `json:"provider" gorm:"size:8;not null"`
Endpoint string `json:"endpoint" gorm:"size:128;not null"`
Region string `json:"region" gorm:"size:128;not null"`
AccessKey string `json:"access_key" gorm:"size:64;not null"`
SecretKey string `json:"secret_key" gorm:"size:64;not null"`
CustomHost string `json:"custom_host" gorm:"size:128;not null"`
Expand Down
1 change: 1 addition & 0 deletions internal/app/service/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func (s *Storage) Create(storage *model.Storage) error {
Provider: storage.Provider,
Bucket: storage.Bucket,
Endpoint: storage.Endpoint,
Region: storage.Region,
CustomHost: storage.CustomHost,
AccessKey: storage.AccessKey,
AccessSecret: storage.SecretKey,
Expand Down
2 changes: 2 additions & 0 deletions internal/pkg/bind/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type StorageBody struct {
Bucket string `json:"bucket" binding:"required"`
Provider string `json:"provider" binding:"required"`
Endpoint string `json:"endpoint" binding:"required"`
Region string `json:"region"`
AccessKey string `json:"access_key" binding:"required"`
SecretKey string `json:"secret_key" binding:"required"`
Title string `json:"title"`
Expand All @@ -38,6 +39,7 @@ func (b *StorageBody) Model() *model.Storage {
Bucket: ts(b.Bucket),
Provider: b.Provider,
Endpoint: ts(b.Endpoint),
Region: ts(b.Region),
CustomHost: ts(b.CustomHost),
AccessKey: ts(b.AccessKey),
SecretKey: ts(b.SecretKey),
Expand Down
5 changes: 5 additions & 0 deletions internal/pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type Config struct {
Provider string
Bucket string
Endpoint string
Region string
CustomHost string
AccessKey string
AccessSecret string
Expand All @@ -46,6 +47,10 @@ var supportProviders = map[string]Constructor{
}

func New(conf Config) (Provider, error) {
if conf.Region == "" {
conf.Region = "auto"
}

constructor, ok := supportProviders[strings.ToUpper(conf.Provider)]
if !ok {
return nil, fmt.Errorf("provider %s not found", conf.Provider)
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/provider/provider_cos.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/tencentyun/cos-go-sdk-v5"
)

// 腾讯云
// COSProvider 腾讯云
type COSProvider struct {
S3Provider

Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/provider/provider_kodo.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/aliyun/aliyun-oss-go-sdk/oss"
)

// 七牛云
// KODOProvider 七牛云
type KODOProvider struct {
S3Provider

Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/provider/provider_minio.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/aliyun/aliyun-oss-go-sdk/oss"
)

// MinIO
// MINIOProvider MinIO
type MINIOProvider struct {
S3Provider

Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/provider/provider_nos.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/NetEase-Object-Storage/nos-golang-sdk/nosclient"
)

// 网易云
// NOSProvider 网易云
type NOSProvider struct {
S3Provider

Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/provider/provider_obs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/saltbo/zpan/pkg/obs"
)

// 华为云
// OBSProvider 华为云
type OBSProvider struct {
S3Provider

Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/provider/provider_oss.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/aliyun/aliyun-oss-go-sdk/oss"
)

// 阿里云
// OSSProvider 阿里云
type OSSProvider struct {
S3Provider

Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/provider/provider_s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func newS3Provider(conf Config) (*S3Provider, error) {
return nil, err
}

client := s3.New(s, cfg.WithRegion("auto"), cfg.WithEndpoint(conf.Endpoint))
client := s3.New(s, cfg.WithRegion(conf.Region), cfg.WithEndpoint(conf.Endpoint))
if conf.CustomHost != "" {
cURL, err := url.Parse(conf.CustomHost)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/provider/provider_us3.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/aliyun/aliyun-oss-go-sdk/oss"
)

// UCloud
// US3Provider UCloud
type US3Provider struct {
S3Provider

Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/provider/provider_uss.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/upyun/go-sdk/v3/upyun"
)

// 又拍云
// USSProvider 又拍云
type USSProvider struct {
client *upyun.UpYun
}
Expand Down
2 changes: 1 addition & 1 deletion web/dist/404.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html lang=zh-CN><head><title>ZPan</title><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"><link rel=icon href=data:image/ico;base64,aWNv><link href=/css/chunk-141f1d87.09f4af54.css rel=prefetch><link href=/css/chunk-14d2e418.95c79dda.css rel=prefetch><link href=/css/chunk-22dece4e.1d3af35b.css rel=prefetch><link href=/css/chunk-26cc1f8f.a0ccf9af.css rel=prefetch><link href=/css/chunk-32916612.de3dfbbd.css rel=prefetch><link href=/css/chunk-3745c98b.5e5cc2d9.css rel=prefetch><link href=/css/chunk-391c7ca2.4537606f.css rel=prefetch><link href=/css/chunk-45cef788.9856c3c5.css rel=prefetch><link href=/css/chunk-4fae512a.09f4af54.css rel=prefetch><link href=/css/chunk-54185f58.0568edce.css rel=prefetch><link href=/css/chunk-5ace7ddd.c4f9a7a6.css rel=prefetch><link href=/css/chunk-5c753fc6.0c7d8b3b.css rel=prefetch><link href=/css/chunk-5db82f0c.1d3af35b.css rel=prefetch><link href=/css/chunk-a9f37876.ea6c9abb.css rel=prefetch><link href=/css/chunk-b7a527f0.6a417862.css rel=prefetch><link href=/css/chunk-fb0da912.e0c7d8aa.css rel=prefetch><link href=/js/chunk-141f1d87.10a20f61.js rel=prefetch><link href=/js/chunk-14d2e418.700c6720.js rel=prefetch><link href=/js/chunk-22dece4e.848b52d5.js rel=prefetch><link href=/js/chunk-26cc1f8f.c76cbb92.js rel=prefetch><link href=/js/chunk-2d0a4fde.7ec55408.js rel=prefetch><link href=/js/chunk-2d0afa39.b9da666a.js rel=prefetch><link href=/js/chunk-2d0bce73.aedb4f0b.js rel=prefetch><link href=/js/chunk-2d0c5700.2daeca86.js rel=prefetch><link href=/js/chunk-2d0d76a6.316f54fb.js rel=prefetch><link href=/js/chunk-2d0daeb3.2e2a4703.js rel=prefetch><link href=/js/chunk-2d207759.34442d66.js rel=prefetch><link href=/js/chunk-32916612.cc19a6c1.js rel=prefetch><link href=/js/chunk-3745c98b.1fe98723.js rel=prefetch><link href=/js/chunk-391c7ca2.7a3016ca.js rel=prefetch><link href=/js/chunk-45cef788.0d128fbd.js rel=prefetch><link href=/js/chunk-4fae512a.2b114c38.js rel=prefetch><link href=/js/chunk-54185f58.72adcd7a.js rel=prefetch><link href=/js/chunk-5ace7ddd.3727561f.js rel=prefetch><link href=/js/chunk-5c753fc6.670b0f7f.js rel=prefetch><link href=/js/chunk-5db82f0c.c033762d.js rel=prefetch><link href=/js/chunk-a9f37876.d98e15d0.js rel=prefetch><link href=/js/chunk-b7a527f0.8c77ddf6.js rel=prefetch><link href=/js/chunk-c39e5b9a.e60b8b38.js rel=prefetch><link href=/js/chunk-fb0da912.03431740.js rel=prefetch><link href=/css/chunk-common.fd380bbd.css rel=preload as=style><link href=/css/chunk-vendors.0ddd2d7b.css rel=preload as=style><link href=/js/404.8ba9f6fa.js rel=preload as=script><link href=/js/chunk-common.b6394f79.js rel=preload as=script><link href=/js/chunk-vendors.8e1decbe.js rel=preload as=script><link href=/css/chunk-vendors.0ddd2d7b.css rel=stylesheet><link href=/css/chunk-common.fd380bbd.css rel=stylesheet></head><body><div id=app></div><script src=/js/chunk-vendors.8e1decbe.js></script><script src=/js/chunk-common.b6394f79.js></script><script src=/js/index.9fabb557.js></script></body></html>
<!DOCTYPE html><html lang=zh-CN><head><title>ZPan</title><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"><link rel=icon href=data:image/ico;base64,aWNv><link href=/css/chunk-141f1d87.09f4af54.css rel=prefetch><link href=/css/chunk-14d2e418.95c79dda.css rel=prefetch><link href=/css/chunk-22dece4e.1d3af35b.css rel=prefetch><link href=/css/chunk-26cc1f8f.a0ccf9af.css rel=prefetch><link href=/css/chunk-32916612.de3dfbbd.css rel=prefetch><link href=/css/chunk-3745c98b.5e5cc2d9.css rel=prefetch><link href=/css/chunk-391c7ca2.4537606f.css rel=prefetch><link href=/css/chunk-45cef788.9856c3c5.css rel=prefetch><link href=/css/chunk-4fae512a.09f4af54.css rel=prefetch><link href=/css/chunk-54185f58.0568edce.css rel=prefetch><link href=/css/chunk-5ace7ddd.c4f9a7a6.css rel=prefetch><link href=/css/chunk-5c753fc6.0c7d8b3b.css rel=prefetch><link href=/css/chunk-5db82f0c.1d3af35b.css rel=prefetch><link href=/css/chunk-a9f37876.ea6c9abb.css rel=prefetch><link href=/css/chunk-b7a527f0.6a417862.css rel=prefetch><link href=/css/chunk-fb0da912.e0c7d8aa.css rel=prefetch><link href=/js/chunk-141f1d87.a6e6d410.js rel=prefetch><link href=/js/chunk-14d2e418.9d85c0a7.js rel=prefetch><link href=/js/chunk-22dece4e.4004c054.js rel=prefetch><link href=/js/chunk-26cc1f8f.5d4b8039.js rel=prefetch><link href=/js/chunk-2d0a4fde.da1dd376.js rel=prefetch><link href=/js/chunk-2d0afa39.376e5298.js rel=prefetch><link href=/js/chunk-2d0bce73.554ba6c6.js rel=prefetch><link href=/js/chunk-2d0c5700.bb0164e0.js rel=prefetch><link href=/js/chunk-2d0d76a6.1a2c1728.js rel=prefetch><link href=/js/chunk-2d0daeb3.007e5916.js rel=prefetch><link href=/js/chunk-2d207759.9ebf29b5.js rel=prefetch><link href=/js/chunk-32916612.b107d109.js rel=prefetch><link href=/js/chunk-3745c98b.87545ec4.js rel=prefetch><link href=/js/chunk-391c7ca2.ec9ab1a8.js rel=prefetch><link href=/js/chunk-45cef788.fb25b3bd.js rel=prefetch><link href=/js/chunk-4fae512a.5ac645e3.js rel=prefetch><link href=/js/chunk-54185f58.2f80c1ea.js rel=prefetch><link href=/js/chunk-5ace7ddd.d52ad262.js rel=prefetch><link href=/js/chunk-5c753fc6.326b9aa7.js rel=prefetch><link href=/js/chunk-5db82f0c.571278cf.js rel=prefetch><link href=/js/chunk-a9f37876.7e467fd6.js rel=prefetch><link href=/js/chunk-b7a527f0.0b643bc2.js rel=prefetch><link href=/js/chunk-c39e5b9a.154700e5.js rel=prefetch><link href=/js/chunk-fb0da912.b4726624.js rel=prefetch><link href=/css/chunk-common.fd380bbd.css rel=preload as=style><link href=/css/chunk-vendors.0ddd2d7b.css rel=preload as=style><link href=/js/404.148ed303.js rel=preload as=script><link href=/js/chunk-common.1ac1ab4d.js rel=preload as=script><link href=/js/chunk-vendors.8e1decbe.js rel=preload as=script><link href=/css/chunk-vendors.0ddd2d7b.css rel=stylesheet><link href=/css/chunk-common.fd380bbd.css rel=stylesheet></head><body><div id=app></div><script src=/js/chunk-vendors.8e1decbe.js></script><script src=/js/chunk-common.1ac1ab4d.js></script><script src=/js/index.59995789.js></script></body></html>
2 changes: 1 addition & 1 deletion web/dist/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html lang=zh-CN><head><title>ZPan</title><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"><link rel=icon href=data:image/ico;base64,aWNv><link href=/css/chunk-141f1d87.09f4af54.css rel=prefetch><link href=/css/chunk-14d2e418.95c79dda.css rel=prefetch><link href=/css/chunk-22dece4e.1d3af35b.css rel=prefetch><link href=/css/chunk-26cc1f8f.a0ccf9af.css rel=prefetch><link href=/css/chunk-32916612.de3dfbbd.css rel=prefetch><link href=/css/chunk-3745c98b.5e5cc2d9.css rel=prefetch><link href=/css/chunk-391c7ca2.4537606f.css rel=prefetch><link href=/css/chunk-45cef788.9856c3c5.css rel=prefetch><link href=/css/chunk-4fae512a.09f4af54.css rel=prefetch><link href=/css/chunk-54185f58.0568edce.css rel=prefetch><link href=/css/chunk-5ace7ddd.c4f9a7a6.css rel=prefetch><link href=/css/chunk-5c753fc6.0c7d8b3b.css rel=prefetch><link href=/css/chunk-5db82f0c.1d3af35b.css rel=prefetch><link href=/css/chunk-a9f37876.ea6c9abb.css rel=prefetch><link href=/css/chunk-b7a527f0.6a417862.css rel=prefetch><link href=/css/chunk-fb0da912.e0c7d8aa.css rel=prefetch><link href=/js/chunk-141f1d87.10a20f61.js rel=prefetch><link href=/js/chunk-14d2e418.700c6720.js rel=prefetch><link href=/js/chunk-22dece4e.848b52d5.js rel=prefetch><link href=/js/chunk-26cc1f8f.c76cbb92.js rel=prefetch><link href=/js/chunk-2d0a4fde.7ec55408.js rel=prefetch><link href=/js/chunk-2d0afa39.b9da666a.js rel=prefetch><link href=/js/chunk-2d0bce73.aedb4f0b.js rel=prefetch><link href=/js/chunk-2d0c5700.2daeca86.js rel=prefetch><link href=/js/chunk-2d0d76a6.316f54fb.js rel=prefetch><link href=/js/chunk-2d0daeb3.2e2a4703.js rel=prefetch><link href=/js/chunk-2d207759.34442d66.js rel=prefetch><link href=/js/chunk-32916612.cc19a6c1.js rel=prefetch><link href=/js/chunk-3745c98b.1fe98723.js rel=prefetch><link href=/js/chunk-391c7ca2.7a3016ca.js rel=prefetch><link href=/js/chunk-45cef788.0d128fbd.js rel=prefetch><link href=/js/chunk-4fae512a.2b114c38.js rel=prefetch><link href=/js/chunk-54185f58.72adcd7a.js rel=prefetch><link href=/js/chunk-5ace7ddd.3727561f.js rel=prefetch><link href=/js/chunk-5c753fc6.670b0f7f.js rel=prefetch><link href=/js/chunk-5db82f0c.c033762d.js rel=prefetch><link href=/js/chunk-a9f37876.d98e15d0.js rel=prefetch><link href=/js/chunk-b7a527f0.8c77ddf6.js rel=prefetch><link href=/js/chunk-c39e5b9a.e60b8b38.js rel=prefetch><link href=/js/chunk-fb0da912.03431740.js rel=prefetch><link href=/css/chunk-common.fd380bbd.css rel=preload as=style><link href=/css/chunk-vendors.0ddd2d7b.css rel=preload as=style><link href=/js/chunk-common.b6394f79.js rel=preload as=script><link href=/js/chunk-vendors.8e1decbe.js rel=preload as=script><link href=/js/index.9fabb557.js rel=preload as=script><link href=/css/chunk-vendors.0ddd2d7b.css rel=stylesheet><link href=/css/chunk-common.fd380bbd.css rel=stylesheet></head><body><div id=app></div><script src=/js/chunk-vendors.8e1decbe.js></script><script src=/js/chunk-common.b6394f79.js></script><script src=/js/index.9fabb557.js></script></body></html>
<!DOCTYPE html><html lang=zh-CN><head><title>ZPan</title><meta charset=UTF-8><meta name=viewport content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0"><link rel=icon href=data:image/ico;base64,aWNv><link href=/css/chunk-141f1d87.09f4af54.css rel=prefetch><link href=/css/chunk-14d2e418.95c79dda.css rel=prefetch><link href=/css/chunk-22dece4e.1d3af35b.css rel=prefetch><link href=/css/chunk-26cc1f8f.a0ccf9af.css rel=prefetch><link href=/css/chunk-32916612.de3dfbbd.css rel=prefetch><link href=/css/chunk-3745c98b.5e5cc2d9.css rel=prefetch><link href=/css/chunk-391c7ca2.4537606f.css rel=prefetch><link href=/css/chunk-45cef788.9856c3c5.css rel=prefetch><link href=/css/chunk-4fae512a.09f4af54.css rel=prefetch><link href=/css/chunk-54185f58.0568edce.css rel=prefetch><link href=/css/chunk-5ace7ddd.c4f9a7a6.css rel=prefetch><link href=/css/chunk-5c753fc6.0c7d8b3b.css rel=prefetch><link href=/css/chunk-5db82f0c.1d3af35b.css rel=prefetch><link href=/css/chunk-a9f37876.ea6c9abb.css rel=prefetch><link href=/css/chunk-b7a527f0.6a417862.css rel=prefetch><link href=/css/chunk-fb0da912.e0c7d8aa.css rel=prefetch><link href=/js/chunk-141f1d87.a6e6d410.js rel=prefetch><link href=/js/chunk-14d2e418.9d85c0a7.js rel=prefetch><link href=/js/chunk-22dece4e.4004c054.js rel=prefetch><link href=/js/chunk-26cc1f8f.5d4b8039.js rel=prefetch><link href=/js/chunk-2d0a4fde.da1dd376.js rel=prefetch><link href=/js/chunk-2d0afa39.376e5298.js rel=prefetch><link href=/js/chunk-2d0bce73.554ba6c6.js rel=prefetch><link href=/js/chunk-2d0c5700.bb0164e0.js rel=prefetch><link href=/js/chunk-2d0d76a6.1a2c1728.js rel=prefetch><link href=/js/chunk-2d0daeb3.007e5916.js rel=prefetch><link href=/js/chunk-2d207759.9ebf29b5.js rel=prefetch><link href=/js/chunk-32916612.b107d109.js rel=prefetch><link href=/js/chunk-3745c98b.87545ec4.js rel=prefetch><link href=/js/chunk-391c7ca2.ec9ab1a8.js rel=prefetch><link href=/js/chunk-45cef788.fb25b3bd.js rel=prefetch><link href=/js/chunk-4fae512a.5ac645e3.js rel=prefetch><link href=/js/chunk-54185f58.2f80c1ea.js rel=prefetch><link href=/js/chunk-5ace7ddd.d52ad262.js rel=prefetch><link href=/js/chunk-5c753fc6.326b9aa7.js rel=prefetch><link href=/js/chunk-5db82f0c.571278cf.js rel=prefetch><link href=/js/chunk-a9f37876.7e467fd6.js rel=prefetch><link href=/js/chunk-b7a527f0.0b643bc2.js rel=prefetch><link href=/js/chunk-c39e5b9a.154700e5.js rel=prefetch><link href=/js/chunk-fb0da912.b4726624.js rel=prefetch><link href=/css/chunk-common.fd380bbd.css rel=preload as=style><link href=/css/chunk-vendors.0ddd2d7b.css rel=preload as=style><link href=/js/chunk-common.1ac1ab4d.js rel=preload as=script><link href=/js/chunk-vendors.8e1decbe.js rel=preload as=script><link href=/js/index.59995789.js rel=preload as=script><link href=/css/chunk-vendors.0ddd2d7b.css rel=stylesheet><link href=/css/chunk-common.fd380bbd.css rel=stylesheet></head><body><div id=app></div><script src=/js/chunk-vendors.8e1decbe.js></script><script src=/js/chunk-common.1ac1ab4d.js></script><script src=/js/index.59995789.js></script></body></html>
Loading

0 comments on commit 0db0d14

Please sign in to comment.