-
Notifications
You must be signed in to change notification settings - Fork 25
/
types.go
114 lines (102 loc) · 3.94 KB
/
types.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package config
import "regexp"
// Preset describe properties of transform preset
type Preset struct {
Quality int `yaml:"quality"`
Format string `yaml:"format"`
Filters struct {
Thumbnail *struct {
Width int `yaml:"width"`
Height int `yaml:"height"`
Mode string `yaml:"mode"`
} `yaml:"thumbnail,omitempty"`
Interlace bool `yaml:"interlace"`
Crop *struct {
Width int `yaml:"width"`
Height int `yaml:"height"`
Gravity string `yaml:"gravity"`
Mode string `yaml:"mode"`
} `yaml:"crop,omitempty"`
AutoRotate bool `yaml:"auto_rotate"`
Grayscale bool `yaml:"grayscale"`
Strip bool `yaml:"strip"`
Blur *struct {
Sigma float64 `yaml:"sigma"`
MinAmpl float64 `yaml:"minAmpl"`
} `yaml:"blur,omitempty"`
Watermark *struct {
Image string `yaml:"image"`
Position string `yaml:"position"`
Opacity float32 `yaml:"opacity"`
} `yaml:"watermark,omitempty"`
Rotate *struct {
Angle int `yaml:"angle"`
} `yaml:"rotate,omitempty"`
} `yaml:"filters"`
}
// Transform describe transform for bucket
type Transform struct {
Path string `yaml:"path"`
ParentStorage string `yaml:"parentStorage"`
ParentBucket string `yaml:"parentBucket"`
PathRegexp *regexp.Regexp
Kind string `yaml:"kind"`
Presets map[string]Preset `yaml:"presets"`
CheckParent bool `yaml:"checkParent"`
ResultKey string `yaml:"resultKey"`
}
// Storage contains information about kind of used storage
type Storage struct {
RootPath string `yaml:"rootPath,omitempty"` // root path for local-* storage
Kind string `yaml:"kind"` // type of storage from list ("local", "local-meta", "s3", "http", "noop")
Url string `yaml:"url,omitempty"` // Url for http storage
Headers map[string]string `yaml:"headers,omitempty"` // request headers for http storage
AccessKey string `yaml:"accessKey,omitempty"` // access key for s3 storage
SecretAccessKey string `yaml:"secretAccessKey,omitempty"` // SecretAccessKey for s3 storage
Region string `yaml:"region,omitempty"` // region for s3 storage
Endpoint string `yaml:"endpoint,omitempty"` // endpoint for s3 storage
PathPrefix string `yaml:"pathPrefix,omitempty"` // prefix in path for all storage
Bucket string `yaml:"bucket"`
Hash string // unique hash for given storage
}
// StorageTypes contains map of storage for bucket
type StorageTypes map[string]Storage
// Basic return storage that contains originals object
func (s *StorageTypes) Basic() Storage {
return s.Get("basic")
}
// Transform return strorage in which we should storage processed objects
func (s *StorageTypes) Transform() Storage {
return s.Get("transform")
}
// Get basic method for getting storage by name
func (s *StorageTypes) Get(name string) Storage {
return (*s)[name]
}
// S3Key define credentials for s3 auth
type S3Key struct {
AccessKey string `yaml:"accessKey"`
SecretAccessKey string `yaml:"secretAccessKey"`
}
// Bucket describe single bucket entry in config
type Bucket struct {
Transform *Transform `yaml:"transform,omitempty"`
Storages StorageTypes `yaml:"storages"`
Keys []S3Key `yaml:"keys"`
Name string
}
// HeaderYaml allow you to override response headers
type HeaderYaml struct {
StatusCodes []int `yaml:"statusCodes"`
Values map[string]string `yaml:"values"`
}
// Server configure HTTP server
type Server struct {
InternalListen string `yaml:"internalListen"`
SingleListen string `yaml:"listen"`
CacheSize int64 `yaml:"cacheSize"`
RequestTimeout int `yaml:"requestTimeout"`
QueueLen int `yaml:"queueLen"`
Listen []string `yaml:"listens"`
Monitoring string `yaml:"monitoring"`
}