GitHub Realtime needs to be able to authenticate. This PR adds relevant fields to the relevant protobuf message, and exports/tweaks some stuff from the github source package to permit its (eventual) use by the GitHub Realtime implementation: The Connector interface and its constructors are now exported Connector.Clone now accepts additional clone arguments The github-specific connection construction has been moved into github.go The injected rate limit handler no longer accepts error reporters that it never uses I also added an API endpoint field to the GitHub Realtime proto message, because we need that too and I was here.
18 lines
639 B
Go
18 lines
639 B
Go
package github
|
|
|
|
import (
|
|
gogit "github.com/go-git/go-git/v5"
|
|
"github.com/google/go-github/v67/github"
|
|
"github.com/trufflesecurity/trufflehog/v3/pkg/context"
|
|
)
|
|
|
|
const cloudEndpoint = "https://api.github.com"
|
|
|
|
// Connector abstracts over the authenticated ways to interact with GitHub: cloning and API operations.
|
|
type Connector interface {
|
|
// APIClient returns a configured GitHub client that can be used for GitHub API operations.
|
|
APIClient() *github.Client
|
|
// Clone clones a repository using the configured authentication information.
|
|
Clone(ctx context.Context, repoURL string, args ...string) (string, *gogit.Repository, error)
|
|
}
|