-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
239 additions
and
99 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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package common | ||
|
||
import ( | ||
"path/filepath" | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
// ClientType is a mount client type | ||
type ClientType string | ||
|
||
// mount driver (iRODS Client) types | ||
const ( | ||
// IrodsFuseClientType is for iRODS FUSE | ||
IrodsFuseClientType ClientType = "irodsfuse" | ||
// WebdavClientType is for WebDav client (Davfs2) | ||
WebdavClientType ClientType = "webdav" | ||
// NfsClientType is for NFS client | ||
NfsClientType ClientType = "nfs" | ||
) | ||
|
||
// GetClientType returns iRODS Client value from param map | ||
func GetClientType(params map[string]string) ClientType { | ||
return GetValidClientType(params["client"]) | ||
} | ||
|
||
// IsValidClientType checks if given client string is valid | ||
func IsValidClientType(client string) bool { | ||
switch client { | ||
case string(IrodsFuseClientType): | ||
return true | ||
case string(WebdavClientType): | ||
return true | ||
case string(NfsClientType): | ||
return true | ||
default: | ||
return false | ||
} | ||
} | ||
|
||
// GetValidClientType checks if given client string is valid | ||
func GetValidClientType(client string) ClientType { | ||
switch client { | ||
case string(IrodsFuseClientType): | ||
return IrodsFuseClientType | ||
case string(WebdavClientType): | ||
return WebdavClientType | ||
case string(NfsClientType): | ||
return NfsClientType | ||
default: | ||
return IrodsFuseClientType | ||
} | ||
} | ||
|
||
// GetConfigEnforceProxyAccess checks if proxy access is enforced via driver config | ||
func GetConfigEnforceProxyAccess(configs map[string]string) bool { | ||
enforce := configs["enforceproxyaccess"] | ||
bEnforce, _ := strconv.ParseBool(enforce) | ||
return bEnforce | ||
} | ||
|
||
// GetConfigMountPathWhitelist returns a whitelist of collections that users can mount | ||
func GetConfigMountPathWhitelist(configs map[string]string) []string { | ||
whitelist := configs["mountpathwhitelist"] | ||
|
||
whitelistItems := strings.Split(whitelist, ",") | ||
if len(whitelistItems) > 0 { | ||
for idx := range whitelistItems { | ||
whitelistItems[idx] = strings.TrimSpace(whitelistItems[idx]) | ||
} | ||
return whitelistItems | ||
} | ||
|
||
return []string{"/"} | ||
} | ||
|
||
// GetConfigDataRootPath returns a data root path | ||
func GetConfigDataRootPath(configs map[string]string, volID string) string { | ||
irodsClientType := GetClientType(configs) | ||
return filepath.Join(configs["storagepath"], string(irodsClientType), volID) | ||
} |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package webdav | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"strings" | ||
) | ||
|
||
type DavFSConfig struct { | ||
Params map[string]string | ||
} | ||
|
||
// NewDefaultDavFSConfig creates default DavFS config map | ||
func NewDefaultDavFSConfig() *DavFSConfig { | ||
return &DavFSConfig{ | ||
Params: map[string]string{}, | ||
} | ||
} | ||
|
||
func (config *DavFSConfig) AddParam(key string, value string) { | ||
config.Params[key] = value | ||
} | ||
|
||
func (config *DavFSConfig) AddParams(params map[string]string) { | ||
for k, v := range params { | ||
config.Params[k] = v | ||
} | ||
} | ||
|
||
func (config *DavFSConfig) SaveToFile(name string) error { | ||
sb := strings.Builder{} | ||
|
||
for k, v := range config.Params { | ||
sb.WriteString(fmt.Sprintf("%s %s\n", k, v)) | ||
} | ||
|
||
return os.WriteFile(name, []byte(sb.String()), 0o664) | ||
} |
Oops, something went wrong.