Skip to content

Commit

Permalink
Merge pull request eksctl-io#2709 from weaveworks/dot-git
Browse files Browse the repository at this point in the history
Trim .git suffix when adding deploy keys
  • Loading branch information
michaelbeaumont authored Oct 5, 2020
2 parents 35309c9 + 08850b6 commit eff895a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/gitops/deploykey/deploykey.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ func GetDeployKeyClient(ctx context.Context, url string) (gitprovider.DeployKeyC
return nil, errors.New("only GitHub URLs are currently supported")
}
githubToken := os.Getenv(githubTokenVariable)
if githubToken == "" {
return nil, errors.Errorf("%s not set", githubTokenVariable)
}
gh, err := github.NewClient(github.WithOAuth2Token(githubToken))
if err != nil {
return nil, err
Expand All @@ -31,12 +34,13 @@ func GetDeployKeyClient(ctx context.Context, url string) (gitprovider.DeployKeyC
if len(ownerRepo) != 2 {
return nil, errors.New("couldn't understand path of URL")
}
repoName := strings.TrimSuffix(ownerRepo[1], ".git")
rep, err := gh.UserRepositories().Get(ctx, gitprovider.UserRepositoryRef{
UserRef: gitprovider.UserRef{
Domain: github.DefaultDomain,
UserLogin: ownerRepo[0],
},
RepositoryName: ownerRepo[1],
RepositoryName: repoName,
})
if err != nil {
return nil, err
Expand Down

0 comments on commit eff895a

Please sign in to comment.