Skip to content

Commit

Permalink
chore: support github enterprise token (#84)
Browse files Browse the repository at this point in the history
supoprt github enterprise token support

Signed-off-by: Zach Aller <[email protected]>
  • Loading branch information
zachaller authored Oct 25, 2024
1 parent 93faf3a commit 59f12a2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions internal/scms/github/git_operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ func NewGithubGitAuthenticationProvider(scmProvider *v1alpha1.ScmProvider, secre
panic(err)
}

if scmProvider.Spec.GitHub != nil && scmProvider.Spec.GitHub.Domain != "" {
itr.BaseURL = fmt.Sprintf("https://%s/api/v3", scmProvider.Spec.GitHub.Domain)
}

return GitAuthenticationProvider{
scmProvider: scmProvider,
secret: secret,
Expand All @@ -44,10 +48,10 @@ func NewGithubGitAuthenticationProvider(scmProvider *v1alpha1.ScmProvider, secre
}

func (gh GitAuthenticationProvider) GetGitHttpsRepoUrl(gitRepository v1alpha1.GitRepository) string {
if gh.scmProvider.Spec.GitHub != nil && gh.scmProvider.Spec.GitHub.Domain == "" {
return fmt.Sprintf("https://git@github.com/%s/%s.git", gitRepository.Spec.Owner, gitRepository.Spec.Name)
if gh.scmProvider.Spec.GitHub != nil && gh.scmProvider.Spec.GitHub.Domain != "" {
return fmt.Sprintf("https://git@%s/%s/%s.git", gh.scmProvider.Spec.GitHub.Domain, gitRepository.Spec.Owner, gitRepository.Spec.Name)
}
return fmt.Sprintf("https://git@%s/%s/%s.git", gh.scmProvider.Spec.GitHub.Domain, gitRepository.Spec.Owner, gitRepository.Spec.Name)
return fmt.Sprintf("https://git@github.com/%s/%s.git", gitRepository.Spec.Owner, gitRepository.Spec.Name)
}

func (gh GitAuthenticationProvider) GetToken(ctx context.Context) (string, error) {
Expand Down

0 comments on commit 59f12a2

Please sign in to comment.