nomad

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2024 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// AllocAdminActions maps allocation-specific AdminActions to their display text
	AllocAdminActions = map[AdminAction]string{
		RestartTaskAction:  "Restart",
		RestartAllocAction: "Restart",
		StopAllocAction:    "Stop",
	}
)
View Source
var (
	JobAdminActions = map[AdminAction]string{
		StopJobAction:         "Stop",
		StopAndPurgeJobAction: "Stop and purge",
	}
)

Functions

func AdminActionToKey added in v1.1.0

func AdminActionToKey(adminAction AdminAction) string

AdminActionToKey and KeyToAdminAction are used for admin menu serialization/deserialization

func AllocExec added in v0.14.0

func AllocExec(client *api.Client, allocID, task string, args []string) (int, error)

func FetchAllTasks added in v0.10.0

func FetchAllTasks(client api.Client, columns []string) tea.Cmd

func FetchAllocSpec

func FetchAllocSpec(client api.Client, allocID string) tea.Cmd

func FetchEventsStream added in v0.4.0

func FetchEventsStream(client api.Client, topics Topics, namespace string, page Page) tea.Cmd

func FetchJobMeta added in v0.10.0

func FetchJobMeta(client api.Client, jobID, jobNamespace string) tea.Cmd

func FetchJobSpec

func FetchJobSpec(client api.Client, jobID, jobNamespace string) tea.Cmd

func FetchJobs

func FetchJobs(client api.Client, columns []string) tea.Cmd

func FetchLogs

func FetchLogs(client api.Client, alloc api.Allocation, taskName string, logType LogType, logOffset int, logTail bool) tea.Cmd

func FetchStats added in v0.12.0

func FetchStats(client api.Client, allocID, allocName string) tea.Cmd

func FetchTasksForJob added in v0.10.0

func FetchTasksForJob(client api.Client, jobID, jobNamespace string, columns []string) tea.Cmd

func GetAllPageConfigs added in v0.4.3

func GetAllPageConfigs(width, height int, compactTables bool) map[Page]page.Config

func GetAllocAdminText added in v1.1.0

func GetAllocAdminText(adminAction AdminAction, taskName, allocName, allocID string) string

func GetCmdForAllocAdminAction added in v1.1.0

func GetCmdForAllocAdminAction(
	client api.Client,
	adminAction AdminAction,
	taskName,
	allocName,
	allocID string,
) tea.Cmd

func GetCmdForJobAdminAction added in v1.1.0

func GetCmdForJobAdminAction(
	client api.Client,
	adminAction AdminAction,
	jobID, jobNamespace string,
) tea.Cmd

func GetJobAdminText added in v1.1.0

func GetJobAdminText(adminAction AdminAction, jobID string) string

func GetPageKeyHelp

func GetPageKeyHelp(
	currentPage Page,
	filterFocused, filterApplied, saving bool,
	logType LogType,
	compact, inJobsMode bool,
) string

func JobIDAndNamespaceFromKey

func JobIDAndNamespaceFromKey(key string) (string, string)

func NewReader added in v0.14.0

func NewReader(r io.Reader, c byte, h Handler) io.Reader

NewReader returns a reader that escapes the c character (following new lines), in the same manner OpenSSH handling, which defaults to `~`.

For illustrative purposes, we use `~` in documentation as a shorthand for escaping character.

If following a new line, reader sees:

  • `~~`, only one is emitted
  • `~.` (or any character), the handler is invoked with the character. If handler returns true, `~.` will be skipped; otherwise, it's propagated.
  • `~` and it's the last character in stream, it's propagated

Appearances of `~` when not preceded by a new line are propagated unmodified.

func PrettifyLine added in v0.4.0

func PrettifyLine(l string, p Page) tea.Cmd

func ReadEventsStreamNextMessage added in v0.4.0

func ReadEventsStreamNextMessage(c EventsStream, code *gojq.Code) tea.Cmd

func ReadLogsStreamNextMessage added in v0.9.0

func ReadLogsStreamNextMessage(c LogsStream) tea.Cmd

func RestartAllocation added in v1.1.0

func RestartAllocation(client api.Client, allocName, allocID string) tea.Cmd

func RestartTask added in v1.1.0

func RestartTask(client api.Client, taskName, allocName, allocID string) tea.Cmd

func StopAllocation added in v1.1.0

func StopAllocation(client api.Client, allocName, allocID string) tea.Cmd

func StopJob added in v1.1.0

func StopJob(client api.Client, jobID, jobNamespace string, purge bool) tea.Cmd

func UpdatePageDataWithDelay added in v0.3.0

