Skip to content

Commit

Permalink
Remove searching issues by author (#286)
Browse files Browse the repository at this point in the history
Fixes #284
Follow-up to #282

All issues are now created with the searchable term which allows us to
avoid using specific users and can instead use the built-in
github-actions app principals.
  • Loading branch information
danielrbradley authored Nov 1, 2024
1 parent 4b8ee3d commit 77dae6c
Showing 1 changed file with 6 additions and 31 deletions.
37 changes: 6 additions & 31 deletions upgrade/steps_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -720,44 +720,14 @@ var createUpstreamUpgradeIssue = stepv2.Func30E("Ensure Upstream Issue", func(ct
})

func upgradeIssueExits(ctx context.Context, title, repoOrg, repoName string) (bool, error) {
var found bool
var err error
// TODO: Remove this after we've migrated all issues to the new format.
// https://github.com/pulumi/upgrade-provider/issues/284
// Fall back to searching through the issues from the current user.
found, err = issueExistsForVersion(ctx, title,
fmt.Sprintf("--repo=%s", repoOrg+"/"+repoName),
fmt.Sprintf("--search=%q", title),
"--state=open",
"--author=@me")
if err != nil {
return false, err
}
if found {
return true, nil
}

// Search through existing pulumiupgradeproviderissue issues to see if we've already created one for this version.
found, err = issueExistsForVersion(ctx, title,
issues, err := searchIssues(ctx,
fmt.Sprintf("--repo=%s", repoOrg+"/"+repoName),
fmt.Sprintf("--search=%q", upgradeIssueBodyTemplate),
"--state=open")
if err != nil {
return false, err
}
return found, nil
}

type issue struct {
Title string `json:"title"`
Number int `json:"number"`
}

func issueExistsForVersion(ctx context.Context, title string, searchArgs ...string) (bool, error) {
issues, err := searchIssues(ctx, searchArgs...)
if err != nil {
return false, err
}

// check for exact title match from search results
for _, issue := range issues {
Expand All @@ -768,6 +738,11 @@ func issueExistsForVersion(ctx context.Context, title string, searchArgs ...stri
return false, nil
}

type issue struct {
Title string `json:"title"`
Number int `json:"number"`
}

func searchIssues(ctx context.Context, args ...string) ([]issue, error) {
cmdArgs := []string{"issue", "list", "--json=title,number"}
cmdArgs = append(cmdArgs, args...)
Expand Down

0 comments on commit 77dae6c

Please sign in to comment.