package hooks

import "github.com/docker/cli/cli-plugins/hooks"

Index

Constants

const (
	NextSteps = iota
)

Variables

var ErrHookTemplateParse = errors.New("failed to parse hook template")

Functions

func ParseTemplate

func ParseTemplate(hookTemplate string, cmd *cobra.Command) ([]string, error)

func PrintNextSteps

func PrintNextSteps(out io.Writer, messages []string)

func TemplateReplaceArg

func TemplateReplaceArg(i int) string

TemplateReplaceArg takes an index i and returns a hook template string that the CLI will replace the template with the ith argument, after processing the passed flags.

Example:

"run this image with `docker run " + TemplateReplaceArg(0) + "`"

when being executed after the command: `docker pull alpine` will result in the message: "Run this image with `docker run alpine`"

func TemplateReplaceFlagValue

func TemplateReplaceFlagValue(flag string) string

TemplateReplaceFlagValue returns a hook template string that will be replaced by the flags value.

Example:

"you ran a container named: " + TemplateReplaceFlagValue("name")

when being executed after the command: `docker run --name "my-container" alpine` will result in the message: `you ran a container named: my-container`

func TemplateReplaceSubcommandName

func TemplateReplaceSubcommandName() string

TemplateReplaceSubcommandName returns a hook template string that will be replaced by the CLI subcommand being executed

Example:

"you ran the subcommand: " + TemplateReplaceSubcommandName()

when being executed after the command: `docker run --name "my-container" alpine` will result in the message: `you ran the subcommand: run`

Types

type HookMessage

type HookMessage struct {
	Type     HookType
	Template string
}

HookMessage represents a plugin hook response. Plugins declaring support for CLI hooks need to print a json representation of this type when their hook subcommand is invoked.

type HookType

type HookType int

Source Files

printer.go template.go

Version
v28.1.1+incompatible (latest)
Published
Apr 18, 2025
Platform
linux/amd64
Imports
9 packages
Last checked
4 hours ago

Tools for package owners.