func UpdatePageDataWithDelay(id int, p Page, d time.Duration) tea.Cmd

Update page data with a delay. This is useful for pages that update.

Types

type AdminAction added in v1.1.0

type AdminAction int8
const (
	RestartTaskAction AdminAction = iota
	RestartAllocAction
	StopAllocAction
	RestartJobAction
	StopJobAction
	StopAndPurgeJobAction
)

all admin actions, task or job the definition order of these is important, as it's used for sorting

func KeyToAdminAction added in v1.1.0

func KeyToAdminAction(adminAction string) AdminAction

type AllocAdminActionCompleteMsg added in v1.1.0

type AllocAdminActionCompleteMsg struct {
	Err                          error
	TaskName, AllocName, AllocID string
}

type Event added in v0.9.1

type Event struct {
	CompleteValue, JQValue string
}

type EventsStream added in v0.6.0

type EventsStream struct {
	Chan      <-chan *api.Events
	Topics    Topics
	Namespace string
}

type EventsStreamMsg added in v0.4.0

type EventsStreamMsg struct {
	Events []Event
	Topics Topics
}

type ExecCompleteMsg added in v0.14.0

type ExecCompleteMsg struct {
	Output string
}

type Handler added in v0.14.0

type Handler func(c byte) bool

Handler is a callback for handling an escaped char. Reader would skip the escape char and passed char if returns true; otherwise, it preserves them in output

type JobAdminActionCompleteMsg added in v1.1.0

type JobAdminActionCompleteMsg struct {
	Err   error
	JobID string
}

type LogType

type LogType int8
const (
	StdOut LogType = iota
	StdErr
)

func (LogType) ShortString

func (p LogType) ShortString() string

func (LogType) String

func (p LogType) String() string

type LogsStream added in v0.9.0

type LogsStream struct {
	Chan    <-chan *api.StreamFrame
	LogType LogType
}

type LogsStreamMsg added in v0.9.0

type LogsStreamMsg struct {
	Value string // may include line breaks
	Type  LogType
}

type Page

type Page int8
const (
	Unset Page = iota
	JobsPage
	AllTasksPage
	JobSpecPage
	JobEventsPage
	JobEventPage
	JobMetaPage
	AllocEventsPage
	AllocEventPage
	AllEventsPage
	AllEventPage
	JobTasksPage
	ExecPage
	ExecCompletePage
	AllocSpecPage
	LogsPage
	LoglinePage
	StatsPage
	AllocAdminPage
	AllocAdminConfirmPage
	JobAdminPage
	JobAdminConfirmPage
)

func (Page) Backward

func (p Page) Backward(inJobsMode bool) Page

func (Page) CanBeFirstPage added in v0.12.0

func (p Page) CanBeFirstPage() bool

func (Page) DoesLoad added in v0.3.0

func (p Page) DoesLoad() bool

func (Page) DoesReload added in v0.3.0

func (p Page) DoesReload() bool

func (Page) Forward

func (p Page) Forward(inJobsMode bool) Page

func (Page) GetFilterPrefix

func (p Page) GetFilterPrefix(namespace, jobID, taskName, allocName, allocID string, eventTopics Topics, eventNamespace string) string

func (Page) HasAdminMenu added in v1.1.0

func (p Page) HasAdminMenu() bool

func (Page) LoadingString

func (p Page) LoadingString() string

func (Page) ShowsTasks added in v0.10.0

func (p Page) ShowsTasks() bool

func (Page) String

func (p Page) String() string

type PageLoadedMsg

type PageLoadedMsg struct {
	Page         Page
	TableHeader  []string
	AllPageRows  []page.Row
	EventsStream EventsStream
	LogsStream   LogsStream
}

type StdoutProxy added in v0.14.0

type StdoutProxy struct {
	SavedOutput []byte
}

func (*StdoutProxy) Write added in v0.14.0

func (so *StdoutProxy) Write(p []byte) (n int, err error)

type TaskInfo added in v0.10.0

type TaskInfo struct {
	Alloc    api.Allocation
	TaskName string
	Running  bool
}

func TaskInfoFromKey added in v0.10.0

func TaskInfoFromKey(key string) (TaskInfo, error)

type Topics added in v0.6.0

type Topics map[api.Topic][]string

func TopicsForAlloc added in v0.7.0

func TopicsForAlloc(topics Topics, allocID string) Topics

func TopicsForJob added in v0.5.0

func TopicsForJob(topics Topics, job string) Topics

type UpdatePageDataMsg added in v0.3.0

type UpdatePageDataMsg struct {
	ID   int
	Page Page
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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