EntityAPI: Rename references from kind to family (#62044)

This commit is contained in:
Ryan McKinley 2023-01-25 15:42:04 -08:00 committed by GitHub
parent f3aa058886
commit 46c828c2d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 256 additions and 250 deletions

View File

@ -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())
}
}
}

View File

@ -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%';
`)))

View File

@ -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

View File

@ -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 {

View File

@ -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,
}
}
}

View File

@ -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"
}
]
}

View File

@ -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"
}
]
}

View File

@ -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"
}
]
}

View File

@ -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"
}
]
}

View File

@ -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"
}
]
}

View File

@ -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",
},
},
}

View File

@ -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:

View File

@ -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,
})
}

View File

@ -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},
},
}

View File

@ -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,

View File

@ -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,