Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
owenrumney authored and owenrumney-f3 committed Oct 29, 2020
1 parent db60e69 commit 7dcb366
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions cmd/commenter/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,34 @@ For more information, see https://tfsec.dev/docs/%s/%s/`, result.code, result.de
}
}

comment := &github.PullRequestComment{
Line: &result.startLine,
Path: &result.fileName,
CommitID: &result.sha,
Body: &errorMessage,
Position: &result.position,
}
comment := createComment(result, errorMessage)
fmt.Printf("%+v\n", comment)
_, _, err := gc.client.PullRequests.CreateComment(gc.ctx, gc.owner, gc.repo, gc.prNumber, comment)
if err != nil {
fmt.Println("Error occurred %s", err.Error())
}
}

func createComment(result *commentBlock, errorMessage string) *github.PullRequestComment {
if result.startLine == result.endLine {
return &github.PullRequestComment{
Line: &result.startLine,
Path: &result.fileName,
CommitID: &result.sha,
Body: &errorMessage,
Position: &result.position,
}
}
return &github.PullRequestComment{
StartLine: &result.startLine,
Line: &result.endLine,
Path: &result.fileName,
CommitID: &result.sha,
Body: &errorMessage,
Position: &result.position,
}
}

func getPrNumber() (int, error) {
file, err := ioutil.ReadFile("/github/workflow/event.json")
if err != nil {
Expand Down
Binary file added pr_commenter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7dcb366

Please sign in to comment.