Merge pull request #11038 from zhulongcheng/log-db-rm-event

log dashboard removed event
pull/11358/head
Chris Goller 2019-01-20 10:09:03 -06:00 committed by GitHub
commit 1811ed43b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -21,6 +21,7 @@ var (
const (
dashboardCreatedEvent = "Dashboard Created"
dashboardUpdatedEvent = "Dashboard Updated"
dashboardRemovedEvent = "Dashboard Removed"
dashboardCellsReplacedEvent = "Dashboard Cells Replaced"
dashboardCellAddedEvent = "Dashboard Cell Added"
@ -823,7 +824,6 @@ func (c *Client) deleteDashboard(ctx context.Context, tx *bolt.Tx, id platform.I
}
}
// TODO(desa): add DeleteKeyValueLog method and use it here.
err = c.deleteUserResourceMappings(ctx, tx, platform.UserResourceMappingFilter{
ResourceID: id,
ResourceType: platform.DashboardsResourceType,
@ -833,6 +833,13 @@ func (c *Client) deleteDashboard(ctx context.Context, tx *bolt.Tx, id platform.I
Err: err,
}
}
if err := c.appendDashboardEventToLog(ctx, tx, d.ID, dashboardRemovedEvent); err != nil {
return &platform.Error{
Err: err,
}
}
return nil
}

View File

@ -3,6 +3,7 @@ package bolt_test
import (
"context"
"testing"
"time"
platform "github.com/influxdata/influxdb"
"github.com/influxdata/influxdb/bolt"
@ -14,6 +15,11 @@ func initDashboardService(f platformtesting.DashboardFields, t *testing.T) (plat
if err != nil {
t.Fatalf("failed to create new bolt client: %v", err)
}
if f.NowFn == nil {
f.NowFn = time.Now
}
c.IDGenerator = f.IDGenerator
c.WithTime(f.NowFn)
ctx := context.TODO()