-
Notifications
You must be signed in to change notification settings - Fork 2
/
filesystem.go
51 lines (46 loc) · 1.4 KB
/
filesystem.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import "fmt"
type FileSystem struct {
CacheDirectory string `docs:"/var/tmp/;Path of cache directory"`
EnableLogging bool `docs:"false;Whether to enable logging"`
AvailableChecksums []string `docs:"[adler, rabin];The list of checksums provided by the file system"`
// Configs for various metadata drivers
DriverConfig map[string]map[string]interface{} `docs:"{json:{encoding: UTF8}, xml:{encoding: ASCII}}"`
// Config for the HTTP uploads service
Uploads *UploadConfig `docs:"&UploadConfig{HTTPPrefix: uploads, DisableTus: false}"`
}
type UploadConfig struct {
// Whether to disable TUS protocol for uploads.
DisableTus bool `json:"disable_tus" docs:"false"`
// The prefix at which the uploads service should be exposed.
HTTPPrefix string `json:"http_prefix" docs:"uploads"`
}
func (fs FileSystem) init() {
if fs.CacheDirectory == "" {
fs.CacheDirectory = "/var/tmp/"
}
if len(fs.AvailableChecksums) == 0 {
fs.AvailableChecksums = []string{"adler", "rabin"}
}
if fs.DriverConfig == nil {
fs.DriverConfig = map[string]map[string]interface{}{
"json": map[string]interface{}{
"encoding": "UTF8",
},
"xml": map[string]interface{}{
"encoding": "ASCII",
},
}
}
if fs.Uploads == nil {
fs.Uploads = &UploadConfig{
HTTPPrefix: "uploads",
}
}
}
func main() {
fs := FileSystem{
AvailableChecksums: []string{"adler32"},
}
fmt.Printf("FileSystem: %+v", fs)
}