-
Notifications
You must be signed in to change notification settings - Fork 15
/
types.go
57 lines (48 loc) · 1.58 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
package crossplane
type Payload struct {
Status string `json:"status"`
Errors []PayloadError `json:"errors"`
Config []Config `json:"config"`
}
type PayloadError struct {
File string `json:"file"`
Line *int `json:"line"`
Error string `json:"error"`
Callback interface{} `json:"callback,omitempty"`
}
type Config struct {
File string `json:"file"`
Status string `json:"status"`
Errors []ConfigError `json:"errors"`
Parsed []Directive `json:"parsed"`
}
type ConfigError struct {
Line *int `json:"line"`
Error string `json:"error"`
}
type Directive struct {
Directive string `json:"directive"`
Line int `json:"line"`
Args []string `json:"args"`
Includes *[]int `json:"includes,omitempty"`
Block *[]Directive `json:"block,omitempty"`
Comment *string `json:"comment,omitempty"`
}
// IsBlock returns true if this is a block directive.
func (d Directive) IsBlock() bool {
return d.Block != nil
}
// IsInclude returns true if this is an include directive.
func (d Directive) IsInclude() bool {
return d.Directive == "include" && d.Includes != nil
}
// IsComment returns true iff the directive represents a comment.
func (d Directive) IsComment() bool {
return d.Directive == "#" && d.Comment != nil
}
// Combined returns a new Payload that is the same except that the inluding
// logic is performed on its configs. This means that the resulting Payload
// will always have 0 or 1 configs in its Config field.
func (p Payload) Combined() (*Payload, error) {
return combineConfigs(p)
}