deploysrv

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(h Hooker) error

Register allows to register custom Hookers. Must be called after New and before ListenAndServe.

Types

type CallbackData

type CallbackData struct {
	ID          uuid.UUID
	CallbackURL string
	Description string
	Context     string
	Error       error
	ResultsURL  string
}

type Config

type Config struct {
	// ServerURL is the server url for results callback.
	ServerURL string `yaml:"server_url"`
	// Cert is the certificate for TLS enabled listener.
	Cert string `yaml:"cert"`
	// Key is the key for TLS enabled listener.
	Key string `yaml:"key"`
	// ResultsDir is the directory to store results.
	ResultsDir string `yaml:"results_dir"`
	// Deployments is the list of deployments.
	Deployments []Deployment `yaml:"deployments"`
}

func LoadConfig

func LoadConfig(filename string) (Config, error)

func (*Config) IsEmpty

func (c *Config) IsEmpty() bool

type Deployment

type Deployment struct {
	// Type is the deployment type from the [hookers] package, (i.e.
	// dockerhub).
	Type string `yaml:"type"`
	// Disabled is the flag to disable the deployment.
	Disabled bool `yaml:"disabled"`
	// Workdir is the directory where the deployment is located, hubdeploy
	// will change to this directory before running the command.
	Workdir string `yaml:"work_dir"`
	// Command is the command to run in the workdir.
	Command []string `yaml:"command"`
	// Payload is the configuration of the deployment type, i.e. dockerhub
	// configuration.
	Payload any `yaml:"payload"`
}

type Hooker

type Hooker interface {
	// Register must register a deployment. If deployment type is different then
	// the one handled it must return nil.
	Register(Deployment) error
	// Handle must handle the incoming webhook and post a Job to a Job channel.
	Handler(chan<- Job) http.HandlerFunc
	// Callback can send (or not, if not implemented by the caller) the callback
	// to source system with the build results info.
	Callback(CallbackData) error
	// Type must return the string that will be used as deployment type.  It
	// will also be a path of a webhook.
	Type() string
}

Hooker is the interface for pluggable webhook handlers.

type Job

type Job struct {
	CallbackURL string
	Dep         Deployment
}

type Option

type Option func(*Server)

func OptWithCert

func OptWithCert(cert, privkey string) Option

OptWithCert allows to specify the certificate and the private key for TLS Listener.

func OptWithPrefix

func OptWithPrefix(prefix string) Option

OptWithPrefix allows to set the url prefix for the muxer.

func OptWithResultDir

func OptWithResultDir(dir string) Option

OptWithResultDir sets the directory which will contain the results of deployment (combined STDOUT and STDERR outputs).

type Server

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

func New

func New(c Config, opts ...Option) (*Server, error)

New constructs new hubdeploy server instance.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(addr string) error

ListenAndServe listens for incoming connections on the specified address and Serves them.

Jump to

Keyboard shortcuts

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