From 3ad55927bf8e99bc1c227a7e3e7be4096678a4fe Mon Sep 17 00:00:00 2001 From: Alexandre Pujol Date: Sun, 5 May 2024 14:11:00 +0100 Subject: [PATCH] feat(aa): add basic rules getter --- pkg/aa/rules.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pkg/aa/rules.go b/pkg/aa/rules.go index 4cfdda3b..7cb6dc1a 100644 --- a/pkg/aa/rules.go +++ b/pkg/aa/rules.go @@ -32,3 +32,24 @@ type Rules []Rule func (r Rules) String() string { return renderTemplate("rules", r) } + +func (r Rules) Get(filter string) Rules { + res := make(Rules, 0) + for _, rule := range r { + if rule.Kind() == filter { + res = append(res, rule) + } + } + return res +} + +func (r Rules) GetVariables() []*Variable { + res := make([]*Variable, 0) + for _, rule := range r { + switch rule.(type) { + case *Variable: + res = append(res, rule.(*Variable)) + } + } + return res +}