api

package
v0.0.0-...-ea333bb Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const LogsTruncationLength = 2000

Variables

This section is empty.

Functions

func ValidateTagName

func ValidateTagName(tagName string) string

Types

type CronitorApi

type CronitorApi struct {
	DryRun         bool
	ApiKey         string
	IsAutoDiscover bool
	UserAgent      string
}

Temporarily borrowed from https://github.com/cronitorio/cronitor-cli/blob/a5e2b681c89ff8fd5803551206d7ce9674122bd1/lib/cronitor.go#L44

func NewCronitorApi

func NewCronitorApi(apikey string, dryRun bool) CronitorApi

func (CronitorApi) MakeAndSendTelemetryJobEventAndLogs

func (api CronitorApi) MakeAndSendTelemetryJobEventAndLogs(event *pkg.JobEvent, logs string, pod *corev1.Pod, job *v1.Job, cronjob *v1.CronJob) error

func (CronitorApi) MakeAndSendTelemetryPodEventAndLogs

func (api CronitorApi) MakeAndSendTelemetryPodEventAndLogs(event *pkg.PodEvent, logs string, pod *corev1.Pod, job *v1.Job, cronjob *v1.CronJob) error

func (CronitorApi) PutCronJob

func (api CronitorApi) PutCronJob(cronJob *v1.CronJob) ([]*lib.Monitor, error)

func (CronitorApi) PutCronJobs

func (api CronitorApi) PutCronJobs(cronJobs []*v1.CronJob) ([]*lib.Monitor, error)

func (CronitorApi) ShipLogData

func (api CronitorApi) ShipLogData(params *TelemetryEvent) ([]byte, error)

type CronitorApiError

type CronitorApiError struct {
	Err      error
	Response *http.Response
}

func (CronitorApiError) Error

func (c CronitorApiError) Error() string

func (CronitorApiError) ResponseBody

func (c CronitorApiError) ResponseBody() ([]byte, error)

func (*CronitorApiError) Unwrap

func (c *CronitorApiError) Unwrap() error

type CronitorJob

type CronitorJob struct {
	Key          string   `json:"key"`
	Name         string   `json:"name,omitempty"`
	DefaultNote  string   `json:"defaultNote,omitempty"`
	Metadata     string   `json:"metadata"` // This is actually a string rather than a map
	Type_        string   `json:"type"`     // 'job'
	Schedule     string   `json:"schedule"`
	Tags         []string `json:"tags,omitempty"`
	Notify       []string `json:"notify,omitempty"`
	Group        string   `json:"group,omitempty"`
	GraceSeconds int      `json:"grace_seconds,omitempty"`
}

https://docs.google.com/document/d/1erh-fvTkF14jyJGv3DYuN2UalWe6AN49XOUsWHJccso/edit#heading=h.ylm2gai335jy

func (CronitorJob) GetEnvironment

func (cronitorJob CronitorJob) GetEnvironment() string

type TelemetryEvent

type TelemetryEvent struct {
	CronJob   *v1.CronJob
	Event     TelemetryEventStatus
	Message   string
	ErrorLogs string
	// Timestamp in seconds with 3 decimal places for microsecond
	Timestamp string
	// Series is a UUID to distinguish different sets of pings in a series.
	// In Kubernetes, this is loosely analogous to a Job instance of a CronJob, so we use the
	// Job's UUID, which will stay stable even on multiple pod retries.
	Series   *types.UID
	ExitCode *int
	Env      string
	// Host is the Kubernetes node that the pod is running on
	Host   string
	Metric string
}

func NewTelemetryEventFromKubernetesJobEvent

func NewTelemetryEventFromKubernetesJobEvent(event *pkg.JobEvent, logs string, pod *corev1.Pod, job *v1.Job, cronjob *v1.CronJob) (*TelemetryEvent, error)

func NewTelemetryEventFromKubernetesPodEvent

func NewTelemetryEventFromKubernetesPodEvent(event *pkg.PodEvent, logs string, pod *corev1.Pod, job *v1.Job, cronjob *v1.CronJob) (*TelemetryEvent, error)

func (TelemetryEvent) CreateLogTelemetryEvent

func (t TelemetryEvent) CreateLogTelemetryEvent() *TelemetryEvent

func (TelemetryEvent) Encode

func (t TelemetryEvent) Encode() string

type TelemetryEventStatus

type TelemetryEventStatus string
const (
	Run      TelemetryEventStatus = "run"
	Complete TelemetryEventStatus = "complete"
	Fail     TelemetryEventStatus = "fail"
	Ok       TelemetryEventStatus = "ok"
	Logs     TelemetryEventStatus = "logs"
)

func TranslatePodEventReasonToTelemetryEventStatus

func TranslatePodEventReasonToTelemetryEventStatus(event *pkg.PodEvent) (*TelemetryEventStatus, error)

Jump to

Keyboard shortcuts

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