Documentation ¶
Index ¶
- Constants
- func GetBitbucketVersion(client *http.Client, base *url.URL) (string, error)
- func IsHigherVersion(version string, refVersion string) (bool, error)
- func ParseEvent(request *http.Request) *scm.EventData
- type AuthType
- type AuthorizationsService
- type BitbucketServer
- func (b *BitbucketServer) CheckToken() error
- func (b *BitbucketServer) CreateStatus(status c_v1alpha1.StatusPhase, targetURL, repoURL, commitSha string) error
- func (b *BitbucketServer) CreateWebhook(repo string, webhook *scm.Webhook) error
- func (b *BitbucketServer) DeleteWebhook(repo string, webhookURL string) error
- func (b *BitbucketServer) GetPullRequestSHA(repoURL string, number int) (string, error)
- func (b *BitbucketServer) GetToken() (string, error)
- func (b *BitbucketServer) GetWebhook(repo string, webhookURL string) (*Webhook, error)
- func (b *BitbucketServer) ListBranches(repo string) ([]string, error)
- func (b *BitbucketServer) ListDockerfiles(repo string) ([]string, error)
- func (b *BitbucketServer) ListPullRequests(repo, state string) ([]scm.PullRequest, error)
- func (b *BitbucketServer) ListRepos() ([]scm.Repository, error)
- func (b *BitbucketServer) ListTags(repo string) ([]string, error)
- type Branch
- type Branches
- type Change
- type CloneLink
- type Comment
- type Config
- type EventPayload
- type Files
- type ListOpts
- type Pagination
- type PermissionReq
- type PermissionResp
- type Project
- type Property
- type PullRequest
- type PullRequestListOpts
- type PullRequests
- type PullRequestsService
- type Repositories
- type RepositoriesService
- func (server *RepositoriesService) CreateStatus(ctx context.Context, commitID string, input *StatusReq) (*http.Response, error)
- func (server *RepositoriesService) CreateWebhook(ctx context.Context, project string, repo string, webhookReq Webhook) (*Webhook, *http.Response, error)
- func (server *RepositoriesService) DeleteWebhook(ctx context.Context, project string, repo string, webhookID int) (*http.Response, error)
- func (server *RepositoriesService) ListBranches(ctx context.Context, project string, repo string, opt *ListOpts) (*Branches, *http.Response, error)
- func (server *RepositoriesService) ListFiles(ctx context.Context, project string, repo string, opt *ListOpts) (*Files, *http.Response, error)
- func (server *RepositoriesService) ListPullRequests(ctx context.Context, project, repo string, opt *PullRequestListOpts) (*PullRequests, *http.Response, error)
- func (server *RepositoriesService) ListRepositories(ctx context.Context, project string, opt *ListOpts) (*Repositories, *http.Response, error)
- func (server *RepositoriesService) ListTags(ctx context.Context, project string, repo string, opt *ListOpts) (*Tags, *http.Response, error)
- func (server *RepositoriesService) ListWebhook(ctx context.Context, project string, repo string) (*Webhooks, *http.Response, error)
- type Repository
- type SelfLink
- type StatusReq
- type Tag
- type Tags
- type V1Client
- type Webhook
- type Webhooks
Constants ¶
const ( // RepoAdmin represents admin permission in repo. RepoAdmin = "REPO_ADMIN" // ProjectRead represents reading permission in project. ProjectRead = "PROJECT_READ" )
const ( // RefsChanged is the event key about refs changed RefsChanged = "repo:refs_changed" // PrOpened is the event key about pull request opened. PrOpened = "pr:opened" // PrModified means a pull request's description, title, or target branch is changed. // It be supported after the version is 5.10. Ref to: https://confluence.atlassian.com/bitbucketserver/bitbucket-server-5-10-release-notes-948214779.html PrModified = "pr:modified" // PrFromRefUpdated means a pull request's source branch has been updated. PrFromRefUpdated = "pr:from_ref_updated" // PrCommentAdded is the event key about a comment added on the pull request. PrCommentAdded = "pr:comment:added" )
Ref to: https://confluence.atlassian.com/bitbucketserver/event-payload-938025882.html
const ( // SupportAccessTokenVersion represents the lowest version // that support personal access token. SupportAccessTokenVersion = "5.5.0" // SupportPrModifiedEvent represents the lowest version // that support event key named pr:modified. SupportPrModifiedEvent = "5.10.0" // SupportPrFromRefUpdatedEvent represents the lowest version // that support pr:from_ref_updated event. SupportPrFromRefUpdatedEvent = "7.0.0" )
Variables ¶
This section is empty.
Functions ¶
func GetBitbucketVersion ¶
GetBitbucketVersion returns the version of the BitBucket Server
func IsHigherVersion ¶
IsHigherVersion compare the version with refVersion. If the version is lower than the refVersion, it will return false.
Types ¶
type AuthType ¶
type AuthType int
AuthType represents an authentication type within BitBucket Server.
type AuthorizationsService ¶
type AuthorizationsService struct {
// contains filtered or unexported fields
}
AuthorizationsService handles communication with the authorization related methods of the BitBucket Server API. docs: https://docs.atlassian.com/bitbucket-server/rest/6.2.0/bitbucket-access-tokens-rest.html .
func (*AuthorizationsService) CreateAccessToken ¶
func (server *AuthorizationsService) CreateAccessToken(ctx context.Context, user string, permissionReq PermissionReq) (string, *http.Response, error)
CreateAccessToken create a new access token in BitBucket Server.
type BitbucketServer ¶
type BitbucketServer struct {
// contains filtered or unexported fields
}
BitbucketServer represents the SCM provider of BitBucket Server.
func NewBitbucketServer ¶
func NewBitbucketServer(scmCfg *v1alpha1.SCMSource, v1Client *V1Client) *BitbucketServer
NewBitbucketServer new a SCM provider of BitBucket Server.
func (*BitbucketServer) CheckToken ¶
func (b *BitbucketServer) CheckToken() error
CheckToken checks whether the token has the authority of repo by trying ListRepos with the token.
func (*BitbucketServer) CreateStatus ¶
func (b *BitbucketServer) CreateStatus(status c_v1alpha1.StatusPhase, targetURL, repoURL, commitSha string) error
CreateStatus generate a new status for repository.
func (*BitbucketServer) CreateWebhook ¶
func (b *BitbucketServer) CreateWebhook(repo string, webhook *scm.Webhook) error
CreateWebhook creates webhook for specified repo.
func (*BitbucketServer) DeleteWebhook ¶
func (b *BitbucketServer) DeleteWebhook(repo string, webhookURL string) error
DeleteWebhook deletes webhook from specified repo.
func (*BitbucketServer) GetPullRequestSHA ¶
func (b *BitbucketServer) GetPullRequestSHA(repoURL string, number int) (string, error)
GetPullRequestSHA gets latest commit SHA of pull request.
func (*BitbucketServer) GetToken ¶
func (b *BitbucketServer) GetToken() (string, error)
GetToken gets the token by the username and password of SCM config.
func (*BitbucketServer) GetWebhook ¶
func (b *BitbucketServer) GetWebhook(repo string, webhookURL string) (*Webhook, error)
GetWebhook gets webhook from specified repo.
func (*BitbucketServer) ListBranches ¶
func (b *BitbucketServer) ListBranches(repo string) ([]string, error)
ListBranches lists the branches for specified repo.
func (*BitbucketServer) ListDockerfiles ¶
func (b *BitbucketServer) ListDockerfiles(repo string) ([]string, error)
ListDockerfiles lists the Dockerfiles for specified repo.
func (*BitbucketServer) ListPullRequests ¶ added in v0.9.7
func (b *BitbucketServer) ListPullRequests(repo, state string) ([]scm.PullRequest, error)
ListPullRequests lists the pull requests for specified repo.
func (*BitbucketServer) ListRepos ¶
func (b *BitbucketServer) ListRepos() ([]scm.Repository, error)
ListRepos lists the repos by the SCM config.
type Branch ¶
type Branch struct { ID string `json:"id"` DisplayID string `json:"displayId"` Type string `json:"type"` LatestCommit string `json:"latestCommit"` IsDefault bool `json:"isDefault"` }
Branch contains git Branch information.
type Branches ¶
type Branches struct { Pagination Values []Branch `json:"values"` }
Branches is a set of branches.
type Change ¶
type Change struct { Ref struct { ID string `json:"id"` Type string `json:"type"` DisplayID string `json:"displayId"` } `json:"ref"` RefID string `json:"refId"` FromHash string `json:"fromHash"` ToHash string `json:"toHash"` Type string `json:"type"` }
Change represents the details of refs_changed.
type Comment ¶
type Comment struct {
Text string `json:"text"`
}
Comment represents the comment in the pull request.
type Config ¶
type Config struct { // Base URL for API requests. Defaults to the public BitBucket Server API, but can be // set to a domain endpoint to use with a self hosted BitBucket Server server. baseURL // should always be specified with a trailing slash. BaseURL string // Auth type used to make authenticated API calls. AuthType AuthType // Username used for basic authentication. Username string // Password used for basic authentication. Password string // Token used to make authenticated API calls. Token string }
Config contains V1Client config information.
type EventPayload ¶
type EventPayload struct { EventKey string `json:"eventKey"` Repository Repository `json:"repository"` Changes []Change `json:"changes"` PullRequest PullRequest `json:"pullRequest"` Comment Comment `json:"comment"` }
EventPayload represents the event information.
type Files ¶
type Files struct { Pagination Values []string `json:"values"` }
Files is a set of files' name in a repo.
type ListOpts ¶
type ListOpts struct { Start *int `url:"start,omitempty" json:"start,omitempty"` Limit *int `url:"limit,omitempty" json:"limit,omitempty"` }
ListOpts specifies the optional parameters to various List methods that support pagination.
type Pagination ¶
type Pagination struct { Start *int `json:"start"` Size *int `json:"size"` Limit *int `json:"limit"` LastPage *bool `json:"isLastPage"` NextPage *int `json:"nextPageStart"` }
Pagination represents BitBucket Server pagination properties embedded in list responses.
type PermissionReq ¶
PermissionReq represents the options of creating access token.
type PermissionResp ¶
PermissionResp represents the response body of creating access token.
type Project ¶
type Project struct { Key string `json:"key"` ID int `json:"id"` Name string `json:"name"` Description string `json:"description"` Public bool `json:"public"` Type string `json:"type"` Links struct { Self []SelfLink `json:"self"` } `json:"links"` }
Project contains data from a BitBucket Server Project.
type Property ¶
type Property struct {
Version string `json:"version"`
}
Property represents BitBucket Server property.
type PullRequest ¶
type PullRequest struct { ID int `json:"id"` Version int `json:"version"` Title string `json:"title"` Description string `json:"description"` State string `json:"state"` Open bool `json:"open"` Closed bool `json:"closed"` CreatedDate int64 `json:"createdDate"` UpdatedDate int64 `json:"updatedDate"` FromRef struct { ID string `json:"id"` DisplayID string `json:"displayId"` LatestCommit string `json:"latestCommit"` Repository Repository `json:"repository"` } `json:"fromRef"` ToRef struct { ID string `json:"id"` DisplayID string `json:"displayId"` LatestCommit string `json:"latestCommit"` Repository Repository `json:"repository"` } `json:"toRef"` Locked bool `json:"locked"` Author struct { User struct { Name string `json:"name"` EmailAddress string `json:"emailAddress"` ID int `json:"id"` DisplayName string `json:"displayName"` Active bool `json:"active"` Slug string `json:"slug"` Type string `json:"type"` Links struct { Self []struct { Href string `json:"href"` } `json:"self"` } `json:"links"` } `json:"user"` Role string `json:"role"` Approved bool `json:"approved"` Status string `json:"status"` } `json:"author"` Reviewers []interface{} `json:"reviewers"` Participants []interface{} `json:"participants"` Links struct { Self []SelfLink `json:"self"` } `json:"links"` }
PullRequest represents a BitBucket Server pull request on a repository.
type PullRequestListOpts ¶ added in v0.9.7
type PullRequestListOpts struct { ListOpts State string `url:"state,omitempty" json:"state,omitempty"` }
PullRequestListOpts ...
type PullRequests ¶ added in v0.9.7
type PullRequests struct { Pagination Values []scm.PullRequest `json:"values"` }
PullRequests is a set of PullRequest.
type PullRequestsService ¶
type PullRequestsService struct {
// contains filtered or unexported fields
}
PullRequestsService handles communication with the pull request related
func (*PullRequestsService) GetPullRequest ¶
func (server *PullRequestsService) GetPullRequest(ctx context.Context, project string, repo string, number int) (*PullRequest, *http.Response, error)
GetPullRequest get a specific pull request.
type Repositories ¶
type Repositories struct { Pagination Values []Repository `json:"values"` }
Repositories is a set of repositories.
type RepositoriesService ¶
type RepositoriesService struct {
// contains filtered or unexported fields
}
RepositoriesService handles communication with the repository related.
func (*RepositoriesService) CreateStatus ¶
func (server *RepositoriesService) CreateStatus(ctx context.Context, commitID string, input *StatusReq) (*http.Response, error)
CreateStatus create a commit status.
func (*RepositoriesService) CreateWebhook ¶
func (server *RepositoriesService) CreateWebhook(ctx context.Context, project string, repo string, webhookReq Webhook) (*Webhook, *http.Response, error)
CreateWebhook create a new webhook.
func (*RepositoriesService) DeleteWebhook ¶
func (server *RepositoriesService) DeleteWebhook(ctx context.Context, project string, repo string, webhookID int) (*http.Response, error)
DeleteWebhook delete a webhook.
func (*RepositoriesService) ListBranches ¶
func (server *RepositoriesService) ListBranches(ctx context.Context, project string, repo string, opt *ListOpts) (*Branches, *http.Response, error)
ListBranches list branches on the repository.
func (*RepositoriesService) ListFiles ¶
func (server *RepositoriesService) ListFiles(ctx context.Context, project string, repo string, opt *ListOpts) (*Files, *http.Response, error)
ListFiles list files on the repository.
func (*RepositoriesService) ListPullRequests ¶ added in v0.9.7
func (server *RepositoriesService) ListPullRequests(ctx context.Context, project, repo string, opt *PullRequestListOpts) (*PullRequests, *http.Response, error)
ListPullRequests list pull requests on the repository.
func (*RepositoriesService) ListRepositories ¶
func (server *RepositoriesService) ListRepositories(ctx context.Context, project string, opt *ListOpts) (*Repositories, *http.Response, error)
ListRepositories list repositories in the Bitbucket Server.
type Repository ¶
type Repository struct { Slug string `json:"slug"` ID int `json:"id"` Name string `json:"name"` ScmID string `json:"scmId"` State string `json:"state"` StatusMessage string `json:"statusMessage"` Forkable bool `json:"forkable"` Project Project `json:"project"` Public bool `json:"public"` Links struct { Clone []CloneLink `json:"clone"` Self []SelfLink `json:"self"` } `json:"links"` }
Repository contains data from a BitBucket Server Repository.
type SelfLink ¶
type SelfLink struct {
Href string `json:"href"`
}
SelfLink represents the link of the resource.
type StatusReq ¶
type StatusReq struct { State string `json:"state"` Key string `json:"key"` Name string `json:"name"` URL string `json:"url"` Description string `json:"description"` }
StatusReq represents the options of creating commit status.
type Tag ¶
type Tag struct { ID string `json:"id"` DisplayID string `json:"displayId"` Type string `json:"type"` LatestCommit string `json:"latestCommit"` Hash string `json:"hash"` }
Tag contains git Tag information.
type V1Client ¶
type V1Client struct { // User agent used when communicating with the BitBucket Server API. UserAgent string // Services used for talking to different parts of the BitBucket Server API. PullRequests *PullRequestsService Repositories *RepositoriesService Authorizations *AuthorizationsService // contains filtered or unexported fields }
V1Client manages communication with the BitBucket Server API.
type Webhook ¶
type Webhook struct { ID int `json:"id,omitempty"` Name string `json:"name"` Events []string `json:"events,omitempty"` URL string `json:"url"` Active bool `json:"active"` }
Webhook contains webhook information.
type Webhooks ¶
type Webhooks struct { Pagination Values []Webhook `json:"values"` }
Webhooks is a set of webhooks.