From 67df9103c7af021902c349836ea7154bb0546b47 Mon Sep 17 00:00:00 2001 From: Seth L <81644108+sethAmazon@users.noreply.github.com> Date: Wed, 15 May 2024 10:11:34 -0400 Subject: [PATCH] Delete Attribute By Key And Value (#213) --- internal/coreinternal/attraction/attraction.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/coreinternal/attraction/attraction.go b/internal/coreinternal/attraction/attraction.go index c05d4c4d52bd..b3c4dde89513 100644 --- a/internal/coreinternal/attraction/attraction.go +++ b/internal/coreinternal/attraction/attraction.go @@ -218,7 +218,7 @@ func NewAttrProc(settings *Settings) (*AttrProc, error) { action.FromContext = a.FromContext } case HASH, DELETE: - if a.Value != nil || a.FromAttribute != "" { + if a.FromAttribute != "" { return nil, fmt.Errorf("error creating AttrProc. Action \"%s\" does not use \"value\" or \"from_attribute\" field. These must not be specified for %d-th action", a.Action, i) } @@ -290,6 +290,12 @@ func (ap *AttrProc) Process(ctx context.Context, logger *zap.Logger, attrs pcomm // and could impact performance. switch action.Action { case DELETE: + if action.AttributeValue != nil && action.AttributeValue.AsString() != "" { + value, contains := attrs.Get(action.Key) + if !contains || value.AsString() != action.AttributeValue.AsString() { + continue + } + } attrs.Remove(action.Key) for _, k := range getMatchingKeys(action.Regex, attrs) {