/
graphgroup.go
84 lines (60 loc) · 1.83 KB
/
graphgroup.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package gaia
import (
"fmt"
"github.com/mitchellh/copystructure"
"go.aporeto.io/elemental"
)
// GraphGroup represents the model of a graphgroup
type GraphGroup struct {
// Identifier of the group.
ID string `json:"ID" msgpack:"ID" bson:"-" mapstructure:"ID,omitempty"`
// Color to use for the group.
Color string `json:"color" msgpack:"color" bson:"-" mapstructure:"color,omitempty"`
// List of tags that were used to create this group.
Match [][]string `json:"match" msgpack:"match" bson:"-" mapstructure:"match,omitempty"`
// Name of the group.
Name string `json:"name" msgpack:"name" bson:"-" mapstructure:"name,omitempty"`
// ID of the parent group, if any.
ParentID string `json:"parentID" msgpack:"parentID" bson:"-" mapstructure:"parentID,omitempty"`
ModelVersion int `json:"-" msgpack:"-" bson:"_modelversion"`
}
// NewGraphGroup returns a new *GraphGroup
func NewGraphGroup() *GraphGroup {
return &GraphGroup{
ModelVersion: 1,
Match: [][]string{},
}
}
// BleveType implements the bleve.Classifier Interface.
func (o *GraphGroup) BleveType() string {
return "graphgroup"
}
// DeepCopy returns a deep copy if the GraphGroup.
func (o *GraphGroup) DeepCopy() *GraphGroup {
if o == nil {
return nil
}
out := &GraphGroup{}
o.DeepCopyInto(out)
return out
}
// DeepCopyInto copies the receiver into the given *GraphGroup.
func (o *GraphGroup) DeepCopyInto(out *GraphGroup) {
target, err := copystructure.Copy(o)
if err != nil {
panic(fmt.Sprintf("Unable to deepcopy GraphGroup: %s", err))
}
*out = *target.(*GraphGroup)
}
// Validate valides the current information stored into the structure.
func (o *GraphGroup) Validate() error {
errors := elemental.Errors{}
requiredErrors := elemental.Errors{}
if len(requiredErrors) > 0 {
return requiredErrors
}
if len(errors) > 0 {
return errors
}
return nil
}