exec

package
v0.0.0-...-1d6cbaf Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2024 License: Apache-2.0 Imports: 32 Imported by: 2 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

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 CommonFunc = func(uid string, ctx context.Context, model *spec.ExpModel) string {
	matchers := spec.ConvertExpMatchersToString(model, func() map[string]spec.Empty {
		return GetAllDockerFlagNames()
	})
	if _, ok := spec.IsDestroy(ctx); ok {

		return fmt.Sprintf("%s destroy %s %s %s", BladeBin, model.Target, model.ActionName, matchers)
	}
	return fmt.Sprintf("%s create %s %s %s --uid %s", BladeBin, model.Target, model.ActionName, matchers, uid)
}

commonFunc is the command created function

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 ContainerLabelSelectorFlag = &spec.ExpFlag{
	Name:                  "container-label-selector",
	Desc:                  "Container label selector, when used with container-id or container-name, container-id or container-name 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 ContainerNamespace = &spec.ExpFlag{
	Name:     "container-namespace",
	Desc:     "container namespace, If container-runtime is containerd it will be used, default value is k8s.io",
	NoArgs:   false,
	Required: false,
}
View Source
var ContainerRuntime = &spec.ExpFlag{
	Name:     "container-runtime",
	Desc:     "container runtime, support cri and containerd, default value is docker",
	NoArgs:   false,
	Required: false,
}
View Source
var EndpointFlag = &spec.ExpFlag{
	Name:     "cri-endpoint",
	Desc:     "Cri container 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 GetClientByRuntime

func GetClientByRuntime(expModel *spec.ExpModel) (container.Container, error)

func GetContainer

func GetContainer(ctx context.Context, client container.Container, uid string, containerId, containerName string, containerLabelSelector map[string]string) (container.ContainerInfo, *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 GetNSExecFlags

func GetNSExecFlags() []spec.ExpFlagSpec

func NewContainerCommandSpec

func NewContainerCommandSpec() spec.ExpModelCommandSpec

func NewRemoveActionCommand

func NewRemoveActionCommand() spec.ExpActionCommandSpec

Types

type BaseClientExecutor

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

BaseClientExecutor

func (*BaseClientExecutor) SetClient

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

SetClient to the executor

type Client

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

type CommonExecutor

type CommonExecutor struct {
	BaseClientExecutor
}

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

func NewCommonExecutor

func NewCommonExecutor() *CommonExecutor

func (*CommonExecutor) DeployChaosBlade

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

func (*CommonExecutor) Exec

func (r *CommonExecutor) Exec(uid string, ctx context.Context, expModel *spec.ExpModel) *spec.Response

func (*CommonExecutor) Name

func (r *CommonExecutor) Name() string

func (*CommonExecutor) SetChannel

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

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 DockerExpModelSpec

type DockerExpModelSpec struct {
	ScopeName     string
	ExpModelSpecs map[string]spec.ExpModelCommandSpec
}

func NewCriExpModelSpec

func NewCriExpModelSpec() *DockerExpModelSpec

func NewDockerExpModelSpec

func NewDockerExpModelSpec() *DockerExpModelSpec

func (*DockerExpModelSpec) ExpModels

func (*DockerExpModelSpec) GetExpActionModelSpec

func (b *DockerExpModelSpec) GetExpActionModelSpec(target, actionName string) spec.ExpActionCommandSpec

func (*DockerExpModelSpec) Scope

func (b *DockerExpModelSpec) Scope() string

type NetworkExecutor

type NetworkExecutor struct {
	BaseClientExecutor
}

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

func NewNetworkExecutor

func NewNetworkExecutor() *NetworkExecutor

func (*NetworkExecutor) DeployChaosBlade

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

func (*NetworkExecutor) Exec

func (r *NetworkExecutor) Exec(uid string, ctx context.Context, expModel *spec.ExpModel) *spec.Response

func (*NetworkExecutor) Name

func (r *NetworkExecutor) Name() string

func (*NetworkExecutor) SetChannel

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

type RemoveActionCommand

type RemoveActionCommand struct {
	spec.BaseExpActionCommandSpec
}

func (*RemoveActionCommand) Aliases

func (*RemoveActionCommand) Aliases() []string

func (*RemoveActionCommand) LongDesc

func (r *RemoveActionCommand) LongDesc() string

func (*RemoveActionCommand) Name

func (*RemoveActionCommand) Name() string

func (*RemoveActionCommand) ShortDesc

func (*RemoveActionCommand) 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 {
	BaseClientExecutor
}

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 {
	BaseClientExecutor
	// 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)

Directories

Path Synopsis
* Copyright 1999-2020 Alibaba Group Holding Ltd.
* Copyright 1999-2020 Alibaba Group Holding Ltd.
containerd
* Copyright 1999-2020 Alibaba Group Holding Ltd.
* Copyright 1999-2020 Alibaba Group Holding Ltd.
cri-o
* Copyright 1999-2020 Alibaba Group Holding Ltd.
* Copyright 1999-2020 Alibaba Group Holding Ltd.
docker
* Copyright 1999-2020 Alibaba Group Holding Ltd.
* Copyright 1999-2020 Alibaba Group Holding Ltd.

Jump to

Keyboard shortcuts

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