forked from meltwater/drone-cache
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoption.go
48 lines (39 loc) · 872 Bytes
/
option.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
package cache
import (
"compress/flate"
)
const (
DefaultCompressionLevel = flate.DefaultCompression
DefaultArchiveFormat = "tar"
)
type options struct {
archiveFmt string
compressionLevel int
skipSymlinks bool
}
// Option overrides behavior of Cache.
type Option interface {
apply(*options)
}
type optionFunc func(*options)
func (f optionFunc) apply(o *options) {
f(o)
}
// WithSkipSymlinks sets skip symlink option.
func WithSkipSymlinks(b bool) Option {
return optionFunc(func(o *options) {
o.skipSymlinks = b
})
}
// WithArchiveFormat sets archive format option.
func WithArchiveFormat(s string) Option {
return optionFunc(func(o *options) {
o.archiveFmt = s
})
}
// WithCompressionLevel sets compression level option.
func WithCompressionLevel(i int) Option {
return optionFunc(func(o *options) {
o.compressionLevel = i
})
}