script

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: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTimeoutSec = 60

Variables

This section is empty.

Functions

func Validate

func Validate(iv *InputScript) error

Types

type DbProvider

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

type InputScript

type InputScript struct {
	Name        string   `json:"name" db:"name"`
	Interpreter string   `json:"interpreter" db:"interpreter"`
	IsSudo      bool     `json:"is_sudo" db:"is_sudo"`
	Cwd         string   `json:"cwd" db:"cwd"`
	Script      string   `json:"script" 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, logger *logger.Logger) *Manager

func (*Manager) Close

func (m *Manager) Close() error

func (*Manager) Create

func (m *Manager) Create(ctx context.Context, valueToStore *InputScript, username string) (*Script, 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) (*Script, bool, error)

func (*Manager) List

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

func (*Manager) Update

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

type Script

type Script 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"`
	Interpreter *string            `json:"interpreter,omitempty" db:"interpreter"`
	IsSudo      *bool              `json:"is_sudo,omitempty" db:"is_sudo"`
	Cwd         *string            `json:"cwd,omitempty" db:"cwd"`
	Script      string             `json:"script,omitempty" db:"script"`
	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 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 *Script, found bool, err error)

func (*SqliteProvider) List

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

func (*SqliteProvider) Save

func (p *SqliteProvider) Save(ctx context.Context, s *Script, nowDate time.Time) (string, error)

Jump to

Keyboard shortcuts

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