gerritssh

package
v0.0.0-...-6a2011c Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EventTypeAssigneeChanged is sent when the assignee of a change has been
	// modified
	EventTypeAssigneeChanged = "assignee-changed"

	// EventTypeChangeAbandoned is sent when a change has been abandoned
	EventTypeChangeAbandoned = "change-abandoned"

	// EventTypeChangeMerged is sent when a change has been merged into the git
	// repository
	EventTypeChangeMerged = "change-merged"

	// EventTypeChangeRestored is sent when an abandoned change has been restored
	EventTypeChangeRestored = "change-restored"

	// EventTypeCommentAdded is sent when a review comment has been posted on
	// a change
	EventTypeCommentAdded = "comment-added"

	// EventTypeDroppedOutput is sent to notify a client that events have been
	// dropped
	EventTypeDroppedOutput = "dropped-output"

	// EventTypeHashtagsChanged is sent when the hashtags have been added to or
	// removed from a change
	EventTypeHashtagsChanged = "hashtags-changed"

	// EventTypeProjectCreated is sent when a new project has been created
	EventTypeProjectCreated = "project-created"

	// EventTypePatchSetCreated is sent when a new change has been uploaded, or
	// a new patch set has been uploaded to an existing change
	EventTypePatchSetCreated = "patchset-created"

	// EventTypeRefUpdated is sent when a reference is updated in a git repository
	EventTypeRefUpdated = "ref-updated"

	// EventTypeReviewerAdded is sent when a reviewer is added to a change
	EventTypeReviewerAdded = "reviewer-added"

	// EventTypeReviewerDeleted is sent when a reviewer (with a vote) is removed
	// from a change
	EventTypeReviewerDeleted = "reviewer-deleted"

	// EventTypeTopicChanged is sent when the topic of a change has been changed
	EventTypeTopicChanged = "topic-changed"

	// EventTypeWorkInProgressStateChanged is sent when the the WIP state of the
	// change has changed
	EventTypeWorkInProgressStateChanged = "wip-state-changed"

	// EventTypePrivateStateChanged is sent when the the private state of the
	// change has changed
	EventTypePrivateStateChanged = "private-state-changed"

	// EventTypeVoteDeleted is sent when a vote was removed from a change
	EventTypeVoteDeleted = "vote-deleted"

	// EventTypeRefReplicationScheduled is sent when replication is scheduled for a ref
	EventTypeRefReplicationScheduled = "ref-replication-scheduled"

	// EventTypeRefReplicated is sent when a ref has been replicated
	EventTypeRefReplicated = "ref-replicated"

	// EventTypeRefReplicationDone is sent when replication is done for a ref
	EventTypeRefReplicationDone = "ref-replication-done"
)

Variables

This section is empty.

Functions

func ChangeIDWithProjectNumber

func ChangeIDWithProjectNumber(project string, number int64) string

ChangeIDWithProjectNumber formats the given project/number into a Change's ID

Types

type ChangeStatus

type ChangeStatus string

ChangeStatus describes the current status of the change

const (
	// ChangeStatusNew means change is still being reviewed
	ChangeStatusNew ChangeStatus = "NEW"

	// ChangeStatusMerged means change has been merged to its branch
	ChangeStatusMerged ChangeStatus = "MERGED"

	// ChangeStatusAbandoned means change was abandoned by its owner or administrator
	ChangeStatusAbandoned ChangeStatus = "ABANDONED"
)

type Client

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

Client holds the necessary params to connect to a gerrit instance over ssh

func NewClient

func NewClient(sshAddr, user string, privateKey, hostKey []byte) (*Client, error)

NewClient returns a new SSHClient

func (Client) Dial

func (s Client) Dial() (*ssh.Session, error)

Dial connects to gerrit over ssh and returns a new session

func (*Client) StreamEvents

func (e *Client) StreamEvents(ctx context.Context, ch chan Event) error

StreamEvents will start listening for real-time gerrit events

type Event

