Skip to content

Commit

Permalink
Registry replacer: Add explanation in PR body
Browse files Browse the repository at this point in the history
  • Loading branch information
alvaroaleman committed Jul 9, 2020
1 parent 075b4a2 commit d98daf9
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions cmd/registry-replacer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func main() {
return
}

if err := upsertPR(githubClient, opts.configDir, opts.githubUserName, opts.TokenPath, opts.selfApprove); err != nil {
if err := upsertPR(githubClient, opts.configDir, opts.githubUserName, opts.TokenPath, opts.selfApprove, opts.pruneUnusedReplacements); err != nil {
logrus.WithError(err).Fatal("Failed to create PR")
}
}
Expand Down Expand Up @@ -309,7 +309,7 @@ func githubFileGetterFactory(org, repo, branch string) githubFileGetter {
}
}

func upsertPR(gc github.Client, dir, githubUsername, tokenFilePath string, selfApprove bool) error {
func upsertPR(gc github.Client, dir, githubUsername, tokenFilePath string, pruneUnusedReplacements, selfApprove bool) error {
if err := os.Chdir(dir); err != nil {
return fmt.Errorf("failed to chdir into %s: %w", dir, err)
}
Expand Down Expand Up @@ -351,12 +351,20 @@ func upsertPR(gc github.Client, dir, githubUsername, tokenFilePath string, selfA
logrus.Infof("Self-aproving PR by adding the %q and %q labels", labels.Approved, labels.LGTM)
labelsToAdd = append(labelsToAdd, labels.Approved, labels.LGTM)
}

prBody := `This PR:
* Adds a replacement of all FROM registry.svc.ci.openshift.org/anything directives found in any Dockerfile
to make sure all images are pulled from the build cluster registry`

if pruneUnusedReplacements {
prBody += "\n* Prunes existing replacements that do not match any FROM dircetive in the Dockerfile"
}
if err := bumper.UpdatePullRequestWithLabels(
gc,
"openshift",
"release",
prTitle,
"",
prBody,
prTitle,
githubUsername+":"+targetBranch,
"master",
Expand Down

0 comments on commit d98daf9

Please sign in to comment.