vcsclient

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2021 License: Apache-2.0 Imports: 17 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BitbucketCloudClient

type BitbucketCloudClient struct {
	// contains filtered or unexported fields
}

func NewBitbucketCloudClient

func NewBitbucketCloudClient(context context.Context, vcsInfo *VcsInfo) (*BitbucketCloudClient, error)

func (*BitbucketCloudClient) CreatePullRequest

func (client *BitbucketCloudClient) CreatePullRequest(owner, repository, sourceBranch, targetBranch, title, description string) error

func (*BitbucketCloudClient) CreateWebhook

func (client *BitbucketCloudClient) CreateWebhook(owner, repository, branch, payloadUrl string, webhookEvents ...vcsutils.WebhookEvent) (string, string, error)

func (*BitbucketCloudClient) DeleteWebhook

func (client *BitbucketCloudClient) DeleteWebhook(owner, repository, webhookId string) error

func (*BitbucketCloudClient) DownloadRepository

func (client *BitbucketCloudClient) DownloadRepository(owner, repository, branch, localPath string) error

func (*BitbucketCloudClient) ListBranches

func (client *BitbucketCloudClient) ListBranches(owner, repository string) ([]string, error)

func (*BitbucketCloudClient) ListRepositories

func (client *BitbucketCloudClient) ListRepositories() (map[string][]string, error)

func (*BitbucketCloudClient) SetCommitStatus

func (client *BitbucketCloudClient) SetCommitStatus(commitStatus CommitStatus, owner, repository, ref, title, description, detailsUrl string) error

func (*BitbucketCloudClient) TestConnection

func (client *BitbucketCloudClient) TestConnection() error

func (*BitbucketCloudClient) UpdateWebhook

func (client *BitbucketCloudClient) UpdateWebhook(owner, repository, branch, payloadUrl, token, webhookId string, webhookEvents ...vcsutils.WebhookEvent) error

type BitbucketServerClient

type BitbucketServerClient struct {
	// contains filtered or unexported fields
}

func NewBitbucketServerClient

func NewBitbucketServerClient(context context.Context, vcsInfo *VcsInfo) (*BitbucketServerClient, error)

func (*BitbucketServerClient) CreatePullRequest

func (client *BitbucketServerClient) CreatePullRequest(owner, repository, sourceBranch, targetBranch, title, description string) error

func (*BitbucketServerClient) CreateWebhook

func (client *BitbucketServerClient) CreateWebhook(owner, repository, branch, payloadUrl string, webhookEvents ...vcsutils.WebhookEvent) (string, string, error)

func (*BitbucketServerClient) DeleteWebhook

func (client *BitbucketServerClient) DeleteWebhook(owner, repository, webhookId string) error

func (*BitbucketServerClient) DownloadRepository

func (client *BitbucketServerClient) DownloadRepository(owner, repository, branch, localPath string) error

func (*BitbucketServerClient) ListBranches

func (client *BitbucketServerClient) ListBranches(owner, repository string) ([]string, error)

func (*BitbucketServerClient) ListRepositories

func (client *BitbucketServerClient) ListRepositories() (map[string][]string, error)

func (*BitbucketServerClient) SetCommitStatus

func (client *BitbucketServerClient) SetCommitStatus(commitStatus CommitStatus, owner, repository, ref, title, description, detailsUrl string) error

func (*BitbucketServerClient) TestConnection

func (client *BitbucketServerClient) TestConnection() error

func (*BitbucketServerClient) UpdateWebhook

func (client *BitbucketServerClient) UpdateWebhook(owner, repository, branch, payloadUrl, token, webhookId string, webhookEvents ...vcsutils.WebhookEvent) error

type ClientBuilder

type ClientBuilder struct {
	// contains filtered or unexported fields
}

func NewClientBuilder

func NewClientBuilder(vcsProvider vcsutils.VcsProvider) *ClientBuilder

func (*ClientBuilder) ApiEndpoint

func (builder *ClientBuilder) ApiEndpoint(apiEndpoint string) *ClientBuilder

func (*ClientBuilder) Build

func (builder *ClientBuilder) Build() (VcsClient, error)

func (*ClientBuilder) Context

func (builder *ClientBuilder) Context(context context.Context) *ClientBuilder

func (*ClientBuilder) Logger

func (builder *ClientBuilder) Logger(logger *log.Logger) *ClientBuilder

func (*ClientBuilder) Token

func (builder *ClientBuilder) Token(token string) *ClientBuilder

func (*ClientBuilder) Username

func (builder *ClientBuilder) Username(username string) *ClientBuilder

type CommitStatus

type CommitStatus int
const (
	Pass CommitStatus = iota
	Fail
	Error
	InProgress
)

type GitHubClient

type GitHubClient struct {
	// contains filtered or unexported fields
}

func NewGitHubClient

func NewGitHubClient(context context.Context, vcsInfo *VcsInfo) (*GitHubClient, error)

func (*GitHubClient) CreatePullRequest

func (client *GitHubClient) CreatePullRequest(owner, repository, sourceBranch, targetBranch, title, description string) error

func (*GitHubClient) CreateWebhook

func (client *GitHubClient) CreateWebhook(owner, repository, branch, payloadUrl string, webhookEvents ...vcsutils.WebhookEvent) (string, string, error)

func (*GitHubClient) DeleteWebhook

