exec

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChaosBladeImageVersion = "latest"
	DefaultImageRepo       = "registry.cn-hangzhou.aliyuncs.com/chaosblade/chaosblade-tool"
)
View Source
const BladeBin = "/opt/chaosblade/blade"

BladeBin is the blade path in the chaosblade-tool image

View Source
const DstChaosBladeDir = "/opt"
View Source
const (
	ForceFlag = "force"
)

Variables

View Source
var ChaosBladeTarFilePathFlag = &spec.ExpFlag{
	Name:     "blade-tar-file",
	Desc:     "The pull path of the ChaosBlade tar package, for example, --blade-tar-file /opt/chaosblade-0.4.0.tar.gz",
	NoArgs:   false,
	Required: false,
}
View Source
var ContainerIdFlag = &spec.ExpFlag{
	Name:                  "container-id",
	Desc:                  "Container id",
	NoArgs:                false,
	Required:              false,
	RequiredWhenDestroyed: true,
}
View Source
var DeployBladeOverrideFlag = &spec.ExpFlag{
	Name:     "blade-override",
	Desc:     "Override the exists chaosblade tool in the target container or not, default value is false",
	NoArgs:   true,
	Required: false,
}
View Source
var EndpointFlag = &spec.ExpFlag{
	Name:     "docker-endpoint",
	Desc:     "Docker socket endpoint",
	NoArgs:   false,
	Required: false,
}
View Source
var ImageRepoFlag = &spec.ExpFlag{
	Name:     "image-repo",
	Desc:     "Image repository of the chaosblade-tool",
	NoArgs:   false,
	Required: false,
}
View Source
var ImageVersionFlag = &spec.ExpFlag{
	Name:     "image-version",
	Desc:     "Image version of the chaosblade-tool",
	NoArgs:   false,
	Required: false,
}

Functions

func ConvertContainerOutputToResponse

func ConvertContainerOutputToResponse(output string, err error, defaultResponse *spec.Response) *spec.Response

func GetAllDockerFlagNames

func GetAllDockerFlagNames() map[string]spec.Empty

func GetAllExecutors

func GetAllExecutors() map[string]spec.Executor

func GetContainerSelfFlags

func GetContainerSelfFlags() []spec.ExpFlagSpec

func GetExecInContainerFlags

func GetExecInContainerFlags() []spec.ExpFlagSpec

func GetExecSidecarFlags

func GetExecSidecarFlags() []spec.ExpFlagSpec

func GetExecutorKey

func GetExecutorKey(target, action string) string

func NewContainerCommandSpec

func NewContainerCommandSpec() spec.ExpModelCommandSpec

func NewDockerExpModelSpec

func NewDockerExpModelSpec() *dockerExpModelSpec

func NewRemoveActionCommand

func NewRemoveActionCommand() spec.ExpActionCommandSpec

Types

type BaseDockerClientExecutor

type BaseDockerClientExecutor struct {
	Client      *Client
	CommandFunc func(uid string, ctx context.Context, model *spec.ExpModel) string
}

BaseDockerClientExecutor

func (*BaseDockerClientExecutor) SetClient

func (b *BaseDockerClientExecutor) SetClient(expModel *spec.ExpModel) error

SetClient to the executor

type Client

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

func GetClient

func GetClient(endpoint string) (*Client, error)

GetClient returns the docker client

func (*Client) CopyToContainer

func (c *Client) CopyToContainer(ctx context.Context, containerId, srcFile, dstPath string, override bool) error

CopyToContainer copies a tar file to the dstPath. If the same file exits in the dstPath, it will be override if the override arg is true, otherwise not

type ContainerCommandModelSpec

type ContainerCommandModelSpec struct {
	spec.BaseExpModelCommandSpec
}

func (*ContainerCommandModelSpec) LongDesc

func (cms *ContainerCommandModelSpec) LongDesc() string

func (*ContainerCommandModelSpec) Name

func (cms *ContainerCommandModelSpec) Name() string

func (*ContainerCommandModelSpec) ShortDesc

func (cms *ContainerCommandModelSpec) ShortDesc() string

type ResourceExpModelSpec

type ResourceExpModelSpec interface {
	// Scope
	Scope() string
	// ExpModels returns the map of the experiment name and the model
	ExpModels() map[string]spec.ExpModelCommandSpec
	// GetExpActionModelSpec returns the action spec
	GetExpActionModelSpec(target, action string) spec.ExpActionCommandSpec
}

type RunCmdInContainerExecutor

type RunCmdInContainerExecutor interface {
	spec.Executor
	DeployChaosBlade(ctx context.Context, containerId string, srcFile, extractDirName string, override bool) error
}

RunCmdInContainerExecutor is an executor interface which executes command in the target container directly

func NewRunCmdInContainerExecutorByCP

func NewRunCmdInContainerExecutorByCP() RunCmdInContainerExecutor

type RunCmdInContainerExecutorByCP

type RunCmdInContainerExecutorByCP struct {
	BaseDockerClientExecutor
}

RunCmdInContainerExecutorByCP is an executor implementation which used copy chaosblade tool to the target container and executed

func (*RunCmdInContainerExecutorByCP) DeployChaosBlade

func (r *RunCmdInContainerExecutorByCP) DeployChaosBlade(ctx context.Context, containerId string,
	srcFile, extractDirName string, override bool) error

func (*RunCmdInContainerExecutorByCP) Exec

func (*RunCmdInContainerExecutorByCP) Name

func (*RunCmdInContainerExecutorByCP) SetChannel

func (r *RunCmdInContainerExecutorByCP) SetChannel(channel spec.Channel)

type RunInSidecarContainerExecutor

type RunInSidecarContainerExecutor struct {
	BaseDockerClientExecutor
	// contains filtered or unexported fields
}

func NewNetWorkSidecarExecutor

func NewNetWorkSidecarExecutor() *RunInSidecarContainerExecutor

func (*RunInSidecarContainerExecutor) Exec

func (*RunInSidecarContainerExecutor) Name

func (*RunInSidecarContainerExecutor) SetChannel

func (*RunInSidecarContainerExecutor) SetChannel(channel spec.Channel)

Jump to

Keyboard shortcuts

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