-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restructure to allow import of protobuf API with minimal dependencies
and also for selective import of storage backends - massively reducing input tree for dependees. Signed-off-by: Silas Davis <[email protected]>
- Loading branch information
Silas Davis
committed
May 24, 2019
1 parent
ae90c85
commit a50cde4
Showing
57 changed files
with
548 additions
and
546 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
###Fixed | ||
- [BUILD] Change hoard.pb.go to services/services.pb.go | ||
- [BUILD] Change hoard.pb.go to services/api.pb.go | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package main | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
|
||
"github.com/go-kit/kit/log" | ||
"github.com/monax/hoard/v4/config" | ||
"github.com/monax/hoard/v4/stores" | ||
"github.com/monax/hoard/v4/stores/cloud" | ||
"github.com/monax/hoard/v4/stores/ipfs" | ||
) | ||
|
||
func StoreFromStorageConfig(storageConfig *config.Storage, logger log.Logger) (stores.NamedStore, error) { | ||
addressEncoding, err := stores.GetAddressEncoding(storageConfig.AddressEncoding) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
switch storageConfig.StorageType { | ||
case config.Memory, config.Unspecified: | ||
return stores.NewMemoryStore(), nil | ||
|
||
case config.Filesystem: | ||
fsConf := storageConfig.FileSystemConfig | ||
if fsConf == nil { | ||
return nil, errors.New("filesystem storage configuration must be " + | ||
"supplied to use the filesystem storage backend") | ||
} | ||
if fsConf.RootDirectory == "" { | ||
return nil, errors.New("rootDirectory key must be non-empty in " + "filesystem storage") | ||
|
||
} | ||
return stores.NewFileSystemStore(fsConf.RootDirectory, addressEncoding) | ||
|
||
case config.IPFS: | ||
ipfsConf := storageConfig.IPFSConfig | ||
if ipfsConf == nil { | ||
return nil, errors.New("IPFS storage configuration must be " + | ||
"supplied to use the filesystem storage backend") | ||
} | ||
if ipfsConf.RemoteAPI == "" { | ||
return nil, errors.New("http api url must be non-empty in " + | ||
"ipfs storage config") | ||
} | ||
return ipfs.NewStore(ipfsConf.RemoteAPI, addressEncoding) | ||
|
||
case config.AWS: | ||
awsConf := storageConfig.Cloud | ||
if awsConf == nil { | ||
return nil, errors.New("aws configuration must be supplied") | ||
} | ||
return cloud.NewStore(cloud.AWS, awsConf.Bucket, awsConf.Prefix, awsConf.Region, addressEncoding, logger) | ||
|
||
case config.Azure: | ||
azureConf := storageConfig.Cloud | ||
if azureConf == nil { | ||
return nil, errors.New("azure configuration must be supplied") | ||
} | ||
return cloud.NewStore(cloud.Azure, azureConf.Bucket, azureConf.Prefix, azureConf.Region, addressEncoding, logger) | ||
|
||
case config.GCP: | ||
gcpConf := storageConfig.Cloud | ||
if gcpConf == nil { | ||
return nil, errors.New("gcp configuration must be supplied") | ||
} | ||
return cloud.NewStore(cloud.GCP, gcpConf.Bucket, gcpConf.Prefix, gcpConf.Region, addressEncoding, logger) | ||
|
||
default: | ||
return nil, fmt.Errorf("did not recognise storage type '%s'", | ||
storageConfig.StorageType) | ||
} | ||
} |
Oops, something went wrong.