Documentation
¶
Overview ¶
Package clients contains github client logic
Index ¶
- Constants
- Variables
- func NewGitHubAppProvider(cfg *minderv1.GitHubAppProviderConfig, appConfig *server.GitHubAppConfig, ...) (*github.GitHub, error)
- func NewRestClient(cfg *minderv1.GitHubProviderConfig, restClientCache ratecache.RestClientCache, ...) (*github.GitHub, error)
- func ParseV1AppConfig(rawCfg json.RawMessage) (*minderv1.GitHubAppProviderConfig, error)
- func ParseV1OAuthConfig(rawCfg json.RawMessage) (*minderv1.GitHubProviderConfig, error)
- type GitHubAppDelegate
- func (g *GitHubAppDelegate) GetCredential() provifv1.GitHubCredential
- func (g *GitHubAppDelegate) GetLogin(ctx context.Context) (string, error)
- func (g *GitHubAppDelegate) GetName(_ context.Context) (string, error)
- func (_ *GitHubAppDelegate) GetOwner() string
- func (g *GitHubAppDelegate) GetPrimaryEmail(ctx context.Context) (string, error)
- func (g *GitHubAppDelegate) GetUserId(ctx context.Context) (int64, error)
- func (g *GitHubAppDelegate) IsOrg() bool
- func (g *GitHubAppDelegate) ListAllRepositories(ctx context.Context) ([]*minderv1.Repository, error)
- type GitHubClientFactory
- type GitHubOAuthDelegate
- func (o *GitHubOAuthDelegate) GetCredential() provifv1.GitHubCredential
- func (o *GitHubOAuthDelegate) GetLogin(ctx context.Context) (string, error)
- func (o *GitHubOAuthDelegate) GetName(ctx context.Context) (string, error)
- func (o *GitHubOAuthDelegate) GetOwner() string
- func (o *GitHubOAuthDelegate) GetPrimaryEmail(ctx context.Context) (string, error)
- func (o *GitHubOAuthDelegate) GetUserId(ctx context.Context) (int64, error)
- func (o *GitHubOAuthDelegate) IsOrg() bool
- func (o *GitHubOAuthDelegate) ListAllRepositories(ctx context.Context) ([]*minderv1.Repository, error)
Constants ¶
const Github = "github"
Github is the string that represents the GitHubOAuth provider
const GithubApp = "github-app"
GithubApp is the string that represents the GitHubApp provider
Variables ¶
var AppAuthorizationFlows = []db.AuthorizationFlow{ db.AuthorizationFlowGithubAppFlow, }
AppAuthorizationFlows is the list of authorization flows that the GitHubOAuth provider supports
var AppImplements = []db.ProviderType{ db.ProviderTypeGithub, db.ProviderTypeGit, db.ProviderTypeRest, db.ProviderTypeRepoLister, }
AppImplements is the list of provider types that the GitHubOAuth provider implements
var OAuthAuthorizationFlows = []db.AuthorizationFlow{ db.AuthorizationFlowUserInput, db.AuthorizationFlowOauth2AuthorizationCodeFlow, }
OAuthAuthorizationFlows is the list of authorization flows that the GitHubOAuth provider supports
var OAuthImplements = []db.ProviderType{ db.ProviderTypeGithub, db.ProviderTypeGit, db.ProviderTypeRest, db.ProviderTypeRepoLister, }
OAuthImplements is the list of provider types that the GitHubOAuth provider implements
Functions ¶
func NewGitHubAppProvider ¶ added in v0.0.49
func NewGitHubAppProvider( cfg *minderv1.GitHubAppProviderConfig, appConfig *server.GitHubAppConfig, restClientCache ratecache.RestClientCache, credential provifv1.GitHubCredential, packageListingClient *gogithub.Client, ghClientFactory GitHubClientFactory, isOrg bool, ) (*github.GitHub, error)
NewGitHubAppProvider creates a new GitHub App API client BaseURL defaults to the public GitHub API, if needing to use a customer domain endpoint (as is the case with GitHub Enterprise), set the Endpoint field in the GitHubConfig struct
func NewRestClient ¶ added in v0.0.49
func NewRestClient( cfg *minderv1.GitHubProviderConfig, restClientCache ratecache.RestClientCache, credential provifv1.GitHubCredential, ghClientFactory GitHubClientFactory, owner string, ) (*github.GitHub, error)
NewRestClient creates a new GitHub REST API client BaseURL defaults to the public GitHub API, if needing to use a customer domain endpoint (as is the case with GitHub Enterprise), set the Endpoint field in the GitHubConfig struct
func ParseV1AppConfig ¶ added in v0.0.49
func ParseV1AppConfig(rawCfg json.RawMessage) (*minderv1.GitHubAppProviderConfig, error)
ParseV1AppConfig parses the raw config into a GitHubAppProviderConfig struct
func ParseV1OAuthConfig ¶ added in v0.0.49
func ParseV1OAuthConfig(rawCfg json.RawMessage) (*minderv1.GitHubProviderConfig, error)
ParseV1OAuthConfig parses the raw config into a GitHubConfig struct
Types ¶
type GitHubAppDelegate ¶ added in v0.0.49
type GitHubAppDelegate struct {
// contains filtered or unexported fields
}
GitHubAppDelegate is the struct that contains the GitHub App specific operations
func NewAppDelegate ¶ added in v0.0.49
func NewAppDelegate( client *gogithub.Client, credential provifv1.GitHubCredential, appName string, defaultUserId int64, isOrg bool, ) *GitHubAppDelegate
NewAppDelegate creates a GitHubOAuthDelegate from a GitHub client This exists as a separate function to allow the provider creation code to use its methods without instantiating a full provider.
func (*GitHubAppDelegate) GetCredential ¶ added in v0.0.49
func (g *GitHubAppDelegate) GetCredential() provifv1.GitHubCredential
GetCredential returns the GitHub App installation credential
func (*GitHubAppDelegate) GetLogin ¶ added in v0.0.49
func (g *GitHubAppDelegate) GetLogin(ctx context.Context) (string, error)
GetLogin returns the username for the GitHub App user
func (*GitHubAppDelegate) GetName ¶ added in v0.0.49
func (g *GitHubAppDelegate) GetName(_ context.Context) (string, error)
GetName returns the username for the GitHub App user
func (*GitHubAppDelegate) GetOwner ¶ added in v0.0.49
func (_ *GitHubAppDelegate) GetOwner() string
GetOwner returns the owner filter
func (*GitHubAppDelegate) GetPrimaryEmail ¶ added in v0.0.49
func (g *GitHubAppDelegate) GetPrimaryEmail(ctx context.Context) (string, error)
GetPrimaryEmail returns the email for the GitHub App user
func (*GitHubAppDelegate) GetUserId ¶ added in v0.0.49
func (g *GitHubAppDelegate) GetUserId(ctx context.Context) (int64, error)
GetUserId returns the user id for the GitHub App user
func (*GitHubAppDelegate) IsOrg ¶ added in v0.0.49
func (g *GitHubAppDelegate) IsOrg() bool
IsOrg returns true if the owner is an organization
func (*GitHubAppDelegate) ListAllRepositories ¶ added in v0.0.49
func (g *GitHubAppDelegate) ListAllRepositories(ctx context.Context) ([]*minderv1.Repository, error)
ListAllRepositories returns a list of all repositories accessible to the GitHub App installation
type GitHubClientFactory ¶
type GitHubClientFactory interface { // BuildOAuthClient creates an instance of the GitHub Client and the OAuthDelegate // `baseURL` should be set to the empty string if there is no need to // override the default GitHub URL BuildOAuthClient( baseURL string, credential provifv1.GitHubCredential, owner string, ) (*gogithub.Client, github.Delegate, error) // BuildAppClient creates an instance of the GitHub Client and the AppDelegate // `baseURL` should be set to the empty string if there is no need to // override the default GitHub URL BuildAppClient( baseURL string, credential provifv1.GitHubCredential, appName string, userID int64, isOrg bool, ) (*gogithub.Client, github.Delegate, error) }
GitHubClientFactory creates instances of the GitHub API client
func NewGitHubClientFactory ¶
func NewGitHubClientFactory(metrics telemetry.HttpClientMetrics) GitHubClientFactory
NewGitHubClientFactory creates a new instance of GitHubClientFactory
type GitHubOAuthDelegate ¶ added in v0.0.49
type GitHubOAuthDelegate struct {
// contains filtered or unexported fields
}
GitHubOAuthDelegate is the struct that contains the GitHub access token specifc operations
func NewOAuthDelegate ¶ added in v0.0.49
func NewOAuthDelegate( client *gogithub.Client, credential provifv1.GitHubCredential, owner string, ) *GitHubOAuthDelegate
NewOAuthDelegate creates a GitHubOAuthDelegate from a GitHub client This exists as a separate function to allow the provider creation code to use its methods without instantiating a full provider.
func (*GitHubOAuthDelegate) GetCredential ¶ added in v0.0.49
func (o *GitHubOAuthDelegate) GetCredential() provifv1.GitHubCredential
GetCredential returns the GitHub OAuth credential
func (*GitHubOAuthDelegate) GetLogin ¶ added in v0.0.49
func (o *GitHubOAuthDelegate) GetLogin(ctx context.Context) (string, error)
GetLogin returns the login for the authenticated user
func (*GitHubOAuthDelegate) GetName ¶ added in v0.0.49
func (o *GitHubOAuthDelegate) GetName(ctx context.Context) (string, error)
GetName returns the username for the authenticated user
func (*GitHubOAuthDelegate) GetOwner ¶ added in v0.0.49
func (o *GitHubOAuthDelegate) GetOwner() string
GetOwner returns the owner filter
func (*GitHubOAuthDelegate) GetPrimaryEmail ¶ added in v0.0.49
func (o *GitHubOAuthDelegate) GetPrimaryEmail(ctx context.Context) (string, error)
GetPrimaryEmail returns the primary email for the authenticated user.
func (*GitHubOAuthDelegate) GetUserId ¶ added in v0.0.49
func (o *GitHubOAuthDelegate) GetUserId(ctx context.Context) (int64, error)
GetUserId returns the user id for the authenticated user
func (*GitHubOAuthDelegate) IsOrg ¶ added in v0.0.49
func (o *GitHubOAuthDelegate) IsOrg() bool
IsOrg returns true if the owner is an organization
func (*GitHubOAuthDelegate) ListAllRepositories ¶ added in v0.0.49
func (o *GitHubOAuthDelegate) ListAllRepositories(ctx context.Context) ([]*minderv1.Repository, error)
ListAllRepositories returns a list of all repositories for the authenticated user Two APIs are available, contigent on whether the token is for a user or an organization