github.com/cs3org/reva/v2@v2.27.7/pkg/storage/fs/eos/eos.go (about) 1 // Copyright 2018-2021 CERN 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 // 15 // In applying this license, CERN does not waive the privileges and immunities 16 // granted to it by virtue of its status as an Intergovernmental Organization 17 // or submit itself to any jurisdiction. 18 19 package eos 20 21 import ( 22 "github.com/cs3org/reva/v2/pkg/events" 23 "github.com/cs3org/reva/v2/pkg/storage" 24 "github.com/cs3org/reva/v2/pkg/storage/fs/registry" 25 "github.com/cs3org/reva/v2/pkg/storage/utils/eosfs" 26 "github.com/mitchellh/mapstructure" 27 "github.com/pkg/errors" 28 "github.com/rs/zerolog" 29 ) 30 31 func init() { 32 registry.Register("eos", New) 33 } 34 35 func parseConfig(m map[string]interface{}) (*eosfs.Config, error) { 36 c := &eosfs.Config{} 37 if err := mapstructure.Decode(m, c); err != nil { 38 err = errors.Wrap(err, "error decoding conf") 39 return nil, err 40 } 41 42 // default to version invariance if not configured 43 if _, ok := m["version_invariant"]; !ok { 44 c.VersionInvariant = true 45 } 46 47 return c, nil 48 } 49 50 // New returns a new implementation of the storage.FS interface that connects to EOS. 51 func New(m map[string]interface{}, _ events.Stream, _ *zerolog.Logger) (storage.FS, error) { 52 c, err := parseConfig(m) 53 if err != nil { 54 return nil, err 55 } 56 57 return eosfs.NewEOSFS(c) 58 }