scm

package
v0.9.4-beta Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ListPerPageOpt represents the value for PerPage in list options.
	ListPerPageOpt = 30
)

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 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"
)

type Provider

type Provider interface {
	GetToken() (string, error)
	ListRepos() ([]Repository, error)
	ListBranches(repo string) ([]string, error)
	ListTags(repo string) ([]string, 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 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