cheek

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2022 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Info notificationType = iota
	Error
)

Variables

View Source
var Version = "development"

Version will be set through build flags used to print version via cmd.

Functions

func CheekPath

func CheekPath() string

func CoreJsonLogger

func CoreJsonLogger() io.Writer

func JobRunWebhookCall

func JobRunWebhookCall(jr *JobRun, webhookURL string) ([]byte, error)

func NewLogger

func NewLogger(logLevel string, extraWriters ...io.Writer) zerolog.Logger

Configures the package's global logger, also allows to pass in custom writers for testing purposes.

func PrettyStdout

func PrettyStdout() io.Writer

func RunJob

func RunJob(log zerolog.Logger, cfg Config, fn string, jobName string)

RunJob allows to run a specific job

func RunSchedule

func RunSchedule(log zerolog.Logger, cfg Config, fn string)

RunSchedule is the main entry entrypoint of cheek.

func TUI

func TUI(log zerolog.Logger, scheduleFile string)

TUI is the main entrypoint for the cheek ui.

Types

type Config

type Config struct {
	Pretty       bool   `yaml:"pretty"`
	SuppressLogs bool   `yaml:"suppressLogs"`
	LogLevel     string `yaml:"logLevel"`
	HomeDir      string `yaml:"homedir"`
	Port         string `yaml:"port"`
	Telemetry    bool   `yaml:"telemetry"`
	PhoneHomeUrl string `yaml:"phoneHomeUrl"`
}

func NewConfig

func NewConfig() Config

type ET

type ET struct{}

func (ET) PhoneHome

func (et ET) PhoneHome(phoneHomeUrl string) ([]byte, error)

type JobRun

type JobRun struct {
	Status int `json:"status"`

	Log         string    `json:"log"`
	Name        string    `json:"name"`
	TriggeredAt time.Time `json:"triggered_at"`
	TriggeredBy string    `json:"triggered_by"`
	Triggered   []string  `json:"triggered,omitempty"`
	// contains filtered or unexported fields
}

JobRun holds information about a job execution.

func (*JobRun) Close

func (jr *JobRun) Close()

type JobSpec

type JobSpec struct {
	Cron    string      `yaml:"cron,omitempty" json:"cron,omitempty"`
	Command stringArray `yaml:"command" json:"command"`

	OnSuccess OnEvent `yaml:"on_success,omitempty" json:"on_success,omitempty"`
	OnError   OnEvent `yaml:"on_error,omitempty" json:"on_error,omitempty"`

	Name    string `json:"name"`
	Retries int    `yaml:"retries,omitempty" json:"retries,omitempty"`
	Env     map[string]string
	// contains filtered or unexported fields
}

JobSpec holds specifications and metadata of a job.

func (*JobSpec) OnEvent

func (j *JobSpec) OnEvent(jr *JobRun, suppressLogs bool)

func (*JobSpec) ValidateCron

func (j *JobSpec) ValidateCron() error

type OnEvent

type OnEvent struct {
	TriggerJob    []string `yaml:"trigger_job,omitempty" json:"trigger_job,omitempty"`
	NotifyWebhook []string `yaml:"notify_webhook,omitempty" json:"notify_webhook,omitempty"`
}

OnEvent contains specs on what needs to happen after a job event.

type Schedule

type Schedule struct {
	Jobs       map[string]*JobSpec `yaml:"jobs" json:"jobs"`
	OnSuccess  OnEvent             `yaml:"on_success,omitempty" json:"on_success,omitempty"`
	OnError    OnEvent             `yaml:"on_error,omitempty" json:"on_error,omitempty"`
	TZLocation string              `yaml:"tz_location,omitempty" json:"tz_location,omitempty"`
	// contains filtered or unexported fields
}

Schedule defines specs of a job schedule.

func (*Schedule) Run

func (s *Schedule) Run()

Run a Schedule based on its specs.

func (*Schedule) Validate

func (s *Schedule) Validate() error

Validate Schedule spec and logic.

Jump to

Keyboard shortcuts

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