func (client *GitHubClient) DeleteWebhook(owner, repository, webhookId string) error

func (*GitHubClient) DownloadRepository

func (client *GitHubClient) DownloadRepository(owner, repository, branch, localPath string) error

func (*GitHubClient) ListBranches

func (client *GitHubClient) ListBranches(owner, repository string) ([]string, error)

func (*GitHubClient) ListRepositories

func (client *GitHubClient) ListRepositories() (map[string][]string, error)

func (*GitHubClient) SetCommitStatus

func (client *GitHubClient) SetCommitStatus(commitStatus CommitStatus, owner, repository, ref, title, description, detailsUrl string) error

func (*GitHubClient) TestConnection

func (client *GitHubClient) TestConnection() error

func (*GitHubClient) UpdateWebhook

func (client *GitHubClient) UpdateWebhook(owner, repository, branch, payloadUrl, token, webhookId string, webhookEvents ...vcsutils.WebhookEvent) error

type GitLabClient

type GitLabClient struct {
	// contains filtered or unexported fields
}

func NewGitLabClient

func NewGitLabClient(context context.Context, vcsInfo *VcsInfo) (*GitLabClient, error)

func (*GitLabClient) CreatePullRequest

func (client *GitLabClient) CreatePullRequest(owner, repository, sourceBranch, targetBranch, title, description string) error

func (*GitLabClient) CreateWebhook

func (client *GitLabClient) CreateWebhook(owner, repository, branch, payloadUrl string, webhookEvents ...vcsutils.WebhookEvent) (string, string, error)

func (*GitLabClient) DeleteWebhook

func (client *GitLabClient) DeleteWebhook(owner, repository, webhookId string) error

func (*GitLabClient) DownloadRepository

func (client *GitLabClient) DownloadRepository(owner, repository, branch, localPath string) error

func (*GitLabClient) ListBranches

func (client *GitLabClient) ListBranches(owner, repository string) ([]string, error)

func (*GitLabClient) ListRepositories

func (client *GitLabClient) ListRepositories() (map[string][]string, error)

func (*GitLabClient) SetCommitStatus

func (client *GitLabClient) SetCommitStatus(commitStatus CommitStatus, owner, repository, ref, title, description, detailsUrl string) error

func (*GitLabClient) TestConnection

func (client *GitLabClient) TestConnection() error

func (*GitLabClient) UpdateWebhook

func (client *GitLabClient) UpdateWebhook(owner, repository, branch, payloadUrl, token, webhookId string, webhookEvents ...vcsutils.WebhookEvent) error

type TokenPermission

type TokenPermission int
const (
	WebhookPerm TokenPermission = iota
	CommitStatusPerm
)

type VcsClient

type VcsClient interface {
	// Return nil if connection and authorization established successfully
	TestConnection() error

	// Return a map between all accesibles owners to their list of repositories
	ListRepositories() (map[string][]string, error)

	// List all branches under the input repository
	// owner      - User or organiaztion
	// repository - VCS repository name
	ListBranches(owner, repository string) ([]string, error)

	// Create a webhook
	// owner         - User or organiaztion
	// repository    - VCS repository name
	// branch        - VCS branch name
	// payloadUrl    - URL to send the payload when a webhook event occurs
	// webhookEvents - PrCreated, PrEdited, or Push
	// Return the webhook ID, token and an error, if occurred
	CreateWebhook(owner, repository, branch, payloadUrl string, webhookEvents ...vcsutils.WebhookEvent) (string, string, error)

	// Update a webhook
	// owner         - User or organiaztion
	// repository    - VCS repository name
	// branch        - VCS branch name
	// payloadUrl    - URL to send the payload when a webhook event occurs
	// token         - A token used to validate identity of the incoming webhook
	// webhookId     - The webhook ID returned from a previous CreateWebhook command
	// webhookEvents - PrCreated, PrEdited, or Push
	UpdateWebhook(owner, repository, branch, payloadUrl, token, webhookId string, webhookEvents ...vcsutils.WebhookEvent) error

	// Delete a webhook
	// owner        - User or organiaztion
	// repository   - VCS repository name
	// webhookId    - The webhook ID returned from a previous CreateWebhook command
	DeleteWebhook(owner, repository, webhookId string) error

	// Set commit status
	// commitStatus - One of Pass, Fail, Error, or InProgress
	// owner        - User or organiaztion
	// repository   - VCS repository name
	// ref          - SHA, a branch name, or a tag name.
	// title        - Title of the commit status
	// description  - Description of the commit status
	// detailsUrl   - The URL for component status link
	SetCommitStatus(commitStatus CommitStatus, owner, repository, ref, title, description, detailsUrl string) error

	// Download and extract a VCS repository
	// owner      - User or organiaztion
	// repository - VCS repository name
	// branch     - VCS branch name
	// localPath  - Local file system path
	DownloadRepository(owner, repository, branch, localPath string) error

	// Create a pull request between 2 different branches in the same repository
	// owner        - User or organiaztion
	// repository   - VCS repository name
	// sourceBranch - Source branch
	// targetBranch - Target branch
	// title        - Pull request title
	// description  - Pull request description
	CreatePullRequest(owner, repository, sourceBranch, targetBranch, title, description string) error
}

type VcsInfo

type VcsInfo struct {
	ApiEndpoint string
	Username    string
	Token       string
}

Jump to

Keyboard shortcuts

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