Documentation ¶
Index ¶
- Constants
- func GenerateSCMToken(config *v1alpha1.SCMSource) error
- func IsDockerfile(path string) bool
- func IsInDep(path string) bool
- func ParseRepo(url string) (string, string)
- func ParseServerURL(url string) string
- func RegisterProvider(scmType v1alpha1.SCMType, pFunc newProviderFunc) error
- type EventData
- type EventType
- type Provider
- type PullRequest
- type Repository
- type Webhook
Constants ¶
const ( // ListOptPerPage represents the value for PerPage in list options. // Max is 100 for both GitHub and Gitlab, refer to https://developer.github.com/v3/guides/traversing-with-pagination/#basics-of-pagination ListOptPerPage = 100 )
Variables ¶
This section is empty.
Functions ¶
func GenerateSCMToken ¶
GenerateSCMToken generates the SCM token according to the config. Make sure the type, server of the SCM is provided. If the SCM is Github, the username is required. If the access token is provided, it should be checked whether has authority of repos. Generate new token only when the username and password are provided at the same time.
func IsDockerfile ¶ added in v0.9.6
IsDockerfile judges whether the file is Dockerfile. Dockerfile should meet requirements: * File should not be in dep folders. * File name should has Dockerfile prefix.
func ParseRepo ¶
ParseRepo parses owner and name from full repo name. For example, parse caicloud/cyclone will return owner(caicloud) and name(cyclone).
func ParseServerURL ¶
ParseServerURL is a helper func to parse the server url, such as https://github.com/ to return server(github.com).
func RegisterProvider ¶
RegisterProvider registers SCM providers.
Types ¶
type EventData ¶
type EventData struct { Type EventType Repo string Ref string Branch string Comment string CommitSHA string }
EventData represents the data parsed from SCM events.
type EventType ¶
type EventType string
EventType represents event types of SCM.
const ( // PullRequestEventType represents pull request events. PullRequestEventType EventType = "scm-pull-request" // PullRequestCommentEventType represents pull request comment events. PullRequestCommentEventType EventType = "scm-pull-request-comment" // PushEventType represents commit push events. PushEventType EventType = "scm-push" // TagReleaseEventType represents tag release events. TagReleaseEventType EventType = "scm-tag-release" // PostCommitEventType represents post commit events. PostCommitEventType EventType = "scm-post-commit" )
type Provider ¶
type Provider interface { GetToken() (string, error) ListRepos() ([]Repository, error) // ListBranches list branches of repo, repo format must be {owner}/{repo}. ListBranches(repo string) ([]string, error) // ListTags list tags of repo, repo format must be {owner}/{repo}. ListTags(repo string) ([]string, error) // ListPullRequests list pull requests of repo, repo format must be {owner}/{repo}. ListPullRequests(repo, state string) ([]PullRequest, error) ListDockerfiles(repo string) ([]string, error) CreateStatus(status c_v1alpha1.StatusPhase, targetURL, repoURL, commitSHA string) error GetPullRequestSHA(repoURL string, number int) (string, error) CheckToken() error CreateWebhook(repo string, webhook *Webhook) error DeleteWebhook(repo string, webhookURL string) error }
Provider represents the interface of SCM provider.
type PullRequest ¶ added in v0.9.7
type PullRequest struct { ID int `json:"id"` Title string `json:"title"` Description string `json:"description"` State string `json:"state"` // TargetBranch used for GitLab to indicate to which branch the merge-request should merge. TargetBranch string `json:"targetBranch"` }
PullRequest describes pull requests of SCM repositories.
type Repository ¶
Repository represents the information of a repository.