forked from foxis/EasyRobot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
53 lines (47 loc) · 1.04 KB
/
options.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
package writer
import (
"github.com/itohio/EasyRobot/pkg/core/options"
"github.com/itohio/EasyRobot/pkg/core/plugin"
"github.com/itohio/EasyRobot/pkg/core/store"
)
type writerOpts struct {
base plugin.Options
keys []store.FQDNType
prefix string
ext string
}
func WithKeyFirst(key store.FQDNType) options.Option {
return func(o interface{}) {
if opt, ok := o.(*writerOpts); ok {
opt.keys = []store.FQDNType{key}
}
}
}
func WithKey(key store.FQDNType) options.Option {
return func(o interface{}) {
if opt, ok := o.(*writerOpts); ok {
opt.keys = append(opt.keys, key)
}
}
}
func WithKeys(keys []store.FQDNType) options.Option {
return func(o interface{}) {
if opt, ok := o.(*writerOpts); ok {
opt.keys = append(opt.keys, keys...)
}
}
}
func WithPrefix(prefix string) options.Option {
return func(opt interface{}) {
if o, ok := opt.(*writerOpts); ok {
o.prefix = prefix
}
}
}
func WithExtension(ext string) options.Option {
return func(opt interface{}) {
if o, ok := opt.(*writerOpts); ok {
o.ext = ext
}
}
}