agent

package
v0.0.0-...-9e50b09 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DeploymentStateError   deploymentState = "error"
	DeploymentStateFailure deploymentState = "failure"
	DeploymentStateSuccess deploymentState = "success"
)

Variables

View Source
var ErrHookNotFound error = errors.New("unknown hook")

Functions

func FindState

func FindState(statuses []*github.DeploymentStatus, needleStates ...deploymentState) int

Types

type Agent

type Agent struct {
	Log         Logger
	Deployments *DeploymentOptions
	Deployer    *Deployer
}

Agent applies deployments

func (Agent) Run

func (agent Agent) Run(ctx context.Context, loop bool, sleepTime time.Duration) error

type Deployer

type Deployer struct {
	Deployments *DeploymentOptions
	Hooks       *Hooks
	Log         Logger
}

func (Deployer) Deploy

func (deployer Deployer) Deploy(ctx context.Context, depl *github.Deployment) error

type DeploymentOptions

type DeploymentOptions struct {
	Owner, Repo string
	Env         string
	Client      *github.Client
}

func (*DeploymentOptions) CreateDeploymentStatus

func (api *DeploymentOptions) CreateDeploymentStatus(ctx context.Context, depl *github.Deployment, state deploymentState, desc string) error

CreateDeploymentStatus publishes a new status message for the given deployment object.

see https://developer.github.com/v3/repos/deployments/#create-a-deployment-status state = pending | success | error | failure description = string(140)

func (*DeploymentOptions) FindNewestDeployment

func (api *DeploymentOptions) FindNewestDeployment(ctx context.Context) (*github.Deployment, error)

func (*DeploymentOptions) HasSuccessStatus

func (api *DeploymentOptions) HasSuccessStatus(ctx context.Context, depl *github.Deployment) (bool, error)

func (*DeploymentOptions) ListDeployments

func (api *DeploymentOptions) ListDeployments(ctx context.Context) (deployments []*github.Deployment, err error)

type Hooks

type Hooks struct {
	Path string
	// contains filtered or unexported fields
}

hooksCtx is used to define how to execute the hook scripts. When creating, the environment variables are provided.

func (*Hooks) WithEnv

func (h *Hooks) WithEnv(env []string) *Hooks

type Logger

type Logger interface {
	Printf(format string, v ...interface{})
	Println(v ...interface{})
}

Jump to

Keyboard shortcuts

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