-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugins.go
44 lines (37 loc) · 847 Bytes
/
plugins.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
/*
* Copyright (c) 2022-2024 Mikhail Knyazhev <markus621@yandex.com>. All rights reserved.
* Use of this source code is governed by a BSD 3-Clause license that can be found in the LICENSE file.
*/
package plugins
type (
// Plugin plugin structure
Plugin struct {
Config interface{}
Inject interface{}
Resolve interface{}
}
Plugins []Plugin
)
func (p Plugins) Inject(list ...interface{}) Plugins {
for _, vv := range list {
switch v := vv.(type) {
case Plugins:
p = append(p, v...)
case Plugin:
p = append(p, v)
default:
p = append(p, Plugin{Inject: vv})
}
}
return p
}
func Inject(list ...interface{}) Plugins {
return Plugins{}.Inject(list...)
}
// Defaulter interface for setting default values for a structure
type Defaulter interface {
Default()
}
type Validator interface {
Validate() error
}