Skip to content

Commit

Permalink
chore: pass context from cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
patriknordlen committed Apr 9, 2024
1 parent a7c5db0 commit 5fa9be5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func main() {
Use: "gh dependabot",
Short: "Manage Dependabot PRs.",
Example: "gh dependabot --org einride",
RunE: func(_ *cobra.Command, _ []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
log.Println("Resolving current user...")
username, err := gh.Run("api", "graphql", "-f", "query={viewer{login}}", "--jq", ".data.viewer.login")
if err != nil {
Expand Down Expand Up @@ -57,7 +57,7 @@ func main() {

if securityFilter {
log.Printf("Matching pull requests to security alerts...")
pullRequests, err = filterSecurityPullRequests(client, &pullRequests)
pullRequests, err = filterSecurityPullRequests(cmd.Context(), client, &pullRequests)
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion securityfilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
)

func filterSecurityPullRequests(
ctx context.Context,
client *githubv4.Client,
pullRequests *[]pullRequest,
) ([]pullRequest, error) {
Expand All @@ -35,7 +36,7 @@ func filterSecurityPullRequests(
}
var vulnQ vulnQuery

if err := client.Query(context.Background(), &vulnQ, vulnVars); err != nil {
if err := client.Query(ctx, &vulnQ, vulnVars); err != nil {
return nil, fmt.Errorf("load vulnerability reports: %w", err)
}
for _, vulnAlert := range vulnQ.Repository.VulnerabilityAlerts.Nodes {
Expand Down

0 comments on commit 5fa9be5

Please sign in to comment.