Skip to content

Commit

Permalink
fix: config scraper query in resource selector
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmehrotra committed Oct 28, 2024
1 parent a66a440 commit 7fe3a1d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions query/resource_selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 7fe3a1d

Please sign in to comment.