Documentation ¶
Index ¶
- Constants
- type Client
- func (c *Client) AddLogs(id string, logs ...model.Log)
- func (c *Client) CanAddActivity(id string, activity string) (bool, string)
- func (c *Client) CheckQuota(id string, opts *opts.QuotaOptions) error
- func (c *Client) Create(id, ownerID string, deploymentCreate *body.DeploymentCreate) error
- func (c *Client) Delete(id string) error
- func (c *Client) DoCommand(id string, command string)
- func (c *Client) Get(id string, opts ...opts.GetOpts) (*model.Deployment, error)
- func (c *Client) GetByName(name string, opts ...opts.GetOpts) (*model.Deployment, error)
- func (c *Client) GetCiConfig(id string) (*body.CiConfig, error)
- func (c *Client) GetUsage(userID string) (*model.DeploymentUsage, error)
- func (c *Client) Harbor() *harbor_service.Client
- func (c *Client) K8s() *k8s_service.Client
- func (c *Client) List(opts ...opts.ListOpts) ([]model.Deployment, error)
- func (c *Client) NameAvailable(name string) (bool, error)
- func (c *Client) Repair(id string) error
- func (c *Client) Restart(id string) error
- func (c *Client) SetupLogStream(id string, ctx context.Context, ...) error
- func (c *Client) StartActivity(id string, activity string) error
- func (c *Client) Update(id string, dtoUpdate *body.DeploymentUpdate) error
- func (c *Client) UpdateOwner(id string, params *model.DeploymentUpdateOwnerParams) error
- func (c *Client) ValidateHarborToken(secret string) bool
Constants ¶
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 (*Client) CanAddActivity ¶
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 ¶
Delete deletes an existing deployment.
It returns an error if the deployment is not found.
func (*Client) DoCommand ¶
DoCommand executes a command on the deployment.
It is purely done in best-effort
func (*Client) Get ¶
Get gets an existing deployment.
It can be fetched in multiple ways including ID, transfer code, and Harbor webhook.
func (*Client) GetByName ¶
GetByName gets an existing deployment by name. This does not support shared deployments.
func (*Client) GetCiConfig ¶
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) NameAvailable ¶
NameAvailable checks if a name is available.
func (*Client) Repair ¶
Repair repairs an existing deployment.
Trigger repair jobs for every subsystem.
func (*Client) Restart ¶
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 ¶
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 ¶
ValidateHarborToken validates the Harbor token.