Snapshots: Store dashboard data encrypted in the database (#28129)

* end 2 end

* fix import

* refactor

* introduce securedata

* check err

* use testify instead of convey

* cleanup test

* cleanup test

* blob time

* rename funcs
This commit is contained in:
Will Browne
2020-10-13 10:19:42 +02:00
committed by GitHub
parent 87d6f90acb
commit ef22ff7315
8 changed files with 249 additions and 122 deletions
+14 -1
View File
@@ -3,6 +3,7 @@ package models
import (
"time"
"github.com/grafana/grafana/pkg/components/securedata"
"github.com/grafana/grafana/pkg/components/simplejson"
)
@@ -22,7 +23,19 @@ type DashboardSnapshot struct {
Created time.Time
Updated time.Time
Dashboard *simplejson.Json
Dashboard *simplejson.Json
DashboardEncrypted securedata.SecureData
}
func (ds *DashboardSnapshot) DashboardJSON() (*simplejson.Json, error) {
if ds.DashboardEncrypted != nil {
decrypted, err := ds.DashboardEncrypted.Decrypt()
if err != nil {
return nil, err
}
return simplejson.NewJson(decrypted)
}
return ds.Dashboard, nil
}
// DashboardSnapshotDTO without dashboard map