-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
automod: add removing of labels from accounts and records #950
Conversation
early and still not fully caffeinated, but i think i got some decent logic here. imagine a scenario like:
Here, we'd keep the
Here we'd remove the
Here we'd remove the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one little typo, but otherwise looks good!
automod/engine/effects.go
Outdated
func (e *Effects) RemoveAccountLabel(val string) { | ||
e.mu.Lock() | ||
defer e.mu.Unlock() | ||
for _, v := range e.RemovedRecordLabels { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Record
/ Account
swapped here (sorry this code is so duplicative)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oop nice catch ty
automod/engine/persist.go
Outdated
@@ -42,6 +43,15 @@ func (eng *Engine) persistAccountModActions(c *AccountContext) error { | |||
|
|||
// de-dupe actions | |||
newLabels := dedupeLabelActions(c.effects.AccountLabels, c.Account.AccountLabels, c.Account.AccountNegatedLabels) | |||
var rmdLabels []string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
embarrassing idiomatic golang question: should this be:
rmdLabels := []string{}
specifically b/c it gets len()
called on it, and passed to NegateLabelVals
below. probably fine/same either way. "is zero/nil of an array of strings same as empty array"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be fine for the len()
case. good point though with getting passed to NegateLabelVals
. i'm not sure if the api would be happy with a null
(or omitted? didnt look closely) value after marshaling, so yea let's just initialize the empty array
i haven't tested this yet - and took me a little to understand what we were doing here so might still be a little off - but this should let us remove existing labels from accounts/records