event_processor

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GitProviderGitHub    = "github"
	GitProviderGitLab    = "gitlab"
	GitProviderGerrit    = "gerrit"
	GitProviderBitbucket = "bitbucket"

	GerritEventTypeCommentAdded    = "comment-added"
	GitHubEventTypeCommentAdded    = "issue_comment"
	GitLabEventTypeCommentAdded    = "Note Hook"
	BitbucketEventTypeCommentAdded = "pullrequest:comment_created"

	EventTypeReviewComment = "comment"
	EventTypeMerge         = "merge"

	RecheckComment  = "/recheck"
	OkToTestComment = "/ok-to-test"
)
View Source
const (
	CodebaseListLimit = 1000
)
View Source
const GitServerTokenField = "token"

Variables

This section is empty.

Functions

func ContainsPipelineRecheck added in v0.12.0

func ContainsPipelineRecheck(s string) bool

ContainsPipelineRecheck checks if the comment contains the pipeline recheck or ok to test comment. It's used for Gerrit because its comments are in the format: "Patch Set 2:\n\n/recheck".

func ContainsPipelineRecheckPrefix added in v0.19.0

func ContainsPipelineRecheckPrefix(s string) bool

ContainsPipelineRecheckPrefix checks if the comment starts with the pipeline recheck or ok to test comment.

func ConvertRepositoryPath added in v0.12.0

func ConvertRepositoryPath(repo string) string

ConvertRepositoryPath converts repository path to the format which is used in codebase.

func GetCodebaseByRepoPath added in v0.12.0

func GetCodebaseByRepoPath(ctx context.Context, client ctrlClient.Reader, ns, repoPath string) (*codebaseApi.Codebase, error)

GetCodebaseByRepoPath returns codebase by repository path.

func GetGitServerToken added in v0.13.0

func GetGitServerToken(ctx context.Context, client ctrlClient.Reader, codebase *codebaseApi.Codebase) (string, error)

Types

type BitbucketAuthor added in v0.20.0

type BitbucketAuthor struct {
	DisplayName string `json:"display_name"`
	Links       struct {
		Avatar struct {
			Href string `json:"href"`
		} `json:"avatar"`
	} `json:"links"`
}

type BitbucketBranch added in v0.13.0

type BitbucketBranch struct {
	Name string `json:"name"`
}

type BitbucketComment added in v0.13.0

type BitbucketComment struct {
	Content BitbucketCommentContent `json:"content"`
}

type BitbucketCommentContent added in v0.13.0

type BitbucketCommentContent struct {
	Raw string `json:"raw"`
}

type BitbucketCommentEvent added in v0.13.0

type BitbucketCommentEvent struct {
	BitbucketEvent
	Comment BitbucketComment `json:"comment"`
}

type BitbucketCommit added in v0.13.0

type BitbucketCommit struct {
	Hash string `json:"hash"`
}

type BitbucketEvent added in v0.13.0

type BitbucketEvent struct {
	Repository  BitbucketRepository  `json:"repository"`
	PullRequest BitbucketPullRequest `json:"pullrequest"`
}

type BitbucketPullRequest added in v0.13.0

type BitbucketPullRequest struct {
	ID          int                      `json:"id"`
	Title       string                   `json:"title"`
	Source      BitbucketPullRequestSrc  `json:"source"`
	Destination BitbucketPullRequestDest `json:"destination"`
	LastCommit  BitbucketCommit          `json:"last_commit"`
	Author      BitbucketAuthor          `json:"author"`
	Links       struct {
		Html struct {
			Href string `json:"href"`
		} `json:"html"`
	} `json:"links"`
}

type BitbucketPullRequestDest added in v0.13.0

type BitbucketPullRequestDest struct {
	Branch BitbucketBranch `json:"branch"`
	Commit BitbucketCommit `json:"commit"`
}

type BitbucketPullRequestSrc added in v0.13.0

type BitbucketPullRequestSrc struct {
	Branch BitbucketBranch `json:"branch"`
	Commit BitbucketCommit `json:"commit"`
}

type BitbucketRepository added in v0.13.0

type BitbucketRepository struct {
	FullName string `json:"full_name"`
}

type EventInfo

type EventInfo struct {
	GitProvider        string
	RepoPath           string
	TargetBranch       string
	Type               string
	Codebase           *codebaseApi.Codebase
	HasPipelineRecheck bool
	PullRequest        *PullRequest
}

EventInfo represents information about an event.

func (*EventInfo) IsReviewCommentEvent

func (e *EventInfo) IsReviewCommentEvent() bool

IsReviewCommentEvent returns true if the event is a review comment event.

type GerritEvent

type GerritEvent struct {
	Project struct {
		Name string `json:"name"`
	} `json:"project"`
	Change struct {
		Branch string `json:"branch"`
	} `json:"change"`
	Comment string `json:"comment"`
	Type    string `json:"type"`
}

GerritEvent represents a Gerrit event.

type GitLabComment

type GitLabComment struct {
	Note string `json:"note"`
}

type GitLabCommentEvent

type GitLabCommentEvent struct {
	Project          GitLabProject      `json:"project"`
	MergeRequest     GitLabMergeRequest `json:"merge_request"`
	ObjectAttributes GitLabComment      `json:"object_attributes"`
	User             GitLabUser         `json:"user"`
}

GitLabCommentEvent represents GitLab comment event.

type GitLabCommit

type GitLabCommit struct {
	ID      string `json:"id"`
	Message string `json:"message"`
}

type GitLabMergeRequest

type GitLabMergeRequest struct {
	TargetBranch string       `json:"target_branch"`
	Title        string       `json:"title"`
	LastCommit   GitLabCommit `json:"last_commit"`
	SourceBranch string       `json:"source_branch"`
	ChangeNumber int          `json:"iid"`
	Url          string       `json:"url"`
}

type GitLabMergeRequestsEvent

type GitLabMergeRequestsEvent struct {
	Project          GitLabProject      `json:"project"`
	ObjectAttributes GitLabMergeRequest `json:"object_attributes"`
	User             GitLabUser         `json:"user"`
}

GitLabMergeRequestsEvent represents GitLab merge request event.

type GitLabProject

type GitLabProject struct {
	PathWithNamespace string `json:"path_with_namespace"`
}

type GitLabUser added in v0.20.0

type GitLabUser struct {
	Username  string `json:"username"`
	AvatarUrl string `json:"avatar_url"`
}

type Processor

type Processor interface {
	Process(ctx context.Context, body []byte, ns, eventType string) (*EventInfo, error)
}

Processor is an interface for event processors.

type PullRequest

type PullRequest struct {
	HeadRef           string `json:"headRef"`
	HeadSha           string `json:"headSha"`
	Title             string `json:"title"`
	ChangeNumber      int    `json:"changeNumber"`
	LastCommitMessage string `json:"lastCommitMessage"`
	Author            string `json:"author"`
	AuthorAvatarUrl   string `json:"authorAvatarUrl"`
	Url               string `json:"url"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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