diff --git a/dashboard/components/explorer/hooks/useDependencyGraph.tsx b/dashboard/components/explorer/hooks/useDependencyGraph.tsx index 265c63404..1aa814142 100644 --- a/dashboard/components/explorer/hooks/useDependencyGraph.tsx +++ b/dashboard/components/explorer/hooks/useDependencyGraph.tsx @@ -23,7 +23,7 @@ function GetData(res: any) { data: { label: ele.name, service: ele.service, - provider: 'AWS', + provider: ele.provider, id: ele.resourceId, isRoot: true } @@ -40,7 +40,7 @@ function GetData(res: any) { label: rel.name, service: ele.service, type: rel.type, - provider: 'AWS', // when supporting new provider this could be made dynamic + provider: ele.provider, isRoot: false } }; diff --git a/handlers/resources_handler.go b/handlers/resources_handler.go index cde3cdc5a..f0c0ed13c 100644 --- a/handlers/resources_handler.go +++ b/handlers/resources_handler.go @@ -400,14 +400,14 @@ func (handler *ApiHandler) RelationStatsHandler(c *gin.Context) { query := "" if len(filters) == 0 { - query = "SELECT DISTINCT resources.resource_id, resources.name, resources.service, resources.relations FROM resources WHERE (jsonb_array_length(relations) > 0)" + query = "SELECT DISTINCT resources.resource_id, resources.provider, resources.name, resources.service, resources.relations FROM resources WHERE (jsonb_array_length(relations) > 0)" if handler.db.Dialect().Name() == dialect.SQLite { - query = "SELECT DISTINCT resources.resource_id, resources.name, resources.service, resources.relations FROM resources WHERE (json_array_length(relations) > 0)" + query = "SELECT DISTINCT resources.resource_id, resources.provider, resources.name, resources.service, resources.relations FROM resources WHERE (json_array_length(relations) > 0)" } } else { - query = "SELECT DISTINCT resources.resource_id, resources.name, resources.service, resources.relations FROM resources WHERE (jsonb_array_length(relations) > 0) AND " + whereClause + query = "SELECT DISTINCT resources.resource_id, resources.provider, resources.name, resources.service, resources.relations FROM resources WHERE (jsonb_array_length(relations) > 0) AND " + whereClause if handler.db.Dialect().Name() == dialect.SQLite { - query = "SELECT DISTINCT resources.resource_id, resources.name, resources.service, resources.relations FROM resources WHERE (json_array_length(relations) > 0) AND " + whereClause + query = "SELECT DISTINCT resources.resource_id, resources.provider, resources.name, resources.service, resources.relations FROM resources WHERE (json_array_length(relations) > 0) AND " + whereClause } } @@ -423,9 +423,10 @@ func (handler *ApiHandler) RelationStatsHandler(c *gin.Context) { Name: ele.Name, Type: ele.Service, Link: ele.Relations, + Provider: ele.Provider, }) } - + c.JSON(http.StatusOK, out) } diff --git a/models/relation.go b/models/relation.go index 362cc2fb0..b10dba8df 100644 --- a/models/relation.go +++ b/models/relation.go @@ -12,4 +12,5 @@ type OutputRelationResponse struct { Type string `json:"service" bun:"service"` Name string `json:"name" bun:"name"` Link []Link `json:"relations" bun:"relations"` + Provider string `json:"provider" bun:"provider"` }