run

package
v0.0.0-...-5f60744 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Name  = "run"
	Usage = "Run one or more containers"
	Alias = "r"
)
View Source
const (
	FlagLiveLogs    = "live-logs"
	FlagTerminal    = "terminal"
	FlagPublishPort = "publish"
	FlagRemove      = "rm"
	FlagDetach      = "detach"
)

Run command flag names

View Source
const (
	FlagLiveLogsUsage    = "Show live logs for the container (cant use with --terminal)"
	FlagTerminalUsage    = "Attach interactive terminal to the container"
	FlagPublishPortUsage = "" /* 130-byte string literal not displayed */
	FlagRemoveUsage      = "Remove the container when it exits"
	FlagDetachUsage      = "Start the container and do not wait for it to exit"
)

Run command flag usage info

Variables

View Source
var CLI = &cli.Command{
	Name:    Name,
	Aliases: []string{Alias},
	Usage:   Usage,
	Flags: []cli.Flag{
		commands.Cflag(commands.FlagTarget),
		commands.Cflag(commands.FlagPull),
		commands.Cflag(commands.FlagDockerConfigPath),
		commands.Cflag(commands.FlagRegistryAccount),
		commands.Cflag(commands.FlagRegistrySecret),
		commands.Cflag(commands.FlagShowPullLogs),
		commands.Cflag(commands.FlagEntrypoint),
		commands.Cflag(commands.FlagCmd),
		cflag(FlagLiveLogs),
		cflag(FlagTerminal),
		cflag(FlagPublishPort),
		commands.Cflag(commands.FlagEnv),
		commands.Cflag(commands.FlagVolume),
		cflag(FlagRemove),
		cflag(FlagDetach),
	},
	Action: func(ctx *cli.Context) error {
		xc := app.NewExecutionContext(Name, ctx.String(commands.FlagConsoleFormat))

		gparams, err := commands.GlobalFlagValues(ctx)
		if err != nil {
			return err
		}

		cparams, err := CommandFlagValues(ctx)
		if err != nil {
			return err
		}

		if cparams.TargetRef == "" {
			if ctx.Args().Len() < 1 {
				xc.Out.Error("param.target", "missing target")
				cli.ShowCommandHelp(ctx, Name)
				return nil
			} else {
				cparams.TargetRef = ctx.Args().First()
			}
		}

		OnCommand(
			xc,
			gparams,
			cparams)

		return nil
	},
}
View Source
var CommandSuggestion = prompt.Suggest{
	Text:        Name,
	Description: Usage,
}
View Source
var Flags = map[string]cli.Flag{
	FlagLiveLogs: &cli.BoolFlag{
		Name:    FlagLiveLogs,
		Usage:   FlagLiveLogsUsage,
		EnvVars: []string{"DSLIM_RUN_LIVE_LOGS"},
	},
	FlagTerminal: &cli.BoolFlag{
		Name:    FlagTerminal,
		Usage:   FlagTerminalUsage,
		EnvVars: []string{"DSLIM_RUN_TERMINAL"},
	},
	FlagPublishPort: &cli.StringSliceFlag{
		Name:    FlagPublishPort,
		Value:   &cli.StringSlice{},
		Usage:   FlagPublishPortUsage,
		EnvVars: []string{"DSLIM_RUN_PUBLISH_PORT"},
	},
	FlagRemove: &cli.BoolFlag{
		Name:    FlagRemove,
		Usage:   FlagRemoveUsage,
		EnvVars: []string{"DSLIM_RUN_RM"},
	},
	FlagDetach: &cli.BoolFlag{
		Name:    FlagDetach,
		Usage:   FlagDetachUsage,
		EnvVars: []string{"DSLIM_RUN_DETACH"},
	},
}

Functions

func OnCommand

func OnCommand(
	xc *app.ExecutionContext,
	gparams *commands.GenericParams,
	cparams *CommandParams)

OnCommand implements the 'run' command

func RegisterCommand

func RegisterCommand()

Types

type CommandParams

type CommandParams struct {
	TargetRef        string
	DoPull           bool
	DockerConfigPath string
	RegistryAccount  string
	RegistrySecret   string
	DoShowPullLogs   bool
	Entrypoint       []string
	Cmd              []string
	DoLiveLogs       bool
	DoTerminal       bool
	PublishPorts     map[dockerapi.Port][]dockerapi.PortBinding
	EnvVars          []string
	Volumes          []config.VolumeMount
	DoRemoveOnExit   bool
	DoDetach         bool
}

func CommandFlagValues

func CommandFlagValues(ctx *cli.Context) (*CommandParams, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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