diff options
author | Laria Carolin Chabowski <laria@laria.me> | 2017-10-02 14:26:26 +0200 |
---|---|---|
committer | Laria Carolin Chabowski <laria@laria.me> | 2017-10-03 15:01:38 +0200 |
commit | db0c023fd0d756912c3f575c6ac65e99fda573cc (patch) | |
tree | f5e507c519f591e401fbb46bb77118d252b37612 /storage/registry/filter_conf.go | |
parent | 7f0771d0a9caf2d3294bfced9e66fac03334d9ba (diff) | |
download | petrific-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/registry/filter_conf.go')
-rw-r--r-- | storage/registry/filter_conf.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/storage/registry/filter_conf.go b/storage/registry/filter_conf.go new file mode 100644 index 0000000..593f238 --- /dev/null +++ b/storage/registry/filter_conf.go @@ -0,0 +1,39 @@ +package registry + +import ( + "code.laria.me/petrific/config" + "code.laria.me/petrific/storage" + "code.laria.me/petrific/storage/filter" +) + +// Unlike the other storage engines, we can not define FilterStorages +// *FromConfig function in the package itself, because we need to reference the +// registry package and circular imports are not allowed + +func filterStorageFromConfig(conf config.Config, name string) (storage.Storage, error) { + var storage_conf struct { + Base string + Encode []string + Decode []string + } + + if err := conf.GetStorageConfData(name, &storage_conf); err != nil { + return nil, err + } + + base, err := LoadStorage(conf, storage_conf.Base) + if err != nil { + return nil, err + } + + st := filter.FilterStorage{Base: base} + + if len(storage_conf.Encode) > 0 { + st.Encode = filter.PipeFilter(storage_conf.Encode) + } + if len(storage_conf.Decode) > 0 { + st.Decode = filter.PipeFilter(storage_conf.Decode) + } + + return st, nil +} |