storage

package
v0.6.0-next.7 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DB provides the gorm DB interface.
	DB *gorm.DB
)

Functions

func AddJob

func AddJob(j *models.Job) error

AddJob adds a Job to the database.

func AddNode

func AddNode(node *models.Node) error

AddNode adds a node to the database.

func AddTask

func AddTask(task *models.Task) error

AddTask adds a task to the database.

func AddUser

func AddUser(u models.User) error

AddUser adds a User to the database.

func DeleteJob

func DeleteJob(j *models.Job) error

DeleteJob deletes a Job in the database.

func DeleteNode

func DeleteNode(node *models.Node) error

DeleteNode deletes a node from the database.

func GetJob

func GetJob(id string) (*models.Job, bool)

GetJob checks if a job with the identifier exists and returns it.

func GetJobWithFullHistory

func GetJobWithFullHistory(id string) (*models.JobWithTasks, bool)

GetJobWithFullHistory returns a job with the tasks substituted for their IDs. Query designed with the help of https://stackoverflow.com/questions/47275606

func GetNode

func GetNode(id string) (*models.Node, bool)

GetNode returns the JSON of a node and its keys separately.

func GetNodeIDorName

func GetNodeIDorName(id string, field string) (string, bool)

GetNodeIDorName returns the full ID or name for the given node.

func GetTask

func GetTask(id string) (*models.Task, bool)

GetTask returns a task in the database.

func GetUser

func GetUser(u models.User) (string, error)

GetUser returns a UserID from the database.

func Init

func Init() error

Init initializes the database connection.

func SaveTask

func SaveTask(t *TaskInfo) error

SaveTask saves a live task to the database.

func UpdateJob

func UpdateJob(j *models.Job) error

UpdateJob updates a Job in the database.

func UpdateUser

func UpdateUser(u models.User, uOld models.User) error

UpdateUser updates a User in the database.

Types

type Query

type Query struct {
	Limit  int    `form:"limit" validate:"min=1,max=50"`
	Offset int    `form:"offset"`
	Sort   string `form:"sort" validate:"oneof=asc desc"`
	SortBy string `form:"sortby"`
	Expand bool   `form:"expand"`
}

Query parses a URL query and gets the items from the database based on it.

func (*Query) Query

func (q *Query) Query(table string, model interface{}) error

Query runs a query against the database.

func (*Query) Setup

func (q *Query) Setup(r *http.Request) error

Setup parses a url query.

type TaskInfo

type TaskInfo struct {
	Log      []string         `json:"log,omitempty"`
	ExitCode int              `json:"exit_code"`
	State    models.TaskState `json:"state"`
	ID       string           `json:"id"`
}

TaskInfo contains new information about a running task.

Jump to

Keyboard shortcuts

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