Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateNewRepositoryName(displayName, uniqueHash string) string
- func GetMockedClient() *github.Client
- func GetMockedPrimaryRateLimitedClient() *github.Client
- func GetMockedResetPrimaryRateLimitedClient() *github.Client
- func GetMockedSecondaryRateLimitedClient() *github.Client
- func GetRepoAndOrgFromURL(repoURL string) (string, string, error)
- func GetRepoNameFromURL(repoURL string, orgName string) (string, error)
- func ParseGitHubTokens() error
- func WriteError(w http.ResponseWriter, httpStatus int, msg string, errors ...github.Error)
- type ContextKey
- type GitHubClient
- func (g *GitHubClient) DeleteRepository(ctx context.Context, orgName string, repoName string) error
- func (g *GitHubClient) GenerateNewRepository(ctx context.Context, orgName string, repoName string, description string) (string, error)
- func (g *GitHubClient) GetBranchFromURL(repoURL string, ctx context.Context, branchName string) (*github.Branch, error)
- func (g *GitHubClient) GetDefaultBranchFromURL(repoURL string, ctx context.Context) (string, error)
- func (g *GitHubClient) GetGitStatus(ctx context.Context) (bool, error)
- func (g *GitHubClient) GetLatestCommitSHAFromRepository(ctx context.Context, repoName string, orgName string, branch string) (string, error)
- type GitHubSystemErr
- type GitHubToken
- type GitHubTokenClient
- type GitHubUserErr
- type MockGitHubTokenClient
- type MockPrimaryRateLimitGitHubTokenClient
- type MockResetPrimaryRateLimitGitHubTokenClient
- type SecondaryRateLimit
- type ServerError
Constants ¶
const AppStudioAppDataOrg = "redhat-appstudio-appdata"
Variables ¶
var Clients map[string]*GitHubClient
Tokens is mapping of token names to GitHub tokens
Functions ¶
func GenerateNewRepositoryName ¶
GenerateNewRepositoryName creates a new gitops repository name, based on the following format: <display-name>-<partial-hash-of-clustername-and-namespace>-<random-word>-<random-word>
func GetMockedClient ¶
GetMockedClient returns a simple mocked go-github client
func GetRepoAndOrgFromURL ¶
GetRepoAndOrgFromURL returns both the github org and repository name from a given github URL Format must be of the form: <github-domain>/owner/repository(.git) If .git is appended to the end, it will be removed from the returned repo name
func GetRepoNameFromURL ¶
GetRepoNameFromURL returns the repository name from the Git repo URL
func ParseGitHubTokens ¶
func ParseGitHubTokens() error
ParseGitHubTokens parses all of the possible GitHub tokens available to HAS and makes them available within the "github" package This function should *only* be called once: at operator startup.
func WriteError ¶
WriteError - based on the mock implementation to handle writing back a response workaround until PR https://github.com/migueleliasweb/go-github-mock/pull/41 is merged
Types ¶
type GitHubClient ¶
type GitHubClient struct { TokenName string Token string Client *github.Client SecondaryRateLimit SecondaryRateLimit PrimaryRateLimited bool // flag to denote if the token has been near primary rate limited }
GitHubClient represents a Go-GitHub client, along with the name of the GitHub token that was used to initialize it
func (*GitHubClient) DeleteRepository ¶
Delete Repository takes in the given repository URL and attempts to delete it
func (*GitHubClient) GenerateNewRepository ¶
func (*GitHubClient) GetBranchFromURL ¶
func (g *GitHubClient) GetBranchFromURL(repoURL string, ctx context.Context, branchName string) (*github.Branch, error)
GetBranchFromURL returns the requested branch of a given repoURL
func (*GitHubClient) GetDefaultBranchFromURL ¶
GetDefaultBranchFromURL returns the default branch of a given repoURL
func (*GitHubClient) GetGitStatus ¶
func (g *GitHubClient) GetGitStatus(ctx context.Context) (bool, error)
GetGitStatus returns the status of the Git API with a simple noop call
func (*GitHubClient) GetLatestCommitSHAFromRepository ¶
func (g *GitHubClient) GetLatestCommitSHAFromRepository(ctx context.Context, repoName string, orgName string, branch string) (string, error)
GetLatestCommitSHAFromRepository gets the latest Commit SHA from the repository
type GitHubSystemErr ¶
type GitHubSystemErr struct {
Err string
}
GitHubSystemErr is a system related error for the GitHub related operations
func (*GitHubSystemErr) Error ¶
func (e *GitHubSystemErr) Error() string
type GitHubToken ¶
type GitHubToken interface {
GetNewGitHubClient(token string) (*GitHubClient, error)
}
type GitHubTokenClient ¶
type GitHubTokenClient struct { }
func (GitHubTokenClient) GetNewGitHubClient ¶
func (g GitHubTokenClient) GetNewGitHubClient(token string) (*GitHubClient, error)
GetNewGitHubClient returns a Go-GitHub client If a token is passed in (non-empty string) it will use that token for the GitHub client If no token is passed in (empty string), a token will be randomly selected by HAS. It returns the GitHub client, and (if a token was randomly selected) the name of the token used for the client If an error is encountered retrieving the token, or initializing the client, an error is returned
type GitHubUserErr ¶
type GitHubUserErr struct {
Err string
}
GitHubUserErr is a user related error for the GitHub related operations
func (*GitHubUserErr) Error ¶
func (e *GitHubUserErr) Error() string
type MockGitHubTokenClient ¶
type MockGitHubTokenClient struct { }
func (MockGitHubTokenClient) GetNewGitHubClient ¶
func (g MockGitHubTokenClient) GetNewGitHubClient(token string) (*GitHubClient, error)
GetNewGitHubClient returns a mocked Go-GitHub client. No actual tokens are passed in or used when this function is called
type MockPrimaryRateLimitGitHubTokenClient ¶
type MockPrimaryRateLimitGitHubTokenClient struct { }
func (MockPrimaryRateLimitGitHubTokenClient) GetNewGitHubClient ¶
func (g MockPrimaryRateLimitGitHubTokenClient) GetNewGitHubClient(token string) (*GitHubClient, error)
type MockResetPrimaryRateLimitGitHubTokenClient ¶
type MockResetPrimaryRateLimitGitHubTokenClient struct { }
func (MockResetPrimaryRateLimitGitHubTokenClient) GetNewGitHubClient ¶
func (g MockResetPrimaryRateLimitGitHubTokenClient) GetNewGitHubClient(token string) (*GitHubClient, error)
type SecondaryRateLimit ¶
type SecondaryRateLimit struct {
// contains filtered or unexported fields
}
type ServerError ¶
type ServerError struct {
// contains filtered or unexported fields
}
ServerError is used to identify gitops repo creation failures caused by server errors
func (*ServerError) Error ¶
func (e *ServerError) Error() string