diff --git a/internal/pkg/argocd/argocd.go b/internal/pkg/argocd/argocd.go index ae63f207..3d3175f8 100644 --- a/internal/pkg/argocd/argocd.go +++ b/internal/pkg/argocd/argocd.go @@ -277,7 +277,7 @@ func findArgocdAppByManifestPathAnnotation(ctx context.Context, componentPath st getAppsStart := time.Now() allRepoApps, err := appClient.List(ctx, &appQuery) getAppsDuration := time.Since(getAppsStart).Milliseconds() - log.Infof("Got %v ArgoCD applications for repo %s in %v ms", len(allRepoApps.Items), repo, getAppsDuration) + log.Debugf("Got %v ArgoCD applications for repo %s in %v ms", len(allRepoApps.Items), repo, getAppsDuration) if err != nil { return nil, err } diff --git a/internal/pkg/githubapi/clients.go b/internal/pkg/githubapi/clients.go index a0bb9cbd..33f2ea30 100644 --- a/internal/pkg/githubapi/clients.go +++ b/internal/pkg/githubapi/clients.go @@ -132,7 +132,6 @@ func createGithubGraphQlClient(githubOauthToken string, githubGraphqlAltURL stri } func createGhAppClientPair(ctx context.Context, githubAppId int64, owner string, ghAppPKeyPathEnvVarName string) GhClientPair { - // var ghClientPair *GhClientPair var githubRestAltURL string var githubGraphqlAltURL string githubAppPrivateKeyPath := getCrucialEnv(ghAppPKeyPathEnvVarName) @@ -151,8 +150,6 @@ func createGhAppClientPair(ctx context.Context, githubAppId int64, owner string, log.Errorf("Couldn't find installation for app ID %v and repo owner %s", githubAppId, owner) } - // ghClientPair.v3Client := createGithubAppRestClient(githubAppPrivateKeyPath, githubAppId, githubAppInstallationId, githubRestAltURL, ctx) - // ghClientPair.v4Client := createGithubAppGraphQlClient(githubAppPrivateKeyPath, githubAppId, githubAppInstallationId, githubGraphqlAltURL, githubRestAltURL, ctx) return GhClientPair{ v3Client: createGithubAppRestClient(githubAppPrivateKeyPath, githubAppId, githubAppInstallationId, githubRestAltURL, ctx), v4Client: createGithubAppGraphQlClient(githubAppPrivateKeyPath, githubAppId, githubAppInstallationId, githubGraphqlAltURL, githubRestAltURL, ctx), @@ -160,7 +157,6 @@ func createGhAppClientPair(ctx context.Context, githubAppId int64, owner string, } func createGhTokenClientPair(ctx context.Context, ghOauthToken string) GhClientPair { - // var ghClientPair *GhClientPair var githubRestAltURL string var githubGraphqlAltURL string githubHost := getEnv("GITHUB_HOST", "") @@ -173,8 +169,6 @@ func createGhTokenClientPair(ctx context.Context, ghOauthToken string) GhClientP log.Debugf("Using public Github API endpoint") } - // ghClientPair.v3Client := createGithubRestClient(ghOauthToken, githubRestAltURL, ctx) - // ghClientPair.v4Client := createGithubGraphQlClient(ghOauthToken, githubGraphqlAltURL) return GhClientPair{ v3Client: createGithubRestClient(ghOauthToken, githubRestAltURL, ctx), v4Client: createGithubGraphQlClient(ghOauthToken, githubGraphqlAltURL), diff --git a/internal/pkg/githubapi/github.go b/internal/pkg/githubapi/github.go index 338c5910..4d509984 100644 --- a/internal/pkg/githubapi/github.go +++ b/internal/pkg/githubapi/github.go @@ -75,11 +75,6 @@ func (pm prMetadata) serialize() (string, error) { if err != nil { return "", err } - // var compressedPmJson []byte - // _, err = lz4.CompressBlock(pmJson, compressedPmJson, nil) - // if err != nil { - // return "", err - // } return base64.StdEncoding.EncodeToString(pmJson), nil } @@ -127,132 +122,157 @@ func shouldSyncBranchCheckBoxBeDisplayed(componentPathList []string, allowSyncfr } func HandlePREvent(eventPayload *github.PullRequestEvent, ghPrClientDetails GhPrClientDetails, mainGithubClientPair GhClientPair, approverGithubClientPair GhClientPair, ctx context.Context) { + defer func() { + if r := recover(); r != nil { + ghPrClientDetails.PrLogger.Errorf("Recovered: %v", r) + } + }() + ghPrClientDetails.getPrMetadata(eventPayload.PullRequest.GetBody()) - // wasCommitStatusSet and the placement of SetCommitStatus in the flow is used to ensure an API call is only made where it needed - wasCommitStatusSet := false - var prHandleError error + stat, ok := eventToHandle(eventPayload) + if !ok { + // nothing to do + return + } + + SetCommitStatus(ghPrClientDetails, "pending") + + var err error + + defer func() { + if err != nil { + SetCommitStatus(ghPrClientDetails, "error") + return + } + SetCommitStatus(ghPrClientDetails, "success") + }() + switch stat { + case "merged": + err = handleMergedPrEvent(ghPrClientDetails, approverGithubClientPair.v3Client) + case "changed": + err = handleChangedPREvent(ctx, mainGithubClientPair, ghPrClientDetails, eventPayload) + case "show-plan": + err = handleShowPlanPREvent(ctx, ghPrClientDetails, eventPayload) + } + + if err != nil { + ghPrClientDetails.PrLogger.Errorf("Handling of PR event failed: err=%s\n", err) + } +} + +// eventToHandle returns the event to be handled, translated from a Github +// world into the Telefonistka world. If no event should be handled, ok is +// false. +func eventToHandle(eventPayload *github.PullRequestEvent) (event string, ok bool) { + switch { + case *eventPayload.Action == "closed" && *eventPayload.PullRequest.Merged: + return "merged", true + case *eventPayload.Action == "opened" || *eventPayload.Action == "reopened" || *eventPayload.Action == "synchronize": + return "changed", true + case *eventPayload.Action == "labeled" && DoesPrHasLabel(eventPayload.PullRequest.Labels, "show-plan"): + return "show-plan", true + default: + return "", false + } +} + +func handleShowPlanPREvent(ctx context.Context, ghPrClientDetails GhPrClientDetails, eventPayload *github.PullRequestEvent) error { + ghPrClientDetails.PrLogger.Infoln("Found show-plan label, posting plan") defaultBranch, _ := ghPrClientDetails.GetDefaultBranch() config, err := GetInRepoConfig(ghPrClientDetails, defaultBranch) if err != nil { - ghPrClientDetails.PrLogger.Infof("Couldn't get Telefonistka in-repo configuration: %v", err) + return fmt.Errorf("get in-repo configuration: %w", err) } + promotions, _ := GeneratePromotionPlan(ghPrClientDetails, config, *eventPayload.PullRequest.Head.Ref) + commentPlanInPR(ghPrClientDetails, promotions) + return nil +} - if *eventPayload.Action == "closed" && *eventPayload.PullRequest.Merged { - SetCommitStatus(ghPrClientDetails, "pending") - wasCommitStatusSet = true - err := handleMergedPrEvent(ghPrClientDetails, approverGithubClientPair.v3Client) - if err != nil { - prHandleError = err - ghPrClientDetails.PrLogger.Errorf("Handling of merged PR failed: err=%s\n", err) - } - } else if *eventPayload.Action == "opened" || *eventPayload.Action == "reopened" || *eventPayload.Action == "synchronize" { - SetCommitStatus(ghPrClientDetails, "pending") - wasCommitStatusSet = true - botIdentity, _ := GetBotGhIdentity(mainGithubClientPair.v4Client, ctx) - err = MimizeStalePrComments(ghPrClientDetails, mainGithubClientPair.v4Client, botIdentity) +func handleChangedPREvent(ctx context.Context, mainGithubClientPair GhClientPair, ghPrClientDetails GhPrClientDetails, eventPayload *github.PullRequestEvent) error { + botIdentity, _ := GetBotGhIdentity(mainGithubClientPair.v4Client, ctx) + err := MimizeStalePrComments(ghPrClientDetails, mainGithubClientPair.v4Client, botIdentity) + if err != nil { + return fmt.Errorf("minimizing stale PR comments: %w", err) + } + defaultBranch, _ := ghPrClientDetails.GetDefaultBranch() + config, err := GetInRepoConfig(ghPrClientDetails, defaultBranch) + if err != nil { + return fmt.Errorf("get in-repo configuration: %w", err) + } + if config.Argocd.CommentDiffonPR { + componentPathList, err := generateListOfChangedComponentPaths(ghPrClientDetails, config) if err != nil { - prHandleError = err - ghPrClientDetails.PrLogger.Errorf("Failed to minimize stale comments: err=%s\n", err) + return fmt.Errorf("generate list of changed components: %w", err) } - if config.Argocd.CommentDiffonPR { - componentPathList, err := generateListOfChangedComponentPaths(ghPrClientDetails, config) + + // Building a map component's path and a boolean value that indicates if we should diff it not. + // I'm avoiding doing this in the ArgoCD package to avoid circular dependencies and keep package scope clean + componentsToDiff := map[string]bool{} + for _, componentPath := range componentPathList { + c, err := getComponentConfig(ghPrClientDetails, componentPath, ghPrClientDetails.Ref) if err != nil { - prHandleError = err - ghPrClientDetails.PrLogger.Errorf("Failed to get list of changed components: err=%s\n", err) + return fmt.Errorf("get component (%s) config: %w", componentPath, err) } - - // Building a map component's path and a boolean value that indicates if we should diff it not. - // I'm avoiding doing this in the ArgoCD package to avoid circular dependencies and keep package scope clean - componentsToDiff := map[string]bool{} - for _, componentPath := range componentPathList { - c, err := getComponentConfig(ghPrClientDetails, componentPath, ghPrClientDetails.Ref) - if err != nil { - prHandleError = fmt.Errorf("Failed to get component config(%s): err=%s\n", componentPath, err) - ghPrClientDetails.PrLogger.Error(prHandleError) - } else { - if c.DisableArgoCDDiff { - componentsToDiff[componentPath] = false - ghPrClientDetails.PrLogger.Debugf("ArgoCD diff disabled for %s\n", componentPath) - } else { - componentsToDiff[componentPath] = true - } - } + componentsToDiff[componentPath] = true + if c.DisableArgoCDDiff { + componentsToDiff[componentPath] = false + ghPrClientDetails.PrLogger.Debugf("ArgoCD diff disabled for %s\n", componentPath) } - hasComponentDiff, hasComponentDiffErrors, diffOfChangedComponents, err := argocd.GenerateDiffOfChangedComponents(ctx, componentsToDiff, ghPrClientDetails.Ref, ghPrClientDetails.RepoURL, config.Argocd.UseSHALabelForAppDiscovery, config.Argocd.CreateTempAppObjectFroNewApps) + } + hasComponentDiff, hasComponentDiffErrors, diffOfChangedComponents, err := argocd.GenerateDiffOfChangedComponents(ctx, componentsToDiff, ghPrClientDetails.Ref, ghPrClientDetails.RepoURL, config.Argocd.UseSHALabelForAppDiscovery, config.Argocd.CreateTempAppObjectFroNewApps) + if err != nil { + return fmt.Errorf("getting diff information: %w", err) + } + ghPrClientDetails.PrLogger.Debugf("Successfully got ArgoCD diff(comparing live objects against objects rendered form git ref %s)", ghPrClientDetails.Ref) + if !hasComponentDiffErrors && !hasComponentDiff { + ghPrClientDetails.PrLogger.Debugf("ArgoCD diff is empty, this PR will not change cluster state\n") + prLables, resp, err := ghPrClientDetails.GhClientPair.v3Client.Issues.AddLabelsToIssue(ghPrClientDetails.Ctx, ghPrClientDetails.Owner, ghPrClientDetails.Repo, *eventPayload.PullRequest.Number, []string{"noop"}) + prom.InstrumentGhCall(resp) if err != nil { - prHandleError = err - ghPrClientDetails.PrLogger.Errorf("Failed to get ArgoCD diff information: err=%s\n", err) + ghPrClientDetails.PrLogger.Errorf("Could not label GitHub PR: err=%s\n%v\n", err, resp) } else { - ghPrClientDetails.PrLogger.Debugf("Successfully got ArgoCD diff(comparing live objects against objects rendered form git ref %s)", ghPrClientDetails.Ref) - if !hasComponentDiffErrors && !hasComponentDiff { - ghPrClientDetails.PrLogger.Debugf("ArgoCD diff is empty, this PR will not change cluster state\n") - prLables, resp, err := ghPrClientDetails.GhClientPair.v3Client.Issues.AddLabelsToIssue(ghPrClientDetails.Ctx, ghPrClientDetails.Owner, ghPrClientDetails.Repo, *eventPayload.PullRequest.Number, []string{"noop"}) - prom.InstrumentGhCall(resp) - if err != nil { - ghPrClientDetails.PrLogger.Errorf("Could not label GitHub PR: err=%s\n%v\n", err, resp) - } else { - ghPrClientDetails.PrLogger.Debugf("PR %v labeled\n%+v", *eventPayload.PullRequest.Number, prLables) - } - // If the PR is a promotion PR and the diff is empty, we can auto-merge it - // "len(componentPathList) > 0" validates we are not auto-merging a PR that we failed to understand which apps it affects - if DoesPrHasLabel(*eventPayload, "promotion") && config.Argocd.AutoMergeNoDiffPRs && len(componentPathList) > 0 { - ghPrClientDetails.PrLogger.Infof("Auto-merging (no diff) PR %d", *eventPayload.PullRequest.Number) - err := MergePr(ghPrClientDetails, eventPayload.PullRequest.Number) - if err != nil { - prHandleError = err - ghPrClientDetails.PrLogger.Errorf("PR auto merge failed: err=%v", err) - } - } + ghPrClientDetails.PrLogger.Debugf("PR %v labeled\n%+v", *eventPayload.PullRequest.Number, prLables) + } + // If the PR is a promotion PR and the diff is empty, we can auto-merge it + // "len(componentPathList) > 0" validates we are not auto-merging a PR that we failed to understand which apps it affects + if DoesPrHasLabel(eventPayload.PullRequest.Labels, "promotion") && config.Argocd.AutoMergeNoDiffPRs && len(componentPathList) > 0 { + ghPrClientDetails.PrLogger.Infof("Auto-merging (no diff) PR %d", *eventPayload.PullRequest.Number) + err := MergePr(ghPrClientDetails, eventPayload.PullRequest.Number) + if err != nil { + return fmt.Errorf("PR auto merge: %w", err) } } + } - if len(diffOfChangedComponents) > 0 { - diffCommentData := DiffCommentData{ - DiffOfChangedComponents: diffOfChangedComponents, - BranchName: ghPrClientDetails.Ref, - } + if len(diffOfChangedComponents) > 0 { + diffCommentData := DiffCommentData{ + DiffOfChangedComponents: diffOfChangedComponents, + BranchName: ghPrClientDetails.Ref, + } - diffCommentData.DisplaySyncBranchCheckBox = shouldSyncBranchCheckBoxBeDisplayed(componentPathList, config.Argocd.AllowSyncfromBranchPathRegex, diffOfChangedComponents) + diffCommentData.DisplaySyncBranchCheckBox = shouldSyncBranchCheckBoxBeDisplayed(componentPathList, config.Argocd.AllowSyncfromBranchPathRegex, diffOfChangedComponents) - comments, err := generateArgoCdDiffComments(diffCommentData, githubCommentMaxSize) + comments, err := generateArgoCdDiffComments(diffCommentData, githubCommentMaxSize) + if err != nil { + return fmt.Errorf("generate diff comment: %w", err) + } + for _, comment := range comments { + err = commentPR(ghPrClientDetails, comment) if err != nil { - prHandleError = err - ghPrClientDetails.PrLogger.Errorf("Failed to comment ArgoCD diff: err=%s\n", err) - } - for _, comment := range comments { - err = commentPR(ghPrClientDetails, comment) - if err != nil { - prHandleError = err - ghPrClientDetails.PrLogger.Errorf("Failed to comment on PR: err=%s\n", err) - } + return fmt.Errorf("commenting on PR: %w", err) } - } else { - ghPrClientDetails.PrLogger.Debugf("Diff not find affected ArogCD apps") } - } - ghPrClientDetails.PrLogger.Infoln("Checking for Drift") - err = DetectDrift(ghPrClientDetails) - if err != nil { - prHandleError = err - ghPrClientDetails.PrLogger.Errorf("Drift detection failed: err=%s\n", err) - } - } else if *eventPayload.Action == "labeled" && DoesPrHasLabel(*eventPayload, "show-plan") { - SetCommitStatus(ghPrClientDetails, "pending") - wasCommitStatusSet = true - ghPrClientDetails.PrLogger.Infoln("Found show-plan label, posting plan") - promotions, _ := GeneratePromotionPlan(ghPrClientDetails, config, *eventPayload.PullRequest.Head.Ref) - commentPlanInPR(ghPrClientDetails, promotions) - } - - if wasCommitStatusSet { - if prHandleError == nil { - SetCommitStatus(ghPrClientDetails, "success") } else { - SetCommitStatus(ghPrClientDetails, "error") + ghPrClientDetails.PrLogger.Debugf("Diff not find affected ArogCD apps") } } + err = DetectDrift(ghPrClientDetails) + if err != nil { + return fmt.Errorf("detecting drift: %w", err) + } + return nil } func generateArgoCdDiffComments(diffCommentData DiffCommentData, githubCommentMaxSize int) (comments []string, err error) { @@ -316,7 +336,7 @@ func ReciveEventFile(eventType string, eventFilePath string, mainGhClientCache * r.Header.Set("Content-Type", "application/json") r.Header.Set("X-GitHub-Event", eventType) - handleEvent(eventPayloadInterface, mainGhClientCache, prApproverGhClientCache, r, payload, eventType) + handleEvent(eventPayloadInterface, mainGhClientCache, prApproverGhClientCache, r, payload) } // ReciveWebhook is the main entry point for the webhook handling it starts parases the webhook payload and start a thread to handle the event success/failure are dependant on the payload parsing only @@ -337,11 +357,11 @@ func ReciveWebhook(r *http.Request, mainGhClientCache *lru.Cache[string, GhClien } prom.InstrumentWebhookHit("successful") - go handleEvent(eventPayloadInterface, mainGhClientCache, prApproverGhClientCache, r, payload, eventType) + go handleEvent(eventPayloadInterface, mainGhClientCache, prApproverGhClientCache, r, payload) return nil } -func handleEvent(eventPayloadInterface interface{}, mainGhClientCache *lru.Cache[string, GhClientPair], prApproverGhClientCache *lru.Cache[string, GhClientPair], r *http.Request, payload []byte, eventType string) { +func handleEvent(eventPayloadInterface interface{}, mainGhClientCache *lru.Cache[string, GhClientPair], prApproverGhClientCache *lru.Cache[string, GhClientPair], r *http.Request, payload []byte) { // We don't use the request context as it might have a short deadline and we don't want to stop event handling based on that // But we do want to stop the event handling after a certain point, so: ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second) @@ -349,10 +369,11 @@ func handleEvent(eventPayloadInterface interface{}, mainGhClientCache *lru.Cache var mainGithubClientPair GhClientPair var approverGithubClientPair GhClientPair + log.Infof("Handling event type %T", eventPayloadInterface) + switch eventPayload := eventPayloadInterface.(type) { case *github.PushEvent: // this is a commit push, do something with it? - log.Infoln("is PushEvent") repoOwner := *eventPayload.Repo.Owner.Login mainGithubClientPair.GetAndCache(mainGhClientCache, "GITHUB_APP_ID", "GITHUB_APP_PRIVATE_KEY_PATH", "GITHUB_OAUTH_TOKEN", repoOwner, ctx) @@ -374,8 +395,9 @@ func handleEvent(eventPayloadInterface interface{}, mainGhClientCache *lru.Cache log.Infof("is PullRequestEvent(%s)", *eventPayload.Action) prLogger := log.WithFields(log.Fields{ - "repo": *eventPayload.Repo.Owner.Login + "/" + *eventPayload.Repo.Name, - "prNumber": *eventPayload.PullRequest.Number, + "repo": *eventPayload.Repo.Owner.Login + "/" + *eventPayload.Repo.Name, + "prNumber": *eventPayload.PullRequest.Number, + "event_type": "pr", }) repoOwner := *eventPayload.Repo.Owner.Login @@ -404,10 +426,10 @@ func handleEvent(eventPayloadInterface interface{}, mainGhClientCache *lru.Cache mainGithubClientPair.GetAndCache(mainGhClientCache, "GITHUB_APP_ID", "GITHUB_APP_PRIVATE_KEY_PATH", "GITHUB_OAUTH_TOKEN", repoOwner, ctx) botIdentity, _ := GetBotGhIdentity(mainGithubClientPair.v4Client, ctx) - log.Infof("Actionable event type %s\n", eventType) prLogger := log.WithFields(log.Fields{ - "repo": *eventPayload.Repo.Owner.Login + "/" + *eventPayload.Repo.Name, - "prNumber": *eventPayload.Issue.Number, + "repo": *eventPayload.Repo.Owner.Login + "/" + *eventPayload.Repo.Name, + "prNumber": *eventPayload.Issue.Number, + "event_type": "issue_comment", }) // Ignore comment events sent by the bot (this is about who trigger the event not who wrote the comment) if *eventPayload.Sender.Login != botIdentity { @@ -427,7 +449,6 @@ func handleEvent(eventPayloadInterface interface{}, mainGhClientCache *lru.Cache } default: - log.Infof("Non-actionable event type %s", eventType) return } } @@ -598,7 +619,6 @@ func handleMergedPrEvent(ghPrClientDetails GhPrClientDetails, prApproverGithubCl // configBranch = default branch as the PR is closed at this and its branch deleted. // If we'l ever want to generate this plan on an unmerged PR the PR branch (ghPrClientDetails.Ref) should be used promotions, _ := GeneratePromotionPlan(ghPrClientDetails, config, defaultBranch) - // log.Infof("%+v", promotions) if !config.DryRunMode { for _, promotion := range promotions { // TODO this whole part shouldn't be in main, but I need to refactor some circular dep's @@ -764,10 +784,6 @@ func (pm *prMetadata) DeSerialize(s string) error { if err != nil { return err } - // _, err = lz4.UncompressBlock(decoded, unCompressedPmJson) - // if err != nil { - // return err - // } err = json.Unmarshal(decoded, pm) return err } @@ -784,15 +800,13 @@ func (p GhPrClientDetails) CommentOnPr(commentBody string) error { return err } -func DoesPrHasLabel(eventPayload github.PullRequestEvent, name string) bool { - result := false - for _, prLabel := range eventPayload.PullRequest.Labels { - if *prLabel.Name == name { - result = true - break +func DoesPrHasLabel(labels []*github.Label, name string) bool { + for _, l := range labels { + if *l.Name == name { + return true } } - return result + return false } func (p *GhPrClientDetails) ToggleCommitStatus(context string, user string) error { @@ -836,7 +850,7 @@ func (p *GhPrClientDetails) ToggleCommitStatus(context string, user string) erro func SetCommitStatus(ghPrClientDetails GhPrClientDetails, state string) { // TODO change all these values - context := "telefonistka" + tcontext := "telefonistka" avatarURL := "https://avatars.githubusercontent.com/u/1616153?s=64" description := "Telefonistka GitOps Bot" targetURL := commitStatusTargetURL(time.Now()) @@ -845,11 +859,17 @@ func SetCommitStatus(ghPrClientDetails GhPrClientDetails, state string) { TargetURL: &targetURL, Description: &description, State: &state, - Context: &context, + Context: &tcontext, AvatarURL: &avatarURL, } ghPrClientDetails.PrLogger.Debugf("Setting commit %s status to %s", ghPrClientDetails.PrSHA, state) - _, resp, err := ghPrClientDetails.GhClientPair.v3Client.Repositories.CreateStatus(ghPrClientDetails.Ctx, ghPrClientDetails.Owner, ghPrClientDetails.Repo, ghPrClientDetails.PrSHA, commitStatus) + + // use a separate context to avoid event processing timeout to cause + // failures in updating the commit status + ctx, cancel := context.WithTimeout(context.Background(), time.Minute) + defer cancel() + + _, resp, err := ghPrClientDetails.GhClientPair.v3Client.Repositories.CreateStatus(ctx, ghPrClientDetails.Owner, ghPrClientDetails.Repo, ghPrClientDetails.PrSHA, commitStatus) prom.InstrumentGhCall(resp) if err != nil { ghPrClientDetails.PrLogger.Errorf("Failed to set commit status: err=%s\n%v", err, resp) @@ -1195,19 +1215,6 @@ func createPrObject(ghPrClientDetails GhPrClientDetails, newBranchRef string, ne ghPrClientDetails.PrLogger.Debugf(" %s was set as assignee on PR", assignee) } - // reviewers := github.ReviewersRequest{ - // Reviewers: []string{"SA-k8s-pr-approver-bot"}, // TODO remove hardcoding - // } - // - // _, resp, err = ghPrClientDetails.Ghclient.PullRequests.RequestReviewers(ghPrClientDetails.Ctx, ghPrClientDetails.Owner, ghPrClientDetails.Repo, *pull.Number, reviewers) - // prom.InstrumentGhCall(resp) - // if err != nil { - // ghPrClientDetails.PrLogger.Errorf("Could not set reviewer on pr: err=%s\n%v\n", err, resp) - // return pull, err - // } else { - // ghPrClientDetails.PrLogger.Debugf("PR reviewer set.\n%+v", reviewers) - // } - return pull, nil // TODO } diff --git a/internal/pkg/githubapi/promotion.go b/internal/pkg/githubapi/promotion.go index aac4edbe..4d5bbbac 100644 --- a/internal/pkg/githubapi/promotion.go +++ b/internal/pkg/githubapi/promotion.go @@ -51,6 +51,7 @@ func contains(s []string, str string) bool { } func DetectDrift(ghPrClientDetails GhPrClientDetails) error { + ghPrClientDetails.PrLogger.Debugln("Checking for Drift") if ghPrClientDetails.Ctx.Err() != nil { return ghPrClientDetails.Ctx.Err() }