Skip to content

Commit

Permalink
Merge pull request #2006 from opengovern/feat-query-validator
Browse files Browse the repository at this point in the history
fix: add more logs to validator
  • Loading branch information
artaasadi authored Nov 16, 2024
2 parents adde567 + 21dedd8 commit c4341b5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/describe/schedulers/query-validator/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (s *JobScheduler) runPublisher(ctx context.Context) error {
for _, qp := range queryParams.QueryParameters {
queryParamMap[qp.Key] = qp.Value
}
queryTemplate, err := template.New("query").Parse(jobMsg.Query)
queryTemplate, err := template.New(jobMsg.QueryId).Parse(jobMsg.Query)
if err != nil {
return err
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/query-validator/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type Job struct {
func (w *Worker) RunJob(ctx context.Context, job Job) error {
ctx, cancel := context.WithTimeout(ctx, JobTimeout)
defer cancel()
res, err := w.RunSQLNamedQuery(ctx, job.Query)
res, err := w.steampipeConn.QueryAll(ctx, job.Query)
if err != nil {
return err
}
Expand All @@ -57,16 +57,19 @@ func (w *Worker) RunJob(ctx context.Context, job Job) error {
if tableName != "" {
queryResourceType, _, err = GetResourceTypeFromTableName(tableName, job.IntegrationType)
if err != nil {
w.logger.Error("Error getting resource type from table", zap.String("table_name", tableName), zap.Error(err))
return err
}
}
}
if queryResourceType == "" {
w.logger.Error("Error getting resource type from table")
return fmt.Errorf(string(MissingResourceTypeQueryError))
}

esIndex := ResourceTypeToESIndex(queryResourceType)
w.logger.Info("before getting data", zap.String("esIndex", esIndex))
w.logger.Info("before getting data", zap.String("esIndex", esIndex),
zap.String("query", job.Query), zap.Any("resp", res))
for _, record := range res.Data {
w.logger.Info("GettingData")
if len(record) != len(res.Headers) {
Expand Down

0 comments on commit c4341b5

Please sign in to comment.