Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DockerRuntime *environments.Runtime
View Source
var ExtraCommands = []environments.Command{ { Text: "x-batch", Description: "Batch management of containers and images", Environments: []environments.Environment{environments.Docker}, MatchFn: environments.StartWithMatch, Fn: func(args []string, writer io.Writer) { if len(args) < 2 || (args[1] != "container" && args[1] != "image") { _, _ = writer.Write([]byte("The container or image type should be provided in the parameter\n" + "Try \"x-batch container\" or \"x-batch image\" again\n")) return } resources := map[string]struct { fn func() []prompt.Suggest ops []string }{ "container": { fn: containerSuggestion, ops: []string{"rm", "rm -f", "start", "stop", "restart", "pause", "unpause", "kill"}, }, "image": { fn: imagesSuggestion, ops: []string{"rmi", "rmi -f", "create", "run"}, }, } resource := resources[args[1]] var opts []string col := int(util.GetWindowWidth() - 15) for _, v := range resource.fn() { opts = append(opts, v.Text+" | "+util.SubString(v.Description, 0, col-len(v.Text))) } var qs = []*survey.Question{ { Name: "objective", Prompt: &survey.MultiSelect{ Message: "Which resource you want to operate ?", Options: opts, PageSize: 25, }, Validate: func(val interface{}) error { if ans, ok := val.([]survey.OptionAnswer); !ok || len(ans) == 0 { return errors.New("please select a least one resource") } return nil }, }, { Name: "operation", Prompt: &survey.Select{ Message: "What you want to do with the these resources ?", Options: resource.ops, }, }, { Name: "confirm", Prompt: &survey.Confirm{ Message: "Are you sure you want to continue ?", }, }, } answers := struct { Objective []string Operation string Confirm bool }{} err := survey.Ask(qs, &answers, survey.WithKeepFilter(true)) if err == terminal.InterruptErr { _, _ = writer.Write([]byte("operation interrupted\n")) } else if err != nil { _, _ = writer.Write([]byte(err.Error() + "\n")) } if answers.Confirm { for _, o := range answers.Objective { environments.Executor("docker", answers.Operation+" "+strings.TrimSpace(strings.Split(o, "|")[0])) } } }, }, }
View Source
var MajorCommands = []prompt.Suggest{
{Text: "app", Description: "A tool to build and manage Docker Applications"},
{Text: "attach", Description: "Attach local standard input, output, and error streams to a running container"},
{Text: "build", Description: "Build an image from a Dockerfile"},
{Text: "builder", Description: "Manage builds"},
{Text: "buildx", Description: "Build with BuildKit"},
{Text: "checkpoint", Description: "Manage checkpoints"},
{Text: "cluster", Description: "A tool to build and manage Docker Clusters."},
{Text: "commit", Description: "Create a new image from a container's changes"},
{Text: "compose", Description: "Docker Compose"},
{Text: "config", Description: "Manage Docker configs"},
{Text: "container", Description: "Manage containers"},
{Text: "context", Description: "Manage contexts"},
{Text: "cp", Description: "Copy files/folders between a container and the local filesystem"},
{Text: "create", Description: "Create a new container"},
{Text: "diff", Description: "Inspect changes to files or directories on a container's filesystem"},
{Text: "events", Description: "Get real time events from the server"},
{Text: "exec", Description: "Run a command in a running container"},
{Text: "export", Description: "Export a container's filesystem as a tar archive"},
{Text: "history", Description: "Show the history of an image"},
{Text: "image", Description: "Manage images"},
{Text: "images", Description: "List images"},
{Text: "import", Description: "Import the contents from a tarball to create a filesystem image"},
{Text: "info", Description: "Display system-wide information"},
{Text: "inspect", Description: "Return low-level information on Docker objects"},
{Text: "kill", Description: "Kill one or more running containers"},
{Text: "load", Description: "Load an image from a tar archive or STDIN"},
{Text: "login", Description: "Log in to a Docker registry"},
{Text: "logout", Description: "Log out from a Docker registry"},
{Text: "logs", Description: "Fetch the logs of a container"},
{Text: "manifest", Description: "Manage Docker image manifests and manifest lists"},
{Text: "network", Description: "Manage networks"},
{Text: "node", Description: "Manage Swarm nodes"},
{Text: "pause", Description: "Pause all processes within one or more containers"},
{Text: "plugin", Description: "Manage plugins"},
{Text: "port", Description: "List port mappings or a specific mapping for the container"},
{Text: "ps", Description: "List containers"},
{Text: "pull", Description: "Pull an image or a repository from a registry"},
{Text: "push", Description: "Push an image or a repository to a registry"},
{Text: "rename", Description: "Rename a container"},
{Text: "restart", Description: "Restart one or more containers"},
{Text: "rm", Description: "Remove one or more containers"},
{Text: "rmi", Description: "Remove one or more images"},
{Text: "run", Description: "Run a command in a new container"},
{Text: "save", Description: "Save one or more images to a tar archive (streamed to STDOUT by default)"},
{Text: "search", Description: "Search the Docker Hub for images"},
{Text: "secret", Description: "Manage Docker secrets"},
{Text: "service", Description: "Manage services"},
{Text: "stack", Description: "Manage Docker stacks"},
{Text: "start", Description: "Start one or more stopped containers"},
{Text: "stats", Description: "Display a live stream of container(s) resource usage statistics"},
{Text: "stop", Description: "Stop one or more running containers"},
{Text: "swarm", Description: "Manage Swarm"},
{Text: "system", Description: "Manage Docker"},
{Text: "tag", Description: "Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE"},
{Text: "top", Description: "Display the running processes of a container"},
{Text: "trust", Description: "Manage trust on Docker images"},
{Text: "unpause", Description: "Unpause all processes within one or more containers"},
{Text: "update", Description: "Update configuration of one or more containers"},
{Text: "version", Description: "Show the Docker version information"},
{Text: "volume", Description: "Manage volumes"},
{Text: "wait", Description: "Block until one or more containers stop, then print their exit codes"},
}
Functions ¶
func RegisterEnv ¶
func RegisterEnv() (*environments.Runtime, error)
Types ¶
type DockerHubResult ¶
type DockerHubResult struct { PageCount *int `json:"num_pages,omitempty"` ResultCount *int `json:"num_results,omitempty"` ItemCountPerPage *int `json:"page_size,omitempty"` CurrentPage *int `json:"page,omitempty"` Query *string `json:"query,omitempty"` Items []registry.SearchResult `json:"results,omitempty"` }
DockerHubResult : Wrap DockerHub API call
Click to show internal directories.
Click to hide internal directories.