Browse Source

Snapshot: use given key and deleteKey (#16876)

Signed-off-by: zhulongcheng <zhulongcheng.me@gmail.com>
zhulongcheng 6 years ago
parent
commit
7ebbeb09cb
1 changed files with 8 additions and 2 deletions
  1. 8 2
      pkg/api/dashboard_snapshot.go

+ 8 - 2
pkg/api/dashboard_snapshot.go

@@ -99,8 +99,14 @@ func CreateDashboardSnapshot(c *m.ReqContext, cmd m.CreateDashboardSnapshotComma
 
 		metrics.M_Api_Dashboard_Snapshot_External.Inc()
 	} else {
-		cmd.Key = util.GetRandomString(32)
-		cmd.DeleteKey = util.GetRandomString(32)
+		if cmd.Key == "" {
+			cmd.Key = util.GetRandomString(32)
+		}
+
+		if cmd.DeleteKey == "" {
+			cmd.DeleteKey = util.GetRandomString(32)
+		}
+
 		url = setting.ToAbsUrl("dashboard/snapshot/" + cmd.Key)
 
 		metrics.M_Api_Dashboard_Snapshot_Create.Inc()