botdata

package
v0.0.0-...-797cded Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package botdata implements parsing and generation logic for BotData.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Append

func Append(humanMsg string, bd BotData) (string, error)

Append appends BotData message (in JSON form) to the given human message. The human message will be truncated if the length of result message exceeds `MaxMessageLength`. Returns error if marshalling BotData to JSON fails or the BotData message itself is already too long.

Types

type ActionType

type ActionType string

ActionType describes the type of the action taken by CV against a Gerrit Change.

const (
	// Start indicates that LUCI CV has started a Run for a Gerrit Change.
	Start ActionType = "start"
	// Cancel indicates that LUCI CV has cancelled a Run for Gerrit Change.
	Cancel = "cancel"
)

func (*ActionType) UnmarshalJSON

func (at *ActionType) UnmarshalJSON(b []byte) error

UnmarshalJSON sets `*at` to the `ActionType` the given bytes represents. Returns error for types other than `Start` or `Cancel`.

type BotData

type BotData struct {
	// Action describes the action taken by CV against a Gerrit Change.
	Action ActionType `json:"action"`
	// TriggeredAt is the timestamp when this action is triggered.
	TriggeredAt time.Time `json:"triggered_at"`
	// Revision is the revision (patch set) of the change at the time this
	// action is triggered.
	Revision string `json:"revision"`
}

BotData records an action taken by CV against a Gerrit Change.

func Parse

func Parse(cmi *gerritpb.ChangeMessageInfo) (ret BotData, ok bool)

Parse tries to extract BotData from the given Gerrit Change message. Returns ok=false if no valid BotData is found in the message.

type ChangeID

type ChangeID struct {
	// Host is the Gerrit host name for the Change.
	Host string
	// Number is the Gerrit Change number.
	Number int64
}

ChangeID is the unique identifier for a Gerrit Change.

func (*ChangeID) MarshalText

func (c *ChangeID) MarshalText() ([]byte, error)

MarshalText encodes `c` in the from of "c.Host:c.Number".

func (*ChangeID) UnmarshalText

func (c *ChangeID) UnmarshalText(b []byte) error

UnmarshalText decodes the bytes and sets `*c` to the resurrected `ChangeID`.

Jump to

Keyboard shortcuts

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