Documentation
¶
Index ¶
- func WithLogs(logs *file.Streamer) func(*Job)
- func WithMaskedPhrases(phrases []string) func(*Job)
- func WithOperatorLogger(l *slog.Logger) func(*Job)
- type Job
- func (j *Job) Cancel()
- func (j *Job) Close()
- func (j *Job) Closed() <-chan struct{}
- func (j *Job) Done() <-chan struct{}
- func (j *Job) FollowLogs(ctx context.Context, offset int64, writer io.Writer) error
- func (j *Job) Interrupt(cause error) bool
- func (j *Job) Logs() (io.Writer, io.Writer)
- func (j *Job) Run(stepsCtx *runner.StepsContext, step runner.Function)
- func (j *Job) Status() *proto.Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithMaskedPhrases ¶ added in v0.37.0
WithMaskedPhrases supplies pre-known secrets to scrub from the Job's log output, typically values of CI variables marked masked=true.
func WithOperatorLogger ¶ added in v0.39.0
WithOperatorLogger sets the logger for operator-facing messages (e.g. job failures). Defaults to slog.Default().
Types ¶
type Job ¶
type Job struct {
TmpDir string
WorkDir string
Ctx context.Context // Cancelled when Run exits or Close is called, whichever comes first.
ID string // The ID of the job to run/being run. Must be unique. Typically this will be the CI job ID.
// contains filtered or unexported fields
}
func (*Job) Cancel ¶ added in v0.35.0
func (j *Job) Cancel()
Cancel sends a cancellation request to the job, giving steps a chance to exit gracefully.
func (*Job) Close ¶
func (j *Job) Close()
Close cancels jobs (if still running) and cleans up all resources associated with managing the job.
func (*Job) Closed ¶ added in v0.45.0
func (j *Job) Closed() <-chan struct{}
Closed is closed when Close has finished releasing the job's resources.
func (*Job) Done ¶ added in v0.45.0
func (j *Job) Done() <-chan struct{}
Done is closed when Run has returned.
func (*Job) FollowLogs ¶
FollowLogs writes the stdout/stderr captured from running steps to the supplied writer. The function blocks until the steps are run and logs are written to the writer. Errors returned are indicative of failure to write to the writer, not failure of running steps.
func (*Job) Interrupt ¶ added in v0.45.0
Interrupt marks a job that has not finished as failed with cause once Run returns, and reports whether it did so. Steps keep running: the caller decides when to stop serving, and stopping early would hide the cause behind a transport error. A job that has already finished is left alone (its result is final and may have been read), and so is a job that was already interrupted: the first cause is the one that matters.