callback

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ExternalType = "external"
	CommandType  = "command"
)

Variables

This section is empty.

Functions

func ValidateCallbacks

func ValidateCallbacks(callbacks []Callback) error

Types

type Callback

type Callback struct {
	Stage string             `yaml:"stage"`
	Pre   CallbackParameters `yaml:"pre,omitempty"`
	Post  CallbackParameters `yaml:"post,omitempty"`
}

func (*Callback) IsValid

func (c *Callback) IsValid() error

IsValid checks if the Callback structure is valid. It ensures that the stage name is provided and that either pre or post parameters exist. Additionally, it validates the pre and post parameters if they are set.

Returns:

  • error: An error if validation fails, otherwise nil.

func (Callback) PostRun

func (c Callback) PostRun(ctx context.Context, wg *sync.WaitGroup, logger interfaces.BuildLogger)

func (Callback) PreRun

func (c Callback) PreRun(ctx context.Context, wg *sync.WaitGroup, logger interfaces.BuildLogger)

type CallbackParameters

type CallbackParameters struct {
	Type       string   `yaml:"type"`
	Action     string   `yaml:"action"`
	Method     string   `yaml:"method,omitempty"`
	Parameters []string `yaml:"parameters,omitempty"`
}

func (*CallbackParameters) IsValid

func (c *CallbackParameters) IsValid() error

IsValid checks if the CallbackParameters structure is valid. It performs type, method, action, and parameters validation.

Returns:

  • error: An error if validation fails, otherwise nil.

func (*CallbackParameters) Run

Run executes the callback based on its type (external or command). It first validates the callback parameters, then either runs an external HTTP request or a system command depending on the `Type` of the callback.

Parameters:

  • ctx (context.Context): The context for the execution, used for cancellation and timeouts.
  • logger (BuildLogger): The logger to record any logs or errors during execution.

Returns:

  • error: Returns an error if validation fails or if execution of the callback fails.

Jump to

Keyboard shortcuts

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