model package - github.com/titpetric/task-ui/server/model - Go Packages

model

package
v0.0.0-...-105c24f Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("record not found")

Functions

This section is empty.

Types

type Command

type Command struct {
	Name string
	Args []string
}

type ErrorBody

type ErrorBody struct {
	// Message contains the string representation of an error.
	Message string `json:"message"`
}

ErrorBody is the encoding for an error message.

type ErrorResponse

type ErrorResponse struct {
	// Error holds the error value
	Err error `json:"-"`

	// StatusCode holds the http response code.
	StatusCode int `json:"-"`

	// Status is the readable http message of StatusCode.
	Status string `json:"status"`

	// Error holds the encoded error message.
	Error ErrorBody `json:"error,omitempty"`
}

ErrorResponse renderer type for errors.

func InternalServerError

func InternalServerError(err error) *ErrorResponse

func NewErrorResponse

func NewErrorResponse(code int, err error) *ErrorResponse

NewErrorResponse produces a filled ErrorResponse object.

func NotFoundError

func NotFoundError(err error) *ErrorResponse

func (*ErrorResponse) Render

Render is a hook to print status code in header.

func (*ErrorResponse) WithError

func (e *ErrorResponse) WithError(err error) *ErrorResponse

Error sets the error message and returns a new ErrorResponse.

type HistoryRecord

type HistoryRecord struct {
	ID        string
	Timestamp int64
	Datetime  string
	Seconds   int
	Lines     int
}

type HistoryResponse

type HistoryResponse struct {
	Files   []string
	History map[string][]HistoryRecord
}

func NewHistoryResponse

func NewHistoryResponse() *HistoryResponse

type Task

type Task struct {
	Name        string   `yaml:"name"`
	Description string   `yaml:"desc"`
	Summary     string   `yaml:"summary"`
	Aliases     []string `yaml:"aliases"`

	Internal    bool `yaml:"internal"`
	Interactive bool `yaml:"interactive"`
}

type TaskFlags

type TaskFlags struct {
	Internal    bool
	Interactive bool
}

TaskFlags holds some task flags.

type TaskInfo

type TaskInfo struct {
	Task        string // Task holds the task name, e.g. `lint`.
	Description string // Description holds the task description.

	// Flags holds some flags
	Flags TaskFlags

	// History holds history data
	History []HistoryRecord `json:",omitempty"`
}

TaskInfo holds information available about a task, without coupling to taskfile structures too much. We need a subset of data available for the UI, we can still use the rest internally.

This is also the point where exposing vars and cmds becomes a security issue. We still assume that users may want to run it in less trusted environments, in which case we explicitly don't want any information about the contents of the taskfile beyond the target names and descriptions.

func NewTaskInfo

func NewTaskInfo(spec *Task) *TaskInfo

NewTaskInfo converts the taskfile record into our own.

type TaskMap

type TaskMap map[string]*Task

func (TaskMap) Item

func (t TaskMap) Item(name string) *Task

func (TaskMap) Keys

func (t TaskMap) Keys() []string

func (TaskMap) Values

func (t TaskMap) Values() []*Task

type Taskfile

type Taskfile struct {
	Tasks TaskMap `yaml:"tasks"`
}

func LoadTaskfile

func LoadTaskfile(filename string) (*Taskfile, error)

Jump to

Keyboard shortcuts

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