Skip to content

Commit 92764f6

Browse files
authored
error handling while creating github repo (#5978)
1 parent d52be33 commit 92764f6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pkg/deployment/gitOps/git/GitServiceGithub.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,23 @@ func (impl GitHubClient) CreateRepository(ctx context.Context, config *bean2.Git
127127
}
128128
private := true
129129
// visibility := "private"
130-
r, _, err := impl.client.Repositories.Create(ctx, impl.org,
130+
r, _, err1 := impl.client.Repositories.Create(ctx, impl.org,
131131
&github.Repository{Name: &config.GitRepoName,
132132
Description: &config.Description,
133133
Private: &private,
134134
// Visibility: &visibility,
135135
})
136-
if err != nil {
136+
if err1 != nil {
137137
impl.logger.Errorw("error in creating github repo, ", "repo", config.GitRepoName, "err", err)
138-
detailedErrorGitOpsConfigActions.StageErrorMap[CreateRepoStage] = err
138+
139139
url, err = impl.GetRepoUrl(config)
140140
if err != nil {
141141
impl.logger.Errorw("error in getting github repo", "repo", config.GitRepoName, "err", err)
142+
detailedErrorGitOpsConfigActions.StageErrorMap[CreateRepoStage] = err1
142143
return "", true, detailedErrorGitOpsConfigActions
143144
}
145+
detailedErrorGitOpsConfigActions.SuccessfulStages = append(detailedErrorGitOpsConfigActions.SuccessfulStages, GetRepoUrlStage)
146+
return url, false, detailedErrorGitOpsConfigActions
144147
}
145148
impl.logger.Infow("github repo created ", "r", r.CloneURL)
146149
detailedErrorGitOpsConfigActions.SuccessfulStages = append(detailedErrorGitOpsConfigActions.SuccessfulStages, CreateRepoStage)

0 commit comments

Comments
 (0)