command

package
v0.0.0-...-7578c0e Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTimeoutSec = 60

Variables

This section is empty.

Functions

func Validate

func Validate(iv *InputCommand) error

Types

type Command

type Command struct {
	ID        string             `json:"id,omitempty" db:"id"`
	Name      string             `json:"name,omitempty" db:"name"`
	CreatedBy string             `json:"created_by,omitempty" db:"created_by"`
	CreatedAt *time.Time         `json:"created_at,omitempty" db:"created_at"`
	UpdatedBy string             `json:"updated_by,omitempty" db:"updated_by"`
	UpdatedAt *time.Time         `json:"updated_at,omitempty" db:"updated_at"`
	Cmd       string             `json:"cmd,omitempty" db:"cmd"`
	Tags      *types.StringSlice `json:"tags,omitempty" db:"tags"`
	TimoutSec *int               `json:"timeout_sec,omitempty" db:"timeout_sec"`
}

To support sparse fieldsets, the fields that can have zero value, use pointers so they're omitted only when they're nil not when they're zero value

type DbProvider

type DbProvider interface {
	GetByID(ctx context.Context, id string, ro *query.RetrieveOptions) (val *Command, found bool, err error)
	List(ctx context.Context, lo *query.ListOptions) ([]Command, error)
	Save(ctx context.Context, s *Command) (string, error)
	Delete(ctx context.Context, id string) error
	io.Closer
}

type InputCommand

type InputCommand struct {
	Name      string   `json:"name" db:"name"`
	Cmd       string   `json:"cmd" db:"script"`
	Tags      []string `json:"tags" db:"tags"`
	TimoutSec int      `json:"timeout_sec" db:"timeout_sec"`
}

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(db DbProvider) *Manager

func (*Manager) Close

func (m *Manager) Close() error

func (*Manager) Create

func (m *Manager) Create(ctx context.Context, valueToStore *InputCommand, username string) (*Command, error)

func (*Manager) Delete

func (m *Manager) Delete(ctx context.Context, id string) error

func (*Manager) GetOne

func (m *Manager) GetOne(ctx context.Context, re *http.Request, id string) (*Command, bool, error)

func (*Manager) List

func (m *Manager) List(ctx context.Context, re *http.Request) ([]Command, int, error)

func (*Manager) Update

func (m *Manager) Update(ctx context.Context, existingID string, valueToStore *InputCommand, username string) (*Command, error)

type SqliteProvider

type SqliteProvider struct {
	// contains filtered or unexported fields
}

func NewSqliteProvider

func NewSqliteProvider(db *sqlx.DB) *SqliteProvider

func (*SqliteProvider) Close

func (p *SqliteProvider) Close() error

func (*SqliteProvider) Delete

func (p *SqliteProvider) Delete(ctx context.Context, id string) error

func (*SqliteProvider) GetByID

func (p *SqliteProvider) GetByID(ctx context.Context, id string, ro *query.RetrieveOptions) (val *Command, found bool, err error)

func (*SqliteProvider) List

func (p *SqliteProvider) List(ctx context.Context, lo *query.ListOptions) ([]Command, error)

func (*SqliteProvider) Save

func (p *SqliteProvider) Save(ctx context.Context, s *Command) (string, error)

Jump to

Keyboard shortcuts

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