exec

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DestroyKey = "suid"
)
View Source
const ProcessKey = "process"

grep ${key}

Variables

This section is empty.

Functions

func GetPidsByProcessCmdName

func GetPidsByProcessCmdName(processName string, ctx context.Context) ([]string, error)

GetPidsByProcessCmdName

func GetPidsByProcessName

func GetPidsByProcessName(processName string, ctx context.Context) ([]string, error)

GetPidsByProcessName

func GetPsArgs

func GetPsArgs(ctx context.Context) string

GetPsArgs

func IsDestroy

func IsDestroy(ctx context.Context) (string, bool)

IsDestroy command

func MarshalModelSpec

func MarshalModelSpec(models *Models, writer io.Writer)

func SetDestroyFlag

func SetDestroyFlag(ctx context.Context, suid string) context.Context

Types

type ActionModel

type ActionModel struct {
	ActionName      string    `yaml:"action"`
	ActionAliases   []string  `yaml:"aliases,flow,omitempty"`
	ActionShortDesc string    `yaml:"shortDesc"`
	ActionLongDesc  string    `yaml:"longDesc"`
	ActionMatchers  []ExpFlag `yaml:"matchers,omitempty"`
	ActionFlags     []ExpFlag `yaml:"flags,omitempty"`
	// contains filtered or unexported fields
}

func (*ActionModel) Aliases

func (am *ActionModel) Aliases() []string

func (*ActionModel) Executor

func (am *ActionModel) Executor(Channel) Executor

func (*ActionModel) Flags

func (am *ActionModel) Flags() []ExpFlagSpec

func (*ActionModel) LongDesc

func (am *ActionModel) LongDesc() string

func (*ActionModel) Matchers

func (am *ActionModel) Matchers() []ExpFlagSpec

func (*ActionModel) Name

func (am *ActionModel) Name() string

func (*ActionModel) ShortDesc

func (am *ActionModel) ShortDesc() string

type Channel

type Channel interface {
	// Run command
	Run(ctx context.Context, script, args string) *transport.Response

	// GetScriptPath
	GetScriptPath() string
}

type Executor

type Executor interface {
	// FlagName is used to identify the executor
	Name() string

	// Exec is used to execute the experiment
	Exec(uid string, ctx context.Context, model *ExpModel) *transport.Response

	SetChannel(channel Channel)
}

Executor defines the executor interface

type ExpActionCommandSpec

type ExpActionCommandSpec interface {
	// FlagName returns the action FlagName
	Name() string

	// Aliases returns command alias names
	Aliases() []string

	// ShortDesc returns short description for the action
	ShortDesc() string

	// LongDesc returns full description for the action
	LongDesc() string

	// Matchers returns the list of matchers supported by the action
	Matchers() []ExpFlagSpec

	// Flags returns the list of flags supported by the action
	Flags() []ExpFlagSpec

	// Executor returns the action command executor
	Executor(channel Channel) Executor
}

ExpActionCommandSpec defines the action command interface for the experimental plugin

type ExpCommandModel

type ExpCommandModel struct {
	ExpName      string        `yaml:"target"`
	ExpShortDesc string        `yaml:"shortDesc"`
	ExpLongDesc  string        `yaml:"longDesc"`
	ExpExample   string        `yaml:"example"`
	ExpActions   []ActionModel `yaml:"actions"`

	ExpScope        string          `yaml:"scope"`
	ExpPrepareModel ExpPrepareModel `yaml:"prepare,omitempty"`
	ExpSubTargets   []string        `yaml:"subTargets,flow,omitempty"`
	// contains filtered or unexported fields
}

func (*ExpCommandModel) Actions

func (ecm *ExpCommandModel) Actions() []ExpActionCommandSpec

func (*ExpCommandModel) Example

func (ecm *ExpCommandModel) Example() string

func (*ExpCommandModel) Flags

func (ecm *ExpCommandModel) Flags() []ExpFlagSpec

func (*ExpCommandModel) LongDesc

func (ecm *ExpCommandModel) LongDesc() string

func (*ExpCommandModel) Name

func (ecm *ExpCommandModel) Name() string

func (*ExpCommandModel) PreExecutor

func (ecm *ExpCommandModel) PreExecutor() PreExecutor

func (*ExpCommandModel) ShortDesc

func (ecm *ExpCommandModel) ShortDesc() string

type ExpFlag

type ExpFlag struct {
	// Name returns the flag FlagName
	Name string `yaml:"name"`

	// Desc returns the flag description
	Desc string `yaml:"desc"`

	// NoArgs means no arguments
	NoArgs bool `yaml:"noArgs"`

	// Required means necessary or not
	Required bool `yaml:"required"`
}

ExpFlag defines the action flag

func (*ExpFlag) FlagDesc

func (f *ExpFlag) FlagDesc() string

func (*ExpFlag) FlagName

func (f *ExpFlag) FlagName() string

func (*ExpFlag) FlagNoArgs

func (f *ExpFlag) FlagNoArgs() bool

func (*ExpFlag) FlagRequired

func (f *ExpFlag) FlagRequired() bool

type ExpFlagSpec

type ExpFlagSpec interface {
	FlagName() string
	FlagDesc() string
	FlagNoArgs() bool
	FlagRequired() bool
}

type ExpModel

type ExpModel struct {
	// Target is experiment target
	Target string

	// ActionName is the experiment action FlagName, for example delay
	ActionName string

	// ActionFlags is the experiment action flags, for example time and offset
	ActionFlags map[string]string
}

ExpModel is the experiment data object

func (*ExpModel) GetFlags

func (exp *ExpModel) GetFlags() string

type ExpModelCommandSpec

type ExpModelCommandSpec interface {
	// FlagName returns the command FlagName
	Name() string

	// ShortDesc returns short description for the command
	ShortDesc() string

	// LongDesc returns full description for the command
	LongDesc() string

	// Example returns use case for the command
	Example() string

	// Actions returns the list of actions supported by the command
	Actions() []ExpActionCommandSpec

	// Flags returns the command flags
	Flags() []ExpFlagSpec

	PreExecutor() PreExecutor
}

ExpModelCommandSpec defines the command interface for the experimental plugin

type ExpPrepareModel

type ExpPrepareModel struct {
	PrepareType     string    `yaml:"type"`
	PrepareFlags    []ExpFlag `yaml:"flags"`
	PrepareRequired bool      `yaml:"required"`
}

type LocalChannel

type LocalChannel struct {
}

func NewLocalChannel

func NewLocalChannel() *LocalChannel

func (*LocalChannel) GetScriptPath

func (client *LocalChannel) GetScriptPath() string

func (*LocalChannel) Run

func (client *LocalChannel) Run(ctx context.Context, script, args string) *transport.Response

type Models

type Models struct {
	Version string            `yaml:"version"`
	Kind    string            `yaml:"kind"`
	Models  []ExpCommandModel `yaml:"items"`
}

func ParseSpecsToModel

func ParseSpecsToModel(file string, executor Executor) (*Models, error)

type PreExecutor

type PreExecutor interface {
	PreExec(cmdName, parentCmdName string, flags map[string]string) func(ctx context.Context) (Channel, context.Context, error)
}

Directories

Path Synopsis
os
bin

Jump to

Keyboard shortcuts

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