From 7fe3a1d5802f13ee79996fc565fe306c21b80233 Mon Sep 17 00:00:00 2001 From: Yash Mehrotra Date: Mon, 28 Oct 2024 17:55:30 +0530 Subject: [PATCH] fix: config scraper query in resource selector --- query/resource_selector.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/query/resource_selector.go b/query/resource_selector.go index 316c19ed..94fdcb33 100644 --- a/query/resource_selector.go +++ b/query/resource_selector.go @@ -498,19 +498,18 @@ func getScopeID(ctx context.Context, scope string, table string, agentID *uuid.U } namespace, name := parts[0], parts[1] - var scopeTable string + q := ctx.DB() switch table { case "checks": - scopeTable = "canaries" + q = q.Table("canaries").Select("id").Where("name = ? AND namespace = ?", name, namespace) case "config_items": - scopeTable = "config_scrapers" + q = q.Table("config_scrapers").Select("id").Where("name = ?", namespace+"/"+name) case "components": - scopeTable = "topologies" + q = q.Table("topologies").Select("id").Where("name = ? AND namespace = ?", name, namespace) default: return "", api.Errorf(api.EINVALID, "scope is not supported for %s", table) } - q := ctx.DB().Table(scopeTable).Select("id").Where("name = ? AND namespace = ?", name, namespace) if agentID != nil { q = q.Where("agent_id = ?", *agentID) }