bitbucket

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2022 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildCloudAPIContext added in v0.13.0

func BuildCloudAPIContext(ctx context.Context, user, password, token string) context.Context

BuildCloudAPIContext builds context.Context used to call Bitbucket Cloud Code Insights API

func BuildServerAPIContext added in v0.13.0

func BuildServerAPIContext(ctx context.Context, bbURL, user, password, token string) (context.Context, error)

BuildServerAPIContext builds context.Context used to call Bitbucket Server Code Insights API

Types

type APIClient added in v0.13.0

type APIClient interface {

	// CreateOrUpdateReport creates or updates specified report
	CreateOrUpdateReport(ctx context.Context, req *ReportRequest) error

	// CreateOrUpdateAnnotations creates or updates annotations
	CreateOrUpdateAnnotations(ctx context.Context, req *AnnotationsRequest) error
}

APIClient is client for Bitbucket Code Insights API

func NewCloudAPIClient added in v0.13.0

func NewCloudAPIClient(isInPipeline bool, isInPipe bool) APIClient

NewCloudAPIClient creates client for Bitbucket Cloud Insights API

func NewCloudAPIClientWithConfigurations added in v0.13.0

func NewCloudAPIClientWithConfigurations(client *http.Client, server bbapi.ServerConfiguration) APIClient

NewCloudAPIClientWithConfigurations creates client for Bitbucket Cloud Insights API with specified configuration

func NewServerAPIClient added in v0.13.0

func NewServerAPIClient() APIClient

NewServerAPIClient creates client for Bitbucket Server Code Insights API

type AnnotationsRequest added in v0.13.0

type AnnotationsRequest struct {
	Owner      string
	Repository string
	Commit     string
	ReportID   string
	Comments   []*reviewdog.Comment
}

AnnotationsRequest is an object that represent parameters used to create/update annotations

type CloudAPIClient added in v0.13.0

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

CloudAPIClient is wrapper for Bitbucket Cloud Code Insights API client

func (*CloudAPIClient) CreateOrUpdateAnnotations added in v0.13.0

func (c *CloudAPIClient) CreateOrUpdateAnnotations(ctx context.Context, req *AnnotationsRequest) error

CreateOrUpdateAnnotations creates or updates annotations

func (*CloudAPIClient) CreateOrUpdateReport added in v0.13.0

func (c *CloudAPIClient) CreateOrUpdateReport(ctx context.Context, req *ReportRequest) error

CreateOrUpdateReport creates or updates specified report

type CloudAPIHelper added in v0.13.0

type CloudAPIHelper struct{}

CloudAPIHelper is collection of utility functions used to build requests for Bitbucket Cloud Code Insights API

func (*CloudAPIHelper) BuildAnnotations added in v0.13.0

func (c *CloudAPIHelper) BuildAnnotations(comments []*reviewdog.Comment) []bbapi.ReportAnnotation

BuildAnnotations builds list of Code Insights API annotation objects for specified comments

func (*CloudAPIHelper) BuildReport added in v0.13.0

func (c *CloudAPIHelper) BuildReport(req *ReportRequest) bbapi.Report

BuildReport builds Code Insights API report object

type ReportAnnotator

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

ReportAnnotator is a comment service for Bitbucket Code Insights reports.

Cloud API:

https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/commit/%7Bcommit%7D/reports/%7BreportId%7D/annotations#post
POST /2.0/repositories/{username}/{repo_slug}/commit/{commit}/reports/{reportId}/annotations

Server API:

https://docs.atlassian.com/bitbucket-server/rest/5.15.0/bitbucket-code-insights-rest.html#idm288218233536
/rest/insights/1.0/projects/{projectKey}/repos/{repositorySlug}/commits/{commitId}/reports/{key}/annotations

func NewReportAnnotator

func NewReportAnnotator(cli APIClient, owner, repo, sha string, runners []string) *ReportAnnotator

NewReportAnnotator creates new Bitbucket ReportRequest Annotator

func (*ReportAnnotator) Flush

func (r *ReportAnnotator) Flush(ctx context.Context) error

Flush posts comments which has not been posted yet.

func (*ReportAnnotator) Post

Post accepts a comment and holds it. Flush method actually posts comments to Bitbucket in batch.

type ReportRequest added in v0.13.0

type ReportRequest struct {
	Owner      string
	Repository string
	Commit     string
	ReportID   string
	Type       string
	Title      string
	Reporter   string
	Result     string
	Details    string
	LogoURL    string
}

ReportRequest is an object that represent parameters used to create/update report

type ServerAPIClient added in v0.13.0

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

ServerAPIClient is wrapper for Bitbucket Server Code Insights API client

func (*ServerAPIClient) CreateOrUpdateAnnotations added in v0.13.0

func (c *ServerAPIClient) CreateOrUpdateAnnotations(ctx context.Context, req *AnnotationsRequest) error

CreateOrUpdateAnnotations creates or updates annotations

func (*ServerAPIClient) CreateOrUpdateReport added in v0.13.0

func (c *ServerAPIClient) CreateOrUpdateReport(ctx context.Context, req *ReportRequest) error

CreateOrUpdateReport creates or updates specified report

type ServerAPIHelper added in v0.13.0

type ServerAPIHelper struct{}

ServerAPIHelper is collection of utility functions used to build requests for Bitbucket Server Code Insights API

func (*ServerAPIHelper) BuildAnnotations added in v0.13.0

func (h *ServerAPIHelper) BuildAnnotations(comments []*reviewdog.Comment) insights.AnnotationsList

BuildAnnotations builds list of Code Insights API annotation objects for specified comments

func (*ServerAPIHelper) BuildReport added in v0.13.0

func (h *ServerAPIHelper) BuildReport(req *ReportRequest) insights.Report

BuildReport builds Code Insights API report object

type UnexpectedResponseError added in v0.13.0

type UnexpectedResponseError struct {
	Code int
	Body []byte
}

UnexpectedResponseError is triggered when we have unexpected response from Code Insights API

func (UnexpectedResponseError) Error added in v0.13.0

func (e UnexpectedResponseError) Error() string

Jump to

Keyboard shortcuts

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