This repository has been archived by the owner on Jan 25, 2022. It is now read-only.
/
blob_store.go
58 lines (47 loc) · 1.59 KB
/
blob_store.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package blob_store
import (
"io"
"github.com/cloudfoundry-incubator/bbs/models"
"github.com/cloudfoundry-incubator/ltc/blob_store/blob"
"github.com/cloudfoundry-incubator/ltc/blob_store/dav_blob_store"
"github.com/cloudfoundry-incubator/ltc/blob_store/s3_blob_store"
config_package "github.com/cloudfoundry-incubator/ltc/config"
)
type BlobStore interface {
List() ([]blob.Blob, error)
Delete(path string) error
Upload(path string, contents io.ReadSeeker) error
Download(path string) (io.ReadCloser, error)
DropletStore
}
type DropletStore interface {
DownloadAppBitsAction(dropletName string) *models.Action
DeleteAppBitsAction(dropletName string) *models.Action
UploadDropletAction(dropletName string) *models.Action
DownloadDropletAction(dropletName string) *models.Action
}
type Verifier interface {
Verify(config *config_package.Config) (authorized bool, err error)
}
type BlobStoreVerifier struct {
DAVBlobStoreVerifier Verifier
S3BlobStoreVerifier Verifier
}
func New(config *config_package.Config) BlobStore {
switch config.ActiveBlobStore() {
case config_package.DAVBlobStore:
return dav_blob_store.New(config.BlobStore())
case config_package.S3BlobStore:
return s3_blob_store.New(config.S3BlobStore())
}
return dav_blob_store.New(config.BlobStore())
}
func (v BlobStoreVerifier) Verify(config *config_package.Config) (authorized bool, err error) {
switch config.ActiveBlobStore() {
case config_package.DAVBlobStore:
return v.DAVBlobStoreVerifier.Verify(config)
case config_package.S3BlobStore:
return v.S3BlobStoreVerifier.Verify(config)
}
panic("unknown blob store type")
}