github.com/cs3org/reva/v2@v2.27.7/pkg/storage/fs/cephfs/options.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  //go:build ceph
    20  // +build ceph
    21  
    22  package cephfs
    23  
    24  import (
    25  	"path/filepath"
    26  
    27  	"github.com/cs3org/reva/v2/pkg/sharedconf"
    28  )
    29  
    30  // Options for the cephfs module
    31  type Options struct {
    32  	GatewaySvc   string `mapstructure:"gatewaysvc"`
    33  	IndexPool    string `mapstructure:"index_pool"`
    34  	Root         string `mapstructure:"root"`
    35  	ShadowFolder string `mapstructure:"shadow_folder"`
    36  	ShareFolder  string `mapstructure:"share_folder"`
    37  	UploadFolder string `mapstructure:"uploads"`
    38  	UserLayout   string `mapstructure:"user_layout"`
    39  
    40  	DisableHome    bool   `mapstructure:"disable_home"`
    41  	UserQuotaBytes uint64 `mapstructure:"user_quota_bytes"`
    42  	HiddenDirs     map[string]bool
    43  }
    44  
    45  func (c *Options) fillDefaults() {
    46  	c.GatewaySvc = sharedconf.GetGatewaySVC(c.GatewaySvc)
    47  
    48  	if c.IndexPool == "" {
    49  		c.IndexPool = "path_index"
    50  	}
    51  
    52  	if c.Root == "" {
    53  		c.Root = "/home"
    54  	} else {
    55  		c.Root = addLeadingSlash(c.Root) //force absolute path in case leading "/" is omitted
    56  	}
    57  
    58  	if c.ShadowFolder == "" {
    59  		c.ShadowFolder = "/.reva_hidden"
    60  	} else {
    61  		c.ShadowFolder = addLeadingSlash(c.ShadowFolder)
    62  	}
    63  
    64  	if c.ShareFolder == "" {
    65  		c.ShareFolder = "/Shares"
    66  	} else {
    67  		c.ShareFolder = addLeadingSlash(c.ShareFolder)
    68  	}
    69  
    70  	if c.UploadFolder == "" {
    71  		c.UploadFolder = ".uploads"
    72  	}
    73  	c.UploadFolder = filepath.Join(c.ShadowFolder, c.UploadFolder)
    74  
    75  	if c.UserLayout == "" {
    76  		c.UserLayout = "{{.Username}}"
    77  	}
    78  
    79  	c.HiddenDirs = map[string]bool{
    80  		".":                                true,
    81  		"..":                               true,
    82  		removeLeadingSlash(c.ShadowFolder): true,
    83  	}
    84  
    85  	c.DisableHome = false // it is currently only home based
    86  
    87  	if c.UserQuotaBytes == 0 {
    88  		c.UserQuotaBytes = 50000000000
    89  	}
    90  }