Skip to content

Commit

Permalink
Add option to tetra to filter on event types
Browse files Browse the repository at this point in the history
This PR adds the ability to filter on the event types.
  • Loading branch information
darox committed Oct 3, 2023
1 parent b3abd80 commit 56662a7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cmd/tetra/getevents/getevents.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type Opts struct {
Output string
Color string
IncludeFields []string
EventTypes []string
ExcludeFields []string
Namespaces []string
Namespace []string // deprecated: use Namespaces
Expand Down Expand Up @@ -87,6 +88,14 @@ var GetFilter = func() *tetragon.Filter {
filter.PodRegex = Options.Pods
}

if len(Options.EventTypes) > 0 {
var e tetragon.EventType
for _, eventType := range Options.EventTypes {
e = tetragon.EventType(tetragon.EventType_value[eventType])
filter.EventSet = append(filter.EventSet, e)
}
}

return &filter
}

Expand Down Expand Up @@ -174,6 +183,7 @@ func New() *cobra.Command {
flags.StringVarP(&Options.Output, common.KeyOutput, "o", "json", "Output format. json or compact")
flags.StringVar(&Options.Color, "color", "auto", "Colorize compact output. auto, always, or never")
flags.StringSliceVarP(&Options.IncludeFields, "include-fields", "f", nil, "Include only fields in events")
flags.StringSliceVarP(&Options.EventTypes, "event-types", "e", nil, "Include only events of given types")
flags.StringSliceVarP(&Options.ExcludeFields, "exclude-fields", "F", nil, "Exclude fields from events")

flags.StringSliceVarP(&Options.Namespaces, "namespaces", "n", nil, "Get events by Kubernetes namespaces")
Expand Down

0 comments on commit 56662a7

Please # to comment.