/
tracemode.go
84 lines (61 loc) · 2.15 KB
/
tracemode.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"
)
// TraceMode represents the model of a tracemode
type TraceMode struct {
// Instructs the enforcers to provide an iptables trace for a processing unit.
IPTables bool `json:"IPTables" msgpack:"IPTables" bson:"iptables" mapstructure:"IPTables,omitempty"`
// Instructs the enforcer to send records for all
// application-initiated connections.
ApplicationConnections bool `json:"applicationConnections" msgpack:"applicationConnections" bson:"applicationconnections" mapstructure:"applicationConnections,omitempty"`
// Determines the length of the time interval that the trace must be
// enabled, using [Golang duration syntax](https://golang.org/pkg/time/#example_Duration).
Interval string `json:"interval" msgpack:"interval" bson:"interval" mapstructure:"interval,omitempty"`
// Instructs the enforcer to send records for all
// network-initiated connections.
NetworkConnections bool `json:"networkConnections" msgpack:"networkConnections" bson:"networkconnections" mapstructure:"networkConnections,omitempty"`
ModelVersion int `json:"-" msgpack:"-" bson:"_modelversion"`
}
// NewTraceMode returns a new *TraceMode
func NewTraceMode() *TraceMode {
return &TraceMode{
ModelVersion: 1,
Interval: "10s",
}
}
// BleveType implements the bleve.Classifier Interface.
func (o *TraceMode) BleveType() string {
return "tracemode"
}
// DeepCopy returns a deep copy if the TraceMode.
func (o *TraceMode) DeepCopy() *TraceMode {
if o == nil {
return nil
}
out := &TraceMode{}
o.DeepCopyInto(out)
return out
}
// DeepCopyInto copies the receiver into the given *TraceMode.
func (o *TraceMode) DeepCopyInto(out *TraceMode) {
target, err := copystructure.Copy(o)
if err != nil {
panic(fmt.Sprintf("Unable to deepcopy TraceMode: %s", err))
}
*out = *target.(*TraceMode)
}
// Validate valides the current information stored into the structure.
func (o *TraceMode) Validate() error {
errors := elemental.Errors{}
requiredErrors := elemental.Errors{}
if len(requiredErrors) > 0 {
return requiredErrors
}
if len(errors) > 0 {
return errors
}
return nil
}