Skip to content

Commit

Permalink
Delete Attribute By Key And Value (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
sethAmazon authored May 15, 2024
1 parent e12c964 commit 67df910
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/coreinternal/attraction/attraction.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 67df910

Please sign in to comment.