Skip to content

Commit

Permalink
fix: add queries
Browse files Browse the repository at this point in the history
  • Loading branch information
artaasadi committed Dec 27, 2024
1 parent 70e4fd4 commit 393797e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion task/run-task.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ type Artifact struct {
func RunTask(ctx context.Context, inventoryServiceEndpoint string, esClient opengovernance.Client, logger *zap.Logger, request tasks.TaskRequest, response *scheduler.TaskResponse) error {
registryType := "ghcr"
var artifacts []Artifact
var artifactsUrls []string
var err error
if _, ok := request.TaskDefinition.Params["query_id"]; ok {
inventoryClient := inventoryClient.NewInventoryServiceClient(inventoryServiceEndpoint)
artifacts, err = GetArtifactsFromQueryID(inventoryClient, request.TaskDefinition.Params)
if err != nil {
return err
}
} else if _, ok := request.TaskDefinition.Params[""]; ok {
} else if _, ok := request.TaskDefinition.Params["query_to_execute"]; ok {
inventoryClient := inventoryClient.NewInventoryServiceClient(inventoryServiceEndpoint)
artifacts, err = GetArtifactsFromInlineQuery(inventoryClient, request.TaskDefinition.Params)
if err != nil {
Expand Down Expand Up @@ -69,6 +70,11 @@ func RunTask(ctx context.Context, inventoryServiceEndpoint string, esClient open
}
}

for _, ar := range artifacts {
artifactsUrls = append(artifactsUrls, ar.OciArtifactUrl)
}
logger.Info("running task on artifacts", zap.Strings("artifacts", artifactsUrls))

var ids []string
var index string
for _, artifact := range artifacts {
Expand Down
2 changes: 1 addition & 1 deletion worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var (
ESAwsRegion = os.Getenv(consts.ElasticSearchAwsRegionEnv)
ESAssumeRoleArn = os.Getenv(consts.ElasticSearchAssumeRoleArnEnv)

InventoryServiceEndpoint = os.Getenv("INVENTORY_BASEURL")
InventoryServiceEndpoint = os.Getenv(consts.InventoryBaseURL)
)

type Worker struct {
Expand Down

0 comments on commit 393797e

Please sign in to comment.