Documentation ¶
Index ¶
- type Client
- func (c *Client) Close()
- func (c *Client) GetBuild(ctx context.Context, references []string) (*spot.Build, error)
- func (c *Client) MonitorCondition(ctx context.Context, build *spot.Build, conditionType spot.BuildConditionType, ...)
- func (c *Client) MustGetBuild(ctx context.Context, references []string) *spot.Build
- func (c *Client) RecordErrorAndPanic(build *spot.Build, err error)
- type Task
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { *rest.RESTClient // contains filtered or unexported fields }
func NewClient ¶
Create a new Client that can communicate with the k8s cluster. This client will use the pod's service account to connect to the cluster and so requires read-write-list permissions on the Build CRD.
func (*Client) GetBuild ¶
Return a Build custom resource from the k8s cluster. The build holds all the information to be able to build an image. If, for a reason or another, it can't retrieve the build set by the reference, this method will panic and terminate the process. Since it requires a k8s resource(*spot.Build) to record an event, it's not possible to gracefully communicate with the operator. It is the operator's responsibility, in this case, to either retry, or mark the build as errored.
func (*Client) MonitorCondition ¶
func (c *Client) MonitorCondition(ctx context.Context, build *spot.Build, conditionType spot.BuildConditionType, fn Task)
Monitor condition takes a conditionType and a Task. It will set the condition's status throughout the lifecycle of a task. Each task's lifecycle is identical from the condition status' perspective where it starts by updating the condition to be InProgress, once the task is finished, it will check if it returned any error. Depending on whether an error exist, the Condition's Status will either be Success or Error.
It's important to understand that this function will make 3 PUT request to the REST API and multiple MonitorCondition *cannot* run in parallel.
If an error occur during a MonitorCondition, there will be an attempt to notify k8s that this build had a fatal error. Then, this method will panic, which will result in the process to die.
There will always be an attempt to create an Event record for the error and update the condition. But it's the best case scenario, if it fails, the operator will need to update the build itself.
func (*Client) MustGetBuild ¶
Same as GetBuild but panic if an error is returned.
type Task ¶
Task represents a function that execute operation on a build. If an error occur while executing the task, it is the function's responsibility to return it so that the function calling this task have the opportunity of setting states on the build before continuing.
Read more about the use of a Task at MonitorCondition()