Documentation
¶
Index ¶
- Constants
- func AddBranchPrefix(branch string) string
- func CheckResponseStatusWithBody(resp *http.Response, expectedStatusCodes ...int) error
- func CreateDotGitFolderWithRemote(path, remoteName, remoteUrl string) error
- func CreateToken() string
- func DefaultIfNotNil[T any](val *T) T
- func DiscardResponseBody(resp *http.Response) error
- func GenerateResponseError(status, body string) error
- func GetNilIfZeroVal[T comparable](val T) *T
- func GetPullRequestFilePath(filePath string) string
- func GetZeroValue[T any]() T
- func MapPullRequestState(state *PullRequestState) *string
- func PointerOf[T any](v T) *T
- func RemapFields[T any](src any, tagName string) (T, error)
- func RemoveDirContents(dirPath string) (err error)
- func RemoveTempDir(dirPath string) error
- func Untar(destDir string, reader io.Reader, shouldRemoveBaseDir bool) (err error)
- func Unzip(zipFileContent []byte, destinationToUnzip string) (err error)
- type EmptyLogger
- type ExecutionHandlerFunc
- type Log
- type PullRequestState
- type RetryExecutor
- type RetryExecutorTimeoutError
- type VcsProvider
- type WebhookEvent
Constants ¶
const ( TagPrefix = "refs/tags/" NumberOfCommitsToFetch = 50 ErrNoCommentsProvided = "could not add a pull request review comment, no comments were provided" )
const ( SuccessfulRepoDownload = "repository downloaded successfully. Starting with repository extraction..." SuccessfulRepoExtraction = "Extracted repository successfully" CreatingPullRequest = "Creating new pull request:" UpdatingPullRequest = "Updating details of pull request ID:" FetchingOpenPullRequests = "Fetching open pull requests in" FetchingPullRequestById = "Fetching pull requests by id in" UploadingCodeScanning = "Uploading code scanning for:" FailedForkedRepositoryExtraction = "Failed to extract forked repository owner" )
const (
RemoteName = "origin"
)
Variables ¶
This section is empty.
Functions ¶
func AddBranchPrefix ¶
AddBranchPrefix adds a branchPrefix to a branch name if it is not already present.
func CreateDotGitFolderWithRemote ¶
CreateDotGitFolderWithRemote creates a .git folder inside path with remote details of remoteName and remoteUrl
func DefaultIfNotNil ¶
func DefaultIfNotNil[T any](val *T) T
DefaultIfNotNil checks: 1. If the pointer is nil, return the zero value of the type 2. If the pointer isn't nil, return the value of the pointer.
func DiscardResponseBody ¶
DiscardResponseBody prepare http response body for closing
func GenerateResponseError ¶
func GetNilIfZeroVal ¶
func GetNilIfZeroVal[T comparable](val T) *T
func GetPullRequestFilePath ¶
func MapPullRequestState ¶
func MapPullRequestState(state *PullRequestState) *string
func PointerOf ¶
func PointerOf[T any](v T) *T
PointerOf returns pointer to the provided value if it is not nil.
func RemapFields ¶
RemapFields creates an instance of the T type and copies data from src parameter to it by mapping fields based on the tags with tagName (if not provided 'mapstructure' tag is used) using 'mapstructure' library.
func RemoveDirContents ¶
RemoveDirContents removes the contents of the directory, without removing the directory itself. If it encounters an error before removing all the files, it stops and returns that error.
func RemoveTempDir ¶
Types ¶
type EmptyLogger ¶
type EmptyLogger struct{}
func (EmptyLogger) Debug ¶
func (el EmptyLogger) Debug(_ ...interface{})
func (EmptyLogger) Error ¶
func (el EmptyLogger) Error(_ ...interface{})
func (EmptyLogger) Info ¶
func (el EmptyLogger) Info(_ ...interface{})
func (EmptyLogger) Output ¶
func (el EmptyLogger) Output(_ ...interface{})
func (EmptyLogger) Warn ¶
func (el EmptyLogger) Warn(_ ...interface{})
type ExecutionHandlerFunc ¶
type Log ¶
type Log interface { Debug(a ...interface{}) Info(a ...interface{}) Warn(a ...interface{}) Error(a ...interface{}) Output(a ...interface{}) }
type PullRequestState ¶
type PullRequestState string
const ( Open PullRequestState = "open" Closed PullRequestState = "closed" )
type RetryExecutor ¶
type RetryExecutor struct { // The context Context context.Context // The amount of retries to perform. MaxRetries int // Number of milliseconds to sleep between retries. RetriesIntervalMilliSecs int // Message to display when retrying. ErrorMessage string // Prefix to print at the beginning of each log. LogMsgPrefix string // ExecutionHandler is the operation to run with retries. ExecutionHandler ExecutionHandlerFunc // Logger for logs Logger Log }
func (*RetryExecutor) Execute ¶
func (runner *RetryExecutor) Execute() error
func (*RetryExecutor) LogRetry ¶
func (runner *RetryExecutor) LogRetry(attemptNumber int, err error)
type RetryExecutorTimeoutError ¶
type RetryExecutorTimeoutError struct {
// contains filtered or unexported fields
}
Error of this type will be returned if the executor reaches timeout and no other error is returned by the execution handler.
func (RetryExecutorTimeoutError) Error ¶
func (retryErr RetryExecutorTimeoutError) Error() string
type VcsProvider ¶
type VcsProvider int
VcsProvider is an enum represents the VCS provider type
const ( // GitHub VCS provider GitHub VcsProvider = iota // GitLab VCS provider GitLab // BitbucketServer VCS provider BitbucketServer // BitbucketCloud VCS provider BitbucketCloud // AzureRepos VCS provider AzureRepos )
func (VcsProvider) MarshalYAML ¶
func (v VcsProvider) MarshalYAML() (interface{}, error)
func (VcsProvider) String ¶
func (v VcsProvider) String() string
String representation of the VcsProvider
func (*VcsProvider) UnmarshalYAML ¶
func (v *VcsProvider) UnmarshalYAML(unmarshal func(interface{}) error) error
type WebhookEvent ¶
type WebhookEvent string
WebhookEvent is the event type of the incoming webhook
const ( // PrRejected the pull request is rejected PrRejected WebhookEvent = "PrRejected" // PrEdited the pull request is edited PrEdited WebhookEvent = "PrEdited" // PrMerged the pull request is merged PrMerged WebhookEvent = "PrMerged" // PrOpened a pull request is opened PrOpened WebhookEvent = "PrOpened" // Push a commit is pushed to the source branch Push WebhookEvent = "Push" // TagPushed a new tag is pushed TagPushed WebhookEvent = "TagPushed" // TagRemoved a tag is removed TagRemoved WebhookEvent = "TagRemoved" )