scm

package
v0.9.8-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
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

func GenerateSCMToken(config *v1alpha1.SCMSource) error

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

func IsDockerfile(path string) bool

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 IsInDep added in v0.9.6

func IsInDep(path string) bool

IsInDep judges whether the path is in dep folders.

func ParseRepo

func ParseRepo(url string) (string, string)

ParseRepo parses owner and name from full repo name. For example, parse caicloud/cyclone will return owner(caicloud) and name(cyclone).

func ParseServerURL

func ParseServerURL(url string) string

ParseServerURL is a helper func to parse the server url, such as https://github.com/ to return server(github.com).

func RegisterProvider

func RegisterProvider(scmType v1alpha1.SCMType, pFunc newProviderFunc) error

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.

func GetSCMProvider

func GetSCMProvider(scm *v1alpha1.SCMSource) (Provider, error)

GetSCMProvider gets the SCM provider by the type.

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

type Repository struct {
	Name string `json:"name,omitempty"`
	URL  string `json:"url,omitempty"`
}

Repository represents the information of a repository.

type Webhook

type Webhook struct {
	Events []EventType
	URL    string
}

Webhook represents the params for SCM webhook.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL