deployments

package
v0.0.0-...-e71a76f Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2025 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MessageSourceControl is the source of the message from the control.
	// The handler should ignore these messages, as they are only intended to check if the log stream is working.
	MessageSourceControl = "control"

	// MessageSourceKeepAlive is the source of the message from the keep alive.
	// They are sent to the client to keep the connection alive.
	MessageSourceKeepAlive = "keep-alive"

	// FetchPeriod is the period between each fetch of logs from the database.
	FetchPeriod = 300 * time.Millisecond
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// V2 is a reference to the parent client.
	V2 clients.V2

	client.BaseClient[Client]
}

Client is the client for the Deployment service. It is used as a wrapper around the BaseClient.

func New

func New(v2 clients.V2, cache ...*core.Cache) *Client

New creates a new deployment service client.

func (*Client) AddLogs

func (c *Client) AddLogs(id string, logs ...model.Log)

AddLogs adds logs to the deployment.

It is purely done in best-effort

func (*Client) CanAddActivity

func (c *Client) CanAddActivity(id string, activity string) (bool, string)

CanAddActivity checks if the deployment can add an activity.

It returns a boolean indicating if the activity can be added, and a string indicating the reason if it cannot.

func (*Client) CheckQuota

func (c *Client) CheckQuota(id string, opts *opts.QuotaOptions) error

CheckQuota checks if the user has enough quota to create or update a deployment.

Make sure to specify either opts.Create or opts.Update in the options (opts.Create takes priority).

It returns an error if the user does not have enough quotas.

func (*Client) Create

func (c *Client) Create(id, ownerID string, deploymentCreate *body.DeploymentCreate) error

Create creates a new deployment.

It returns an error if the deployment already exists (name clash).

func (*Client) Delete

func (c *Client) Delete(id string) error

Delete deletes an existing deployment.

It returns an error if the deployment is not found.

func (*Client) DoCommand

func (c *Client) DoCommand(id string, command string)

DoCommand executes a command on the deployment.

It is purely done in best-effort

func (*Client) Get

func (c *Client) Get(id string, opts ...opts.GetOpts) (*model.Deployment, error)

Get gets an existing deployment.

It can be fetched in multiple ways including ID, transfer code, and Harbor webhook.

func (*Client) GetByName

func (c *Client) GetByName(name string, opts ...opts.GetOpts) (*model.Deployment, error)

GetByName gets an existing deployment by name. This does not support shared deployments.

func (*Client) GetCiConfig

func (c *Client) GetCiConfig(id string) (*body.CiConfig, error)

GetCiConfig returns the CI config for the deployment.

It returns an error if the deployment is not found, or if the deployment is not ready. It returns nil if the deployment is not a custom deployment.

func (*Client) GetUsage

func (c *Client) GetUsage(userID string) (*model.DeploymentUsage, error)

GetUsage gets the usage of the user.

func (*Client) Harbor

func (c *Client) Harbor() *harbor_service.Client

Harbor returns the client for the Harbor service.

func (*Client) K8s

func (c *Client) K8s() *k8s_service.Client

K8s returns the client for the K8s service.

func (*Client) List

func (c *Client) List(opts ...opts.ListOpts) ([]model.Deployment, error)

List lists existing deployments.

func (*Client) NameAvailable

func (c *Client) NameAvailable(name string) (bool, error)

NameAvailable checks if a name is available.

func (*Client) Repair

func (c *Client) Repair(id string) error

Repair repairs an existing deployment.

Trigger repair jobs for every subsystem.

func (*Client) Restart

func (c *Client) Restart(id string) error

Restart restarts a deployment.

It is done in best-effort, and only returns an error if any pre-check fails.

func (*Client) SetupLogStream

func (c *Client) SetupLogStream(id string, ctx context.Context, handler func(string, string, string, time.Time), history int) error

SetupLogStream sets up a log stream for the deployment.

It will continuously check the deployment logs and read the logs after the last read log. Increasing the history will increase the time it takes to set up the log stream.

func (*Client) StartActivity

func (c *Client) StartActivity(id string, activity string) error

StartActivity starts an activity for the deployment.

It only starts the activity if it is allowed, determined by CanAddActivity. It returns a boolean indicating if the activity was started, and a string indicating the reason if it was not.

func (*Client) Update

func (c *Client) Update(id string, dtoUpdate *body.DeploymentUpdate) error

Update updates an existing deployment.

It returns an error if the deployment is not found.

func (*Client) UpdateOwner

func (c *Client) UpdateOwner(id string, params *model.DeploymentUpdateOwnerParams) error

UpdateOwner updates the owner of the deployment.

This is the second step of the owner update process, where the transfer is actually done.

It returns an error if the deployment is not found.

func (*Client) ValidateHarborToken

func (c *Client) ValidateHarborToken(secret string) bool

ValidateHarborToken validates the Harbor token.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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