deployer

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deployer

type Deployer interface {
	// Start must be called only once to start the job processing
	Start()
	// Stop must be called only once and when start has been called
	Stop()
	// Deploy triggers a job to deploy a release. It returns a jobID that can be
	// used to check the job's status.
	Deploy(releaseID, tag string, releaseURL *url.URL) (string, error)
	// GetStatus returns the status of a job
	GetStatus(jobID string) (JobStatus, error)
	// GetLatestTag returns the latest tag associated to the release. If not tag
	// is found, returns 'unknown'.
	GetLatestTag(releaseID string) (string, error)
}

Deployer defines the primitive needed to deploy releases

func NewFileDeployer

func NewFileDeployer(db *buntdb.DB, conf config.Config, client HTTPClient,
	logger zerolog.Logger) Deployer

NewFileDeployer returns a new initialized file deployer

type FileDeployer

type FileDeployer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

FileDeployer implements a Deployer that deploys releases on disk.

- implements deployer.Deployer

func (*FileDeployer) Deploy

func (fd *FileDeployer) Deploy(releaseID, tag string, releaseURL *url.URL) (string, error)

Deploy implements deployer.Deployer. It adds a new job to the queue.

func (*FileDeployer) GetLatestTag added in v1.0.0

func (fd *FileDeployer) GetLatestTag(releaseID string) (string, error)

GetLatestTag implements deployer.Deployer

func (*FileDeployer) GetStatus

func (fd *FileDeployer) GetStatus(key string) (JobStatus, error)

GetStatus implements deployer.Deployer

func (*FileDeployer) Start

func (fd *FileDeployer) Start()

Start implements deployer.Deployer. This is a blocking function that handles jobs. It must be called only once.

func (*FileDeployer) Stop

func (fd *FileDeployer) Stop()

Stop implements deployer.Deployer. Must be called only once and if already started.

type HTTPClient

type HTTPClient interface {
	Get(url string) (resp *http.Response, err error)
}

HTTPClient defines the function we expect from an HTTP client

type JSONSerde

type JSONSerde struct{}

JSONSerde defines a serde type based on JSON

- implements deployer.serde

func (JSONSerde) Marshal

func (JSONSerde) Marshal(v any) ([]byte, error)

Marshal implements deployer.serde

func (JSONSerde) Unmarshal

func (JSONSerde) Unmarshal(data []byte, v any) error

Unmarshal implements deployer.Serde

type JobStatus

type JobStatus struct {
	Status  string `json:"status"`
	Message string `json:"message"`
}

JobStatus represents the status of a job. A job is created each time a deployment is triggered. It allows for asynchronous release deployment.

type Serde

type Serde interface {
	Marshal(v any) ([]byte, error)
	Unmarshal(data []byte, v any) error
}

Serde ddefines the primitives to marshal/unmarshal an element

Jump to

Keyboard shortcuts

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