/
inputinclude.go
53 lines (40 loc) · 1.21 KB
/
inputinclude.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 cfg
import (
"github.com/simplesurance/baur/v2/internal/deepcopy"
)
// InputInclude is a reusable Input definition.
type InputInclude struct {
IncludeID string `toml:"include_id" comment:"identifier of the include"`
Files []FileInputs
GolangSources []GolangSources `comment:"Inputs specified by resolving dependencies of Golang source files or packages."`
filepath string
}
func (in *InputInclude) fileInputs() []FileInputs {
return in.Files
}
func (in *InputInclude) golangSourcesInputs() []GolangSources {
return in.GolangSources
}
func (in *InputInclude) IsEmpty() bool {
return len(in.Files) == 0 && len(in.GolangSources) == 0
}
// validate checks if the stored information is valid.
func (in *InputInclude) validate() error {
if err := validateIncludeID(in.IncludeID); err != nil {
if in.IncludeID != "" {
err = fieldErrorWrap(err, in.IncludeID)
}
return err
}
if in.IsEmpty() {
return nil
}
return inputValidate(in)
}
func (in *InputInclude) clone() *InputInclude {
var clone InputInclude
deepcopy.MustCopy(in, &clone)
// filepath is assigned manually because filepath is a private field, MustCopy() only clones exported fields
clone.filepath = in.filepath
return &clone
}