plugin

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2025 License: MPL-2.0 Imports: 5 Imported by: 0

README

plugin-go

Go SDK to write plugins for ganvil.

Take a look at the examples and the documentation to get started.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ptr

func Ptr[T any](t T) *T

func ServePlugin

func ServePlugin(p Plugin)

ServePlugin starts the go-plugin process and serves the plugin.

Types

type Base

type Base struct{}

Base is a base implementation of Plugin. Plugin authors can embed this struct to implement only those methods of Plugin they need.

type ExamplePlugin struct {
	plugin.Base
}

func (Base) Apply

func (p Base) Apply(ctx Context) error

Apply implements Plugin.

func (Base) Filter

func (p Base) Filter(ctx Context) (bool, error)

Filter implements Plugin.

func (Base) Init

func (p Base) Init(config map[string]string) error

Init implements Plugin.

func (Base) OnPrClosed

func (p Base) OnPrClosed(ctx Context) error

OnPrClosed implements Plugin.

func (Base) OnPrCreated

func (p Base) OnPrCreated(ctx Context) error

OnPrCreated implements Plugin.

func (Base) OnPrMerged

func (p Base) OnPrMerged(ctx Context) error

OnPrMerged implements Plugin.

func (Base) Shutdown

func (p Base) Shutdown() error

Shutdown executes code to clean up data before the plugin shuts down. The function gets executed once, right before saturn-bot stops the plugin.

type Context

type Context struct {
	*protocolv1.Context
}

Context contains data on which repository to process.

type Plugin

type Plugin interface {
	// Apply executes code that modifies the content of a repository.
	Apply(ctx Context) error
	// Filter decides if the plugin should modify contents in a repository.
	// It is executed before Apply.
	Filter(ctx Context) (bool, error)
	// Init is called once after Ganvil started the plugin.
	// config contains configuration values set in the task file.
	Init(config map[string]string) error
	// Name returns the name of the plugin.
	Name() string
	// OnPrClosed executes code when Ganvil closes a pull request.
	OnPrClosed(ctx Context) error
	// OnPrCreated executes code when Ganvil creates a pull request.
	OnPrCreated(ctx Context) error
	// OnPrMerged executes code when Ganvil merges a pull request.
	OnPrMerged(ctx Context) error
	// Shutdown is called once right before Ganvil shuts down the plugin.
	// It can execute code to free allocated resources or close connections.
	Shutdown() error
}

Plugin defines all methods that a Go plugin must implement.

Jump to

Keyboard shortcuts

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