Skip to content

Commit

Permalink
refactor(tags): send build id and run as dedicated field (#107)
Browse files Browse the repository at this point in the history
Also removed duplicate code in tmp dir create

Co-authored-by: oranmoshai <oran.moshai@aquasec.com>
  • Loading branch information
oranmoshai and oranmoshai authored May 12, 2022
1 parent 7578ae2 commit 711e0d7
Show file tree
Hide file tree
Showing 6 changed files with 249 additions and 240 deletions.
13 changes: 2 additions & 11 deletions pkg/buildClient/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,6 @@ func (bc *TwirpClient) Upload(results []*buildsecurity.Result, tags map[string]s
buildSystem := metadata.GetBuildSystem()

run, buildID := metadata.GetBuildInfo(buildSystem)
// add tags only if not exist and allow override
if _, ok := tags["run"]; !ok {
if run != "" {
tags["run"] = run
}
}
if _, ok := tags["build_id"]; !ok {
if buildID != "" {
tags["build_id"] = buildID
}
}

createScanReq := &buildsecurity.CreateScanReq{
RepositoryID: bc.repoId,
Expand All @@ -49,6 +38,8 @@ func (bc *TwirpClient) Upload(results []*buildsecurity.Result, tags map[string]s
System: buildSystem,
Tags: tags,
TriggeredBy: scanner.MatchTriggeredBy(bc.c.String("triggered-by")),
Run: run,
BuildID: buildID,
}

_, err = client.CreateScan(ctx, createScanReq)
Expand Down
2 changes: 2 additions & 0 deletions pkg/proto/buildsecurity.proto
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ message CreateScanReq {
repeated Result Results = 7;
map<string, string> Tags = 8;
TriggeredByEnum TriggeredBy = 9;
string Run = 10;
string BuildID = 11;
}

enum TriggeredByEnum {
Expand Down
Loading

0 comments on commit 711e0d7

Please sign in to comment.