runner

package
v3.6.1-rc.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OpininatedEnvVarNamingRegexp = regexp.MustCompile(`^[A-Z_][A-Z0-9_]{1}[A-Z0-9_]*[A-Z][A-Z0-9_]*$`)

Only allow uppercase letters, digits and underscores, min three chars

Functions

func ConvertRunnerProject

func ConvertRunnerProject(runnerProj *runnerv1.Project) (*project.Project, error)

func IsShell

func IsShell(lang string) bool

func IsShellLanguage

func IsShellLanguage(languageID string) bool

func IsSupported

func IsSupported(lang string) bool

func NewRunnerService

func NewRunnerService(logger *zap.Logger) (runnerv1.RunnerServiceServer, error)

func PrepareScriptFromCommands

func PrepareScriptFromCommands(cmds []string, shell string) string

func ShellFromShellPath

func ShellFromShellPath(programPath string) string

TODO(mxs): this method for determining shell is not strong, since shells can be aliased. we should probably run the shell to get this information

Types

type CommandMode

type CommandMode uint
const (
	// Do not send script to program
	CommandModeNone CommandMode = iota
	// Send script as argument to "-c"
	CommandModeInlineShell
	// Send script as temporary file in cwd
	CommandModeTempFile
)

func GetCellProgram

func GetCellProgram(languageID string, customShell string, cell *document.CodeBlock) (program string, commandMode CommandMode)

type ErrInvalidLanguage

type ErrInvalidLanguage struct {
	LanguageID string
}

func (ErrInvalidLanguage) Error

func (e ErrInvalidLanguage) Error() string

type ErrInvalidProgram

type ErrInvalidProgram struct {
	Program string
	// contains filtered or unexported fields
}

func (ErrInvalidProgram) Error

func (e ErrInvalidProgram) Error() string

func (ErrInvalidProgram) Unwrap

func (e ErrInvalidProgram) Unwrap() error

type Executable

type Executable interface {
	DryRun(context.Context, io.Writer)
	Run(context.Context) error
	ExitCode() int
}

type ExecutableConfig

type ExecutableConfig struct {
	Name    string
	Dir     string
	Tty     bool
	Stdin   io.Reader
	Stdout  io.Writer
	Stderr  io.Writer
	PreEnv  []string
	PostEnv []string
	Session *Session
	Logger  *zap.Logger
}

type ExitError

type ExitError struct {
	Code    uint
	Wrapped error
}

func ExitErrorFromExec

func ExitErrorFromExec(e *exec.ExitError) *ExitError

func (ExitError) Error

func (e ExitError) Error() string

func (ExitError) Unwrap

func (e ExitError) Unwrap() error

type Go

type Go struct {
	*ExecutableConfig
	Source string
	// contains filtered or unexported fields
}

func (Go) DryRun

func (g Go) DryRun(ctx context.Context, w io.Writer)

func (Go) ExitCode

func (g Go) ExitCode() int

func (*Go) Run

func (g *Go) Run(ctx context.Context) error

type Session

type Session struct {
	ID       string
	Metadata map[string]string
	// contains filtered or unexported fields
}

Session is an abstract entity separate from an execution. Currently, its main role is to keep track of environment variables.

func NewSession

func NewSession(envs []string, proj *project.Project, logger *zap.Logger) (*Session, error)

func NewSessionWithStore added in v3.2.0

func NewSessionWithStore(envs []string, proj *project.Project, owlStore bool, logger *zap.Logger) (*Session, error)

func (*Session) AddEnvs

func (s *Session) AddEnvs(context context.Context, envs []string) error

func (*Session) Complete added in v3.2.0

func (s *Session) Complete()

func (*Session) Envs

func (s *Session) Envs() ([]string, error)

func (*Session) SensitiveEnvKeys added in v3.2.2

func (s *Session) SensitiveEnvKeys() ([]string, error)

func (*Session) SetEnv added in v3.2.0

func (s *Session) SetEnv(context context.Context, k string, v string) error

func (*Session) Subscribe added in v3.2.0

func (s *Session) Subscribe(ctx context.Context, snapshotc chan<- owl.SetVarItems) error

func (*Session) UpdateStore added in v3.2.0

func (s *Session) UpdateStore(context context.Context, envs []string, newOrUpdated []string, deleted []string) error

type SessionList

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

thread-safe session list

func NewSessionList

func NewSessionList() (*SessionList, error)

func (*SessionList) AddSession

func (sl *SessionList) AddSession(session *Session)

func (*SessionList) CreateAndAddSession

func (sl *SessionList) CreateAndAddSession(generate func() (*Session, error)) (*Session, error)

func (*SessionList) DeleteSession

func (sl *SessionList) DeleteSession(id string) (present bool)

func (*SessionList) GetSession

func (sl *SessionList) GetSession(id string) (*Session, bool)

func (*SessionList) ListSessions

func (sl *SessionList) ListSessions() ([]*Session, error)

func (*SessionList) MostRecent

func (sl *SessionList) MostRecent() (*Session, bool)

func (*SessionList) MostRecentOrCreate

func (sl *SessionList) MostRecentOrCreate(generate func() (*Session, error)) (*Session, error)

type Shell

type Shell struct {
	*ExecutableConfig

	Cmds        []string
	CustomShell string
	// contains filtered or unexported fields
}

func (Shell) DryRun

func (s Shell) DryRun(ctx context.Context, w io.Writer)

func (Shell) ExitCode

func (s Shell) ExitCode() int

func (Shell) ProgramPath

func (s Shell) ProgramPath() string

func (*Shell) Run

func (s *Shell) Run(ctx context.Context) error

func (Shell) ShellType

func (s Shell) ShellType() string

type ShellRaw

type ShellRaw struct {
	*Shell
}

func (ShellRaw) DryRun

func (s ShellRaw) DryRun(ctx context.Context, w io.Writer)

func (ShellRaw) Run

func (s ShellRaw) Run(ctx context.Context) error

type ShellSession

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

func NewShellSession

func NewShellSession(command string) (*ShellSession, error)

func (*ShellSession) Close

func (s *ShellSession) Close() error

func (*ShellSession) Done

func (s *ShellSession) Done() <-chan struct{}

func (*ShellSession) Err

func (s *ShellSession) Err() error

func (*ShellSession) ID

func (s *ShellSession) ID() string

func (*ShellSession) Send

func (s *ShellSession) Send(data []byte) error

type TempFile

type TempFile struct {
	*ExecutableConfig

	Script      string
	ProgramName string
	LanguageID  string
	// contains filtered or unexported fields
}

func (TempFile) DryRun

func (s TempFile) DryRun(ctx context.Context, w io.Writer)

func (TempFile) ExitCode

func (s TempFile) ExitCode() int

func (*TempFile) Run

func (s *TempFile) Run(ctx context.Context) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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