diff --git a/pkg/services/searchV2/bluge.go b/pkg/services/searchV2/bluge.go index 7fece83e1b3..04bec20680c 100644 --- a/pkg/services/searchV2/bluge.go +++ b/pkg/services/searchV2/bluge.go @@ -170,15 +170,15 @@ func getNonFolderDashboardDoc(dash dashboard, location string) *bluge.Document { } for _, ref := range dash.summary.References { - if ref.Kind == entity.StandardKindDataSource { + if ref.Family == entity.StandardKindDataSource { if ref.Type != "" { doc.AddField(bluge.NewKeywordField(documentFieldDSType, ref.Type). StoreValue(). Aggregatable(). SearchTermPositions()) } - if ref.UID != "" { - doc.AddField(bluge.NewKeywordField(documentFieldDSUID, ref.UID). + if ref.Identifier != "" { + doc.AddField(bluge.NewKeywordField(documentFieldDSUID, ref.Identifier). StoreValue(). Aggregatable(). SearchTermPositions()) @@ -194,8 +194,8 @@ func getDashboardPanelDocs(dash dashboard, location string) []*bluge.Document { var docs []*bluge.Document for _, panel := range dash.summary.Nested { - if panel.Kind == "panel-row" { - continue // for now, we are excluding rows from the search index + if panel.Fields["type"] == "row" { + continue // skip rows } idx := strings.LastIndex(panel.UID, "#") panelId, err := strconv.Atoi(panel.UID[idx+1:]) @@ -209,7 +209,7 @@ func getDashboardPanelDocs(dash dashboard, location string) []*bluge.Document { AddField(bluge.NewKeywordField(documentFieldKind, string(entityKindPanel)).Aggregatable().StoreValue()) // likely want independent index for this for _, ref := range dash.summary.References { - switch ref.Kind { + switch ref.Family { case entity.StandardKindDashboard: if ref.Type != "" { doc.AddField(bluge.NewKeywordField(documentFieldDSType, ref.Type). @@ -217,19 +217,19 @@ func getDashboardPanelDocs(dash dashboard, location string) []*bluge.Document { Aggregatable(). SearchTermPositions()) } - if ref.UID != "" { - doc.AddField(bluge.NewKeywordField(documentFieldDSUID, ref.UID). + if ref.Identifier != "" { + doc.AddField(bluge.NewKeywordField(documentFieldDSUID, ref.Identifier). StoreValue(). Aggregatable(). SearchTermPositions()) } case entity.ExternalEntityReferencePlugin: - if ref.Type == entity.StandardKindPanel && ref.UID != "" { - doc.AddField(bluge.NewKeywordField(documentFieldPanelType, ref.UID).Aggregatable().StoreValue()) + if ref.Type == entity.StandardKindPanel && ref.Identifier != "" { + doc.AddField(bluge.NewKeywordField(documentFieldPanelType, ref.Identifier).Aggregatable().StoreValue()) } case entity.ExternalEntityReferenceRuntime: - if ref.Type == entity.ExternalEntityReferenceRuntime_Transformer && ref.UID != "" { - doc.AddField(bluge.NewKeywordField(documentFieldTransformer, ref.UID).Aggregatable()) + if ref.Type == entity.ExternalEntityReferenceRuntime_Transformer && ref.Identifier != "" { + doc.AddField(bluge.NewKeywordField(documentFieldTransformer, ref.Identifier).Aggregatable()) } } } diff --git a/pkg/services/sqlstore/migrations/entity_store_mig.go b/pkg/services/sqlstore/migrations/entity_store_mig.go index 0d4d0e21fba..69d214d3e25 100644 --- a/pkg/services/sqlstore/migrations/entity_store_mig.go +++ b/pkg/services/sqlstore/migrations/entity_store_mig.go @@ -85,7 +85,7 @@ func addEntityStoreMigrations(mg *migrator.Migrator) { }, Indices: []*migrator.Index{ {Cols: []string{"tenant_id", "uid"}, Type: migrator.UniqueIndex}, - {Cols: []string{"tenant_id", "slug_path"}, Type: migrator.UniqueIndex}, + // {Cols: []string{"tenant_id", "slug_path"}, Type: migrator.UniqueIndex}, }, }) @@ -111,9 +111,9 @@ func addEntityStoreMigrations(mg *migrator.Migrator) { {Name: "parent_grn", Type: migrator.DB_NVarchar, Length: grnLength, Nullable: true}, // Address (defined in the body, not resolved, may be invalid and change) - {Name: "kind", Type: migrator.DB_NVarchar, Length: 255, Nullable: false}, + {Name: "family", Type: migrator.DB_NVarchar, Length: 255, Nullable: false}, {Name: "type", Type: migrator.DB_NVarchar, Length: 255, Nullable: true}, - {Name: "uid", Type: migrator.DB_NVarchar, Length: 1024, Nullable: true}, + {Name: "id", Type: migrator.DB_NVarchar, Length: 1024, Nullable: true}, // Runtime calcs (will depend on the system state) {Name: "resolved_ok", Type: migrator.DB_Bool, Nullable: false}, @@ -123,7 +123,8 @@ func addEntityStoreMigrations(mg *migrator.Migrator) { }, Indices: []*migrator.Index{ {Cols: []string{"grn"}, Type: migrator.IndexType}, - {Cols: []string{"kind"}, Type: migrator.IndexType}, + {Cols: []string{"family"}, Type: migrator.IndexType}, + {Cols: []string{"type"}, Type: migrator.IndexType}, {Cols: []string{"resolved_to"}, Type: migrator.IndexType}, {Cols: []string{"parent_grn"}, Type: migrator.IndexType}, }, @@ -192,7 +193,7 @@ func addEntityStoreMigrations(mg *migrator.Migrator) { // Migration cleanups: given that this is a complex setup // that requires a lot of testing before we are ready to push out of dev // this script lets us easy wipe previous changes and initialize clean tables - suffix := " (v31)" // change this when we want to wipe and reset the object tables + suffix := " (v010)" // change this when we want to wipe and reset the object tables mg.AddMigration("EntityStore init: cleanup"+suffix, migrator.NewRawSQLMigration(strings.TrimSpace(` DELETE FROM migration_log WHERE migration_id LIKE 'EntityStore init%'; `))) diff --git a/pkg/services/store/entity/models.go b/pkg/services/store/entity/models.go index 9f5ea100e19..84784f2808a 100644 --- a/pkg/services/store/entity/models.go +++ b/pkg/services/store/entity/models.go @@ -117,14 +117,19 @@ type EntitySummary struct { // This message is derived from the object body and can be used to search for references. // This does not represent a method to declare a reference to another object. type EntityExternalReference struct { - // datasource (instance), dashboard (instance), - Kind string `json:"kind,omitempty"` + // Category of dependency + // eg: datasource, plugin, runtime + Family string `json:"family,omitempty"` - // prometheus / heatmap, heatamp|prometheus + // datasource > prometheus|influx|... + // plugin > panel | datasource + // runtime > transformer Type string `json:"type,omitempty"` // flavor - // Unique ID for this object - UID string `json:"UID,omitempty"` + // datasource > UID + // plugin > plugin identifier + // runtime > name lookup + Identifier string `json:"ID,omitempty"` } // EntitySummaryBuilder will read an object, validate it, and return a summary, sanitized payload, or an error diff --git a/pkg/services/store/entity/sqlstash/sql_storage_server.go b/pkg/services/store/entity/sqlstash/sql_storage_server.go index 6fc34ef8cd9..ee5167b6105 100644 --- a/pkg/services/store/entity/sqlstash/sql_storage_server.go +++ b/pkg/services/store/entity/sqlstash/sql_storage_server.go @@ -532,10 +532,10 @@ func (s *sqlEntityServer) writeSearchInfo( return err } _, err = tx.Exec(ctx, `INSERT INTO entity_ref (`+ - "grn, parent_grn, kind, type, uid, "+ + "grn, parent_grn, family, type, id, "+ "resolved_ok, resolved_to, resolved_warning, resolved_time) "+ `VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`, - grn, parent_grn, ref.Kind, ref.Type, ref.UID, + grn, parent_grn, ref.Family, ref.Type, ref.Identifier, resolved.OK, resolved.Key, resolved.Warning, resolved.Timestamp, ) if err != nil { diff --git a/pkg/services/store/kind/dashboard/reference.go b/pkg/services/store/kind/dashboard/reference.go index 332078228f3..e71369a6bf2 100644 --- a/pkg/services/store/kind/dashboard/reference.go +++ b/pkg/services/store/kind/dashboard/reference.go @@ -10,7 +10,7 @@ import ( // A reference accumulator can combine type ReferenceAccumulator interface { // Add references as we find them - Add(kind string, subtype string, uid string) + Add(family string, ttype string, id string) // Returns the set of distinct references in a sorted order Get() []*entity.EntityExternalReference @@ -26,14 +26,14 @@ type referenceAccumulator struct { refs map[string]*entity.EntityExternalReference } -func (x *referenceAccumulator) Add(kind string, sub string, uid string) { - key := fmt.Sprintf("%s/%s/%s", kind, sub, uid) +func (x *referenceAccumulator) Add(family string, ttype string, id string) { + key := fmt.Sprintf("%s/%s/%s", family, ttype, id) _, ok := x.refs[key] if !ok { x.refs[key] = &entity.EntityExternalReference{ - Kind: kind, - Type: sub, - UID: uid, + Family: family, + Type: ttype, + Identifier: id, } } } diff --git a/pkg/services/store/kind/dashboard/testdata/gdev-walk-graph-gradient-area-fills.json b/pkg/services/store/kind/dashboard/testdata/gdev-walk-graph-gradient-area-fills.json index 1af4e059861..9eb1a26b1a5 100644 --- a/pkg/services/store/kind/dashboard/testdata/gdev-walk-graph-gradient-area-fills.json +++ b/pkg/services/store/kind/dashboard/testdata/gdev-walk-graph-gradient-area-fills.json @@ -18,12 +18,12 @@ }, "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] }, @@ -36,12 +36,12 @@ }, "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] }, @@ -54,12 +54,12 @@ }, "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] }, @@ -72,24 +72,24 @@ }, "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] } ], "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] } \ No newline at end of file diff --git a/pkg/services/store/kind/dashboard/testdata/gdev-walk-graph-shared-tooltips.json b/pkg/services/store/kind/dashboard/testdata/gdev-walk-graph-shared-tooltips.json index 10c63c88fcb..9406933bac2 100644 --- a/pkg/services/store/kind/dashboard/testdata/gdev-walk-graph-shared-tooltips.json +++ b/pkg/services/store/kind/dashboard/testdata/gdev-walk-graph-shared-tooltips.json @@ -18,12 +18,12 @@ }, "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "timeseries" + "ID": "timeseries" } ] }, @@ -36,22 +36,22 @@ }, "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "xychart" + "ID": "xychart" }, { - "kind": "runtime", + "family": "runtime", "type": "transformer", - "UID": "organize" + "ID": "organize" }, { - "kind": "runtime", + "family": "runtime", "type": "transformer", - "UID": "seriesToColumns" + "ID": "seriesToColumns" } ] }, @@ -64,12 +64,12 @@ }, "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "debug" + "ID": "debug" } ] }, @@ -82,12 +82,12 @@ }, "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "timeseries" + "ID": "timeseries" } ] }, @@ -100,12 +100,12 @@ }, "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "timeseries" + "ID": "timeseries" } ] }, @@ -118,12 +118,12 @@ }, "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "timeseries" + "ID": "timeseries" } ] }, @@ -136,12 +136,12 @@ }, "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] }, @@ -154,49 +154,49 @@ }, "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] } ], "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "debug" + "ID": "debug" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "timeseries" + "ID": "timeseries" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "xychart" + "ID": "xychart" }, { - "kind": "runtime", + "family": "runtime", "type": "transformer", - "UID": "organize" + "ID": "organize" }, { - "kind": "runtime", + "family": "runtime", "type": "transformer", - "UID": "seriesToColumns" + "ID": "seriesToColumns" } ] } \ No newline at end of file diff --git a/pkg/services/store/kind/dashboard/testdata/gdev-walk-graph-time-regions.json b/pkg/services/store/kind/dashboard/testdata/gdev-walk-graph-time-regions.json index 46c2b25e41b..d91dfe46b88 100644 --- a/pkg/services/store/kind/dashboard/testdata/gdev-walk-graph-time-regions.json +++ b/pkg/services/store/kind/dashboard/testdata/gdev-walk-graph-time-regions.json @@ -18,13 +18,13 @@ }, "references": [ { - "kind": "ds", - "UID": "gdev-testdata" + "family": "ds", + "ID": "gdev-testdata" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] }, @@ -37,13 +37,13 @@ }, "references": [ { - "kind": "ds", - "UID": "gdev-testdata" + "family": "ds", + "ID": "gdev-testdata" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] }, @@ -56,13 +56,13 @@ }, "references": [ { - "kind": "ds", - "UID": "gdev-testdata" + "family": "ds", + "ID": "gdev-testdata" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] }, @@ -75,13 +75,13 @@ }, "references": [ { - "kind": "ds", - "UID": "gdev-testdata" + "family": "ds", + "ID": "gdev-testdata" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] }, @@ -94,26 +94,26 @@ }, "references": [ { - "kind": "ds", - "UID": "gdev-testdata" + "family": "ds", + "ID": "gdev-testdata" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] } ], "references": [ { - "kind": "ds", - "UID": "gdev-testdata" + "family": "ds", + "ID": "gdev-testdata" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] } \ No newline at end of file diff --git a/pkg/services/store/kind/dashboard/testdata/gdev-walk-graph_tests.json b/pkg/services/store/kind/dashboard/testdata/gdev-walk-graph_tests.json index b207ad9d31d..61630217a55 100644 --- a/pkg/services/store/kind/dashboard/testdata/gdev-walk-graph_tests.json +++ b/pkg/services/store/kind/dashboard/testdata/gdev-walk-graph_tests.json @@ -18,13 +18,13 @@ }, "references": [ { - "kind": "ds", - "UID": "gdev-testdata" + "family": "ds", + "ID": "gdev-testdata" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] }, @@ -37,13 +37,13 @@ }, "references": [ { - "kind": "ds", - "UID": "gdev-testdata" + "family": "ds", + "ID": "gdev-testdata" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] }, @@ -56,13 +56,13 @@ }, "references": [ { - "kind": "ds", - "UID": "gdev-testdata" + "family": "ds", + "ID": "gdev-testdata" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] }, @@ -75,13 +75,13 @@ }, "references": [ { - "kind": "ds", - "UID": "gdev-testdata" + "family": "ds", + "ID": "gdev-testdata" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] }, @@ -93,12 +93,12 @@ }, "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "text" + "ID": "text" } ] }, @@ -111,13 +111,13 @@ }, "references": [ { - "kind": "ds", - "UID": "gdev-testdata" + "family": "ds", + "ID": "gdev-testdata" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] }, @@ -129,12 +129,12 @@ }, "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "text" + "ID": "text" } ] }, @@ -147,13 +147,13 @@ }, "references": [ { - "kind": "ds", - "UID": "gdev-testdata" + "family": "ds", + "ID": "gdev-testdata" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] }, @@ -166,13 +166,13 @@ }, "references": [ { - "kind": "ds", - "UID": "gdev-testdata" + "family": "ds", + "ID": "gdev-testdata" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] }, @@ -184,12 +184,12 @@ }, "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "text" + "ID": "text" } ] }, @@ -202,13 +202,13 @@ }, "references": [ { - "kind": "ds", - "UID": "gdev-testdata" + "family": "ds", + "ID": "gdev-testdata" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] }, @@ -220,12 +220,12 @@ }, "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "text" + "ID": "text" } ] }, @@ -238,13 +238,13 @@ }, "references": [ { - "kind": "ds", - "UID": "gdev-testdata" + "family": "ds", + "ID": "gdev-testdata" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] }, @@ -256,12 +256,12 @@ }, "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "text" + "ID": "text" } ] }, @@ -274,13 +274,13 @@ }, "references": [ { - "kind": "ds", - "UID": "gdev-testdata" + "family": "ds", + "ID": "gdev-testdata" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] }, @@ -292,12 +292,12 @@ }, "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "text" + "ID": "text" } ] }, @@ -310,13 +310,13 @@ }, "references": [ { - "kind": "ds", - "UID": "gdev-testdata" + "family": "ds", + "ID": "gdev-testdata" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] }, @@ -329,13 +329,13 @@ }, "references": [ { - "kind": "ds", - "UID": "gdev-testdata" + "family": "ds", + "ID": "gdev-testdata" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] }, @@ -348,13 +348,13 @@ }, "references": [ { - "kind": "ds", - "UID": "gdev-testdata" + "family": "ds", + "ID": "gdev-testdata" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] }, @@ -367,13 +367,13 @@ }, "references": [ { - "kind": "ds", - "UID": "gdev-testdata" + "family": "ds", + "ID": "gdev-testdata" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] }, @@ -386,34 +386,34 @@ }, "references": [ { - "kind": "ds", - "UID": "gdev-testdata" + "family": "ds", + "ID": "gdev-testdata" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] } ], "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "ds", - "UID": "gdev-testdata" + "family": "ds", + "ID": "gdev-testdata" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "text" + "ID": "text" } ] } \ No newline at end of file diff --git a/pkg/services/store/kind/dashboard/testdata/gdev-walk-graph_y_axis.json b/pkg/services/store/kind/dashboard/testdata/gdev-walk-graph_y_axis.json index cd8f78665d2..8ee9d100953 100644 --- a/pkg/services/store/kind/dashboard/testdata/gdev-walk-graph_y_axis.json +++ b/pkg/services/store/kind/dashboard/testdata/gdev-walk-graph_y_axis.json @@ -17,12 +17,12 @@ }, "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] }, @@ -35,12 +35,12 @@ }, "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] }, @@ -53,12 +53,12 @@ }, "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] }, @@ -71,12 +71,12 @@ }, "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] }, @@ -89,12 +89,12 @@ }, "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] }, @@ -107,12 +107,12 @@ }, "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] }, @@ -125,12 +125,12 @@ }, "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] }, @@ -143,12 +143,12 @@ }, "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] }, @@ -161,24 +161,24 @@ }, "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] } ], "references": [ { - "kind": "ds" + "family": "ds" }, { - "kind": "plugin", + "family": "plugin", "type": "panel", - "UID": "graph" + "ID": "graph" } ] } \ No newline at end of file diff --git a/pkg/services/store/kind/dummy/summary.go b/pkg/services/store/kind/dummy/summary.go index a7ea51019ba..06f60aa8854 100644 --- a/pkg/services/store/kind/dummy/summary.go +++ b/pkg/services/store/kind/dummy/summary.go @@ -37,17 +37,17 @@ func GetEntitySummaryBuilder(kind string) entity.EntitySummaryBuilder { Nested: nil, // ignore for now References: []*entity.EntityExternalReference{ { - Kind: "ds", - Type: "influx", - UID: "xyz", + Family: "ds", + Type: "influx", + Identifier: "xyz", }, { - Kind: "panel", - Type: "heatmap", + Family: entity.StandardKindPanel, + Type: "heatmap", }, { - Kind: "panel", - Type: "timeseries", + Family: entity.StandardKindPanel, + Type: "timeseries", }, }, } diff --git a/pkg/services/store/kind/playlist/summary.go b/pkg/services/store/kind/playlist/summary.go index 9cb27362710..959f4f2f39b 100644 --- a/pkg/services/store/kind/playlist/summary.go +++ b/pkg/services/store/kind/playlist/summary.go @@ -45,8 +45,8 @@ func summaryBuilder(ctx context.Context, uid string, body []byte) (*entity.Entit switch item.Type { case playlist.ItemTypeDashboardByUid: summary.References = append(summary.References, &entity.EntityExternalReference{ - Kind: "dashboard", - UID: item.Value, + Family: entity.StandardKindDashboard, + Identifier: item.Value, }) case playlist.ItemTypeDashboardByTag: diff --git a/pkg/services/store/kind/preferences/summary.go b/pkg/services/store/kind/preferences/summary.go index 1efdae01633..c3b557f788e 100644 --- a/pkg/services/store/kind/preferences/summary.go +++ b/pkg/services/store/kind/preferences/summary.go @@ -43,8 +43,8 @@ func GetEntitySummaryBuilder() entity.EntitySummaryBuilder { if obj.HomeDashboardUID != nil && *obj.HomeDashboardUID != "" { summary.References = append(summary.References, &entity.EntityExternalReference{ - Kind: entity.StandardKindDashboard, - UID: *obj.HomeDashboardUID, + Family: entity.StandardKindDashboard, + Identifier: *obj.HomeDashboardUID, }) } diff --git a/pkg/services/store/kind/snapshot/summary.go b/pkg/services/store/kind/snapshot/summary.go index 9907b10e21a..d19ed188a16 100644 --- a/pkg/services/store/kind/snapshot/summary.go +++ b/pkg/services/store/kind/snapshot/summary.go @@ -52,7 +52,7 @@ func GetEntitySummaryBuilder() entity.EntitySummaryBuilder { "expires": obj.Expires, }, References: []*entity.EntityExternalReference{ - {Kind: entity.StandardKindDashboard, UID: obj.DashboardUID}, + {Family: entity.StandardKindDashboard, Identifier: obj.DashboardUID}, }, } diff --git a/pkg/services/store/resolver/service.go b/pkg/services/store/resolver/service.go index e8343f3180a..01c01ba732b 100644 --- a/pkg/services/store/resolver/service.go +++ b/pkg/services/store/resolver/service.go @@ -51,7 +51,7 @@ func (r *standardReferenceResolver) Resolve(ctx context.Context, ref *entity.Ent return ResolutionInfo{OK: false, Timestamp: getNow()}, fmt.Errorf("ref is nil") } - switch ref.Kind { + switch ref.Family { case entity.StandardKindDataSource: return r.resolveDatasource(ctx, ref) @@ -74,7 +74,7 @@ func (r *standardReferenceResolver) Resolve(ctx context.Context, ref *entity.Ent } func (r *standardReferenceResolver) resolveDatasource(ctx context.Context, ref *entity.EntityExternalReference) (ResolutionInfo, error) { - ds, err := r.ds.getDS(ctx, ref.UID) + ds, err := r.ds.getDS(ctx, ref.Identifier) if err != nil || ds == nil || ds.UID == "" { return ResolutionInfo{ OK: false, @@ -100,7 +100,7 @@ func (r *standardReferenceResolver) resolveDatasource(ctx context.Context, ref * } func (r *standardReferenceResolver) resolvePlugin(ctx context.Context, ref *entity.EntityExternalReference) (ResolutionInfo, error) { - p, ok := r.pluginStore.Plugin(ctx, ref.UID) + p, ok := r.pluginStore.Plugin(ctx, ref.Identifier) if !ok { return ResolutionInfo{ OK: false, diff --git a/pkg/services/store/resolver/service_test.go b/pkg/services/store/resolver/service_test.go index d6cf4d1a8e5..f0c05043065 100644 --- a/pkg/services/store/resolver/service_test.go +++ b/pkg/services/store/resolver/service_test.go @@ -58,8 +58,8 @@ func TestResolver(t *testing.T) { { name: "Missing datasource without type", given: &entity.EntityExternalReference{ - Kind: entity.StandardKindDataSource, - UID: "xyz", + Family: entity.StandardKindDataSource, + Identifier: "xyz", }, expect: ResolutionInfo{OK: false}, ctx: ctxOrg1, @@ -67,9 +67,9 @@ func TestResolver(t *testing.T) { { name: "OK datasource", given: &entity.EntityExternalReference{ - Kind: entity.StandardKindDataSource, - Type: "influx", - UID: "influx-uid", + Family: entity.StandardKindDataSource, + Type: "influx", + Identifier: "influx-uid", }, expect: ResolutionInfo{OK: true, Key: "influx-uid"}, ctx: ctxOrg1, @@ -77,7 +77,7 @@ func TestResolver(t *testing.T) { { name: "Get the default datasource", given: &entity.EntityExternalReference{ - Kind: entity.StandardKindDataSource, + Family: entity.StandardKindDataSource, }, expect: ResolutionInfo{ OK: true, @@ -89,8 +89,8 @@ func TestResolver(t *testing.T) { { name: "Get the default datasource (with type)", given: &entity.EntityExternalReference{ - Kind: entity.StandardKindDataSource, - Type: "influx", + Family: entity.StandardKindDataSource, + Type: "influx", }, expect: ResolutionInfo{ OK: true, @@ -101,8 +101,8 @@ func TestResolver(t *testing.T) { { name: "Lookup by name", given: &entity.EntityExternalReference{ - Kind: entity.StandardKindDataSource, - UID: "Influx2", + Family: entity.StandardKindDataSource, + Identifier: "Influx2", }, expect: ResolutionInfo{ OK: true,