exec

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2023 License: Apache-2.0 Imports: 23 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 CategorySystemContainer = "system_container"
View Source
const DstChaosBladeDir = "/opt"
View Source
const (
	ForceFlag = "force"
)

Variables

View Source
var ChaosBladeOverrideFlag = &spec.ExpFlag{
	Name:   "chaosblade-override",
	Desc:   "Override the exists chaosblade tool in the target container or not, default value is false",
	NoArgs: true,
}
View Source
var ChaosBladeReleaseFlag = &spec.ExpFlag{
	Name: "chaosblade-release",
	Desc: "The pull path of the chaosblade tar package, for example, --chaosblade-release /opt/chaosblade-0.4.0.tar.gz",
}
View Source
var ContainerIdFlag = &spec.ExpFlag{
	Name:                  "container-id",
	Desc:                  "Container id, when used with container-name, container-id is preferred",
	NoArgs:                false,
	Required:              false,
	RequiredWhenDestroyed: false,
}
View Source
var ContainerNameFlag = &spec.ExpFlag{
	Name:                  "container-name",
	Desc:                  "Container name, when used with container-id, container-id is preferred",
	NoArgs:                false,
	Required:              false,
	RequiredWhenDestroyed: 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,
}
View Source
var JvmSpecFileForYaml = ""

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 GetContainer

func GetContainer(client *Client, uid string, containerId, containerName string) (types.Container, *spec.Response)

GetContainer return container by container flag, such as container id or container name.

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