aboutsummaryrefslogtreecommitdiff
path: root/storage/cloud
diff options
context:
space:
mode:
authorLaria Carolin Chabowski <laria@laria.me>2017-10-02 14:26:26 +0200
committerLaria Carolin Chabowski <laria@laria.me>2017-10-03 15:01:38 +0200
commitdb0c023fd0d756912c3f575c6ac65e99fda573cc (patch)
treef5e507c519f591e401fbb46bb77118d252b37612 /storage/cloud
parent7f0771d0a9caf2d3294bfced9e66fac03334d9ba (diff)
downloadpetrific-db0c023fd0d756912c3f575c6ac65e99fda573cc.tar.gz
petrific-db0c023fd0d756912c3f575c6ac65e99fda573cc.tar.bz2
petrific-db0c023fd0d756912c3f575c6ac65e99fda573cc.zip
Add filter storage method
Also remove de/encryption in cloud storage, can be provided with a filter storage
Diffstat (limited to 'storage/cloud')
-rw-r--r--storage/cloud/cloudstorage.go42
1 files changed, 5 insertions, 37 deletions
diff --git a/storage/cloud/cloudstorage.go b/storage/cloud/cloudstorage.go
index 261a034..f93bb5c 100644
--- a/storage/cloud/cloudstorage.go
+++ b/storage/cloud/cloudstorage.go
@@ -5,7 +5,6 @@ package cloud
import (
"bytes"
"code.laria.me/petrific/config"
- "code.laria.me/petrific/gpg"
"code.laria.me/petrific/objects"
"code.laria.me/petrific/storage"
"errors"
@@ -27,22 +26,9 @@ var (
NotFoundErr = errors.New("Object not found") // Cloud object could not be found
)
-// Crypter provides de-/encrypting facilities for CloudBasedObjectStorage
-type Crypter interface {
- Encrypt([]byte) ([]byte, error)
- Decrypt([]byte) ([]byte, error)
-}
-
-// NopCrypter implements Crypter by not de/-encrypting at all
-type NopCrypter struct{}
-
-func (NopCrypter) Encrypt(in []byte) ([]byte, error) { return in, nil }
-func (NopCrypter) Decrypt(in []byte) ([]byte, error) { return in, nil }
-
type CloudBasedObjectStorage struct {
- CS CloudStorage
- Prefix string
- Crypter Crypter
+ CS CloudStorage
+ Prefix string
index storage.Index
}
@@ -94,24 +80,14 @@ func (cbos *CloudBasedObjectStorage) Init() error {
}
func (cbos CloudBasedObjectStorage) Get(id objects.ObjectId) ([]byte, error) {
- b, err := cbos.CS.Get(cbos.objidToKey(id))
- if err != nil {
- return []byte{}, err
- }
-
- return cbos.Crypter.Decrypt(b)
+ return cbos.CS.Get(cbos.objidToKey(id))
}
func (cbos CloudBasedObjectStorage) Has(id objects.ObjectId) (bool, error) {
return cbos.CS.Has(cbos.objidToKey(id))
}
-func (cbos CloudBasedObjectStorage) Set(id objects.ObjectId, typ objects.ObjectType, raw []byte) error {
- b, err := cbos.Crypter.Encrypt(raw)
- if err != nil {
- return err
- }
-
+func (cbos CloudBasedObjectStorage) Set(id objects.ObjectId, typ objects.ObjectType, b []byte) error {
if err := cbos.CS.Put(cbos.objidToKey(id), b); err != nil {
return err
}
@@ -159,8 +135,7 @@ func cloudStorageCreator(cloudCreator cloudObjectStorageCreator) storage.CreateS
var cbos CloudBasedObjectStorage
var storageconf struct {
- Prefix string `toml:"prefix,omitempty"`
- EncryptFor string `toml:"encrypt_for,omitempty"`
+ Prefix string `toml:"prefix,omitempty"`
}
if err := conf.GetStorageConfData(name, &storageconf); err != nil {
@@ -169,13 +144,6 @@ func cloudStorageCreator(cloudCreator cloudObjectStorageCreator) storage.CreateS
cbos.Prefix = storageconf.Prefix
- if storageconf.EncryptFor != "" {
- cbos.Crypter = gpg.Crypter{
- gpg.Encrypter{Key: storageconf.EncryptFor},
- gpg.Decrypter{},
- }
- }
-
var err error
if cbos.CS, err = cloudCreator(conf, name); err != nil {
return nil, err