type Event struct {
	Type string `json:"type"`

	Change    EventChange    `json:"change"`
	PatchSet  EventPatchSet  `json:"patchSet"`
	RefUpdate EventRefUpdate `json:"refUpdate"`

	Author    EventAccount `json:"author"`
	Submitter EventAccount `json:"submitter"`
	Reviewer  EventAccount `json:"reviewer"`
	Remover   EventAccount `json:"remover"`
	Changer   EventAccount `json:"changer"`
	Uploader  EventAccount `json:"uploader"`
	Editor    EventAccount `json:"editor"`
	Abandoner EventAccount `json:"abandoner"`
	Restorer  EventAccount `json:"restorer"`

	Approvals   []EventApproval `json:"approvals"`
	Added       []string        `json:"added"`
	Removed     []string        `json:"removed"`
	Hashtags    []string        `json:"hashtags"`
	ProjectName string          `json:"projectName"`
	ProjectHead string          `json:"projectHead"`
	OldTopic    string          `json:"oldTopic"`
	Comment     string          `json:"comment"`
	Reason      string          `json:"reason"`
	NewRevision string          `json:"newRev"`
	OldAssignee EventAccount    `json:"oldAssignee"`
	TargetNode  string          `json:"targetNode"`
	Status      string          `json:"status"`
	RefStatus   string          `json:"refStatus"`
	NodesCount  int64           `json:"nodesCount"`

	TSCreated int64 `json:"eventCreatedOn"`
}

Event describes a major event that occured in the gerrit server from https://gerrit-review.googlesource.com/Documentation/cmd-stream-events.html structures from https://gerrit-review.googlesource.com/Documentation/json.html

func (Event) KV

func (e Event) KV() llog.KV

KV returns a KV for the given event

type EventAccount

type EventAccount struct {
	Name     string `json:"name"`
	Email    string `json:"email"`
	Username string `json:"username"`
}

EventAccount describes a user account inside an Event

type EventApproval

type EventApproval struct {
	Type        string       `json:"type"`
	Description string       `json:"description"`
	Value       string       `json:"value"`
	OldValue    string       `json:"oldValue"`
	By          EventAccount `json:"by"`
}

EventApproval describes an approval inside an Event

type EventChange

type EventChange struct {
	Project       string       `json:"project"`
	Branch        string       `json:"branch"`
	Topic         string       `json:"topic"`
	ChangeID      string       `json:"id"`
	Number        int64        `json:"number"`
	Subject       string       `json:"subject"`
	Owner         EventAccount `json:"owner"`
	URL           string       `json:"url"`
	CommitMessage string       `json:"commitMessage"`
	Status        ChangeStatus `json:"status"`
	Open          bool         `json:"open"`
	Private       bool         `json:"private"`
	WIP           bool         `json:"wip"`
	TSCreated     int64        `json:"createdOn"`
}

EventChange describes a change inside an Event

type EventPatchSet

type EventPatchSet struct {
	Number         int64        `json:"number"`
	Revision       string       `json:"revision"`
	Parents        []string     `json:"parents"`
	Ref            string       `json:"ref"`
	Uploader       EventAccount `json:"uploader"`
	Kind           PatchSetKind `json:"kind"`
	Author         EventAccount `json:"author"`
	SizeInsertions int64        `json:"sizeInsertions"`
	SizeDeletions  int64        `json:"sizeDeletions"`
	TSCreated      int64        `json:"createdOn"`
}

EventPatchSet describes a patch set inside an Event

type EventRefUpdate

type EventRefUpdate struct {
	OldRevision string `json:"oldRev"`
	// NewRevision, if 0000000000000000000000000000000000000000, means it was
	// deleted
	NewRevision string `json:"newRev"`
	RefName     string `json:"refName"`
	Project     string `json:"project"`
}

EventRefUpdate describes a ref inside an Event

type PatchSetKind

type PatchSetKind string

PatchSetKind describes the type of patch set

const (
	// PatchSetKindRework is nontrivial content changes
	PatchSetKindRework PatchSetKind = "REWORK"

	// PatchSetKindTrivialRebase is conflict-free merge between the new parent and the
	// prior patch set
	PatchSetKindTrivialRebase PatchSetKind = "TRIVIAL_REBASE"

	// PatchSetKindMergeFirstParentUpdate is conflict-free change of first (left) parent
	// of a merge commit
	PatchSetKindMergeFirstParentUpdate PatchSetKind = "MERGE_FIRST_PARENT_UPDATE"

	// PatchSetKindNoCodeChange is no code changed; same tree and same parent tree
	PatchSetKindNoCodeChange PatchSetKind = "NO_CODE_CHANGE"

	// PatchSetKindNoChange is no changes; same commit message, same tree and same parent
	// tree
	PatchSetKindNoChange PatchSetKind = "NO_CHANGE"
)

Jump to

Keyboard shortcuts

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