Documentation ¶
Index ¶
- Constants
- Variables
- func HandleContainerdRuntime(logger *log.Entry, xc *app.ExecutionContext, gparams *command.GenericParams, ...)
- func HandleDockerRuntime(logger *log.Entry, xc *app.ExecutionContext, gparams *command.GenericParams, ...)
- func HandleKubernetesRuntime(logger *log.Entry, xc *app.ExecutionContext, gparams *command.GenericParams, ...)
- func HandlePodmanRuntime(logger *log.Entry, xc *app.ExecutionContext, gparams *command.GenericParams, ...)
- func OnCommand(xc *app.ExecutionContext, gparams *command.GenericParams, ...)
- func RegisterCommand()
- func ShellCommandPrefix(imageName string) []string
- type CommandParams
- type CreateContainerError
- type DebugContainerInfo
- type DebuggableContainer
- type InputKey
- type NVPair
- type RuntimeCommunicator
- type SpecialKey
- type TUI
- type TUIReader
- type Volume
Constants ¶
const ( Name = "debug" Usage = "Debug the target container from a debug (side-car) container" Alias = "dbg" )
const ( CgrCustomDebugImage = "cgr.dev/chainguard/min-toolkit-debug:latest" WolfiBaseImage = "cgr.dev/chainguard/wolfi-base:latest" BusyboxImage = "busybox@sha256:05a79c7279f71f86a2a0d05eb72fcb56ea36139150f0a75cd87e80a4272e4e39" NicolakaNetshootImage = "nicolaka/netshoot" KoolkitsNodeImage = "lightruncom/koolkits:node" KoolkitsPythonImage = "lightruncom/koolkits:python" KoolkitsGolangImage = "mintoolkit/koolkits-golang:latest" KoolkitsJVMImage = "lightruncom/koolkits:jvm" DigitaloceanDoksImage = "digitalocean/doks-debug:latest" ZinclabsUbuntuImage = "public.ecr.aws/zinclabs/debug-ubuntu-base:latest" InfuserImage = "ghcr.io/teaxyz/infuser:latest" )
const ( FlagTarget = "target" FlagTargetUsage = "Target container (name or ID)" FlagNamespace = "namespace" FlagNamespaceUsage = "Namespace to target (k8s or containerd runtime)" FlagPod = "pod" FlagPodUsage = "Pod to target (k8s runtime)" FlagDebugImage = "debug-image" FlagDebugImageUsage = "Debug image to use for the debug sidecar container" FlagEntrypoint = "entrypoint" FlagEntrypointUsage = "Custom ENTRYPOINT to use for the debug sidecar container." FlagCmd = "cmd" FlagCmdUsage = "Custom CMD to use for the debug sidecar container." FlagShellCmd = "shell-cmd" FlagShellCmdUsage = "Custom CMD to use as a shell command for the debug sidecar container (alternatively pass custom CMD params after '--')." FlagWorkdir = "workdir" FlagWorkdirUsage = "Custom WORKDIR to use for the debug sidecar container." //value expected to be "name=value" FlagEnv = "env" FlagEnvUsage = "Environment variable to add to the debug sidecar container (format: name=value)." //value expected to be "name:path" or "name:path:ro" FlagMount = "mount" FlagMountUsage = "Volume to mount in the debug sidecar container (format: name:path or name:path:ro)." FlagMountTargetVolumes = "mount-target-volumes" FlagMountTargetVolumesUsage = "Mount all volumes mounted in the target container" FlagLoadTargetEnvVars = "load-target-env-vars" FlagLoadTargetEnvVarsUsage = "Load all (container spec) environment variables from the target container" FlagTerminal = "terminal" FlagTerminalUsage = "Attach interactive terminal to the debug container" FlagRunAsTargetShell = "run-as-target-shell" FlagRunAsTargetShellUsage = "Attach an interactive terminal to the debug container and run shell as if it's running in the target container environment." FlagListSessions = "list-sessions" FlagListSessionsUsage = "" /* 128-byte string literal not displayed */ FlagShowSessionLogs = "show-session-logs" FlagShowSessionLogsUsage = "" /* 173-byte string literal not displayed */ FlagSession = "session" FlagSessionUsage = "Debug session container name (used for debug sessoin actions)." FlagConnectSession = "connect-session" FlagConnectSessionUsage = "Connect to existing debug session." //TBD FlagConnectLastSession = "connect-last-session" FlagConnectLastSessionUsage = "Connect to last debug session" FlagListNamespaces = "list-namespaces" FlagListNamespacesUsage = "List names for available namespaces (use this flag by itself)." FlagListPods = "list-pods" FlagListPodsUsage = "List names for running pods in the selected namespace (use this flag by itself)." FlagListDebuggableContainers = "list-debuggable-containers" FlagListDebuggableContainersUsage = "List container names for active containers that can be debugged (use this flag by itself)." FlagListDebugImage = "list-debug-images" FlagListDebugImageUsage = "List possible debug images to use for the debug sidecar container (use this flag by itself)." FlagKubeconfig = "kubeconfig" FlagKubeconfigUsage = "Kubeconfig file location (k8s runtime)" FlagUID = "uid" FlagUIDUsage = "UID to use for the debugging sidecar container" FlagGID = "gid" FlagGIDUsage = "GID to use for the debugging sidecar container" FlagRunPrivileged = "run-privileged" FlagRunPrivilegedUsage = "Run the debug sidecar as a privileged container (true by default)" FlagSecurityContextFromTarget = "security-context-from-target" FlagSecurityContextFromTargetUsage = "Use the security context params from the target container with the debug sidecar container" FlagFallbackToTargetUser = "fallback-to-target-user" FlagFallbackToTargetUserUsage = "Fallback to using target container user if it's non-root (true by default)" )
Debug command flag names and usage descriptions
const ( PCSUnknown = "unknown" PCSConfigured = "created" PCSCreated = "initialized" PCSRunning = "running" PCSStopped = "stopped" PCSPaused = "paused" PCSExited = "exited" PCSRemoving = "removing" PCSStopping = "stopping" //also referenced in the APIs/docs: PCSRestarting = "restarting" PCSDead = "dead" )
https://github.com/containers/podman/blob/main/libpod/define/containerstate.go#L42 PCS - Podman Container State
const ( CSWaiting = "WAITING" CSRunning = "RUNNING" CSTerminated = "TERMINATED" CSOther = "OTHER" )
Variables ¶
var ( ErrPodTerminated = errors.New("Pod terminated") ErrPodNotRunning = errors.New("Pod not running") ErrContainerTerminated = errors.New("Container terminated") )
var ( // TitleStyle is the lipgloss style used for the view title. TitleStyle = lipgloss.NewStyle().Bold(true) // HeaderStyle is the lipgloss style used for the table headers. HeaderStyle = lipgloss.NewStyle().Foreground(white).Bold(true).Align(lipgloss.Center) // CellStyle is the base lipgloss style used for the table rows. CellStyle = lipgloss.NewStyle().Padding(0, 1).Width(14) // OddRowStyle is the lipgloss style used for odd-numbered table rows. OddRowStyle = CellStyle.Foreground(gray) // EvenRowStyle is the lipgloss style used for even-numbered table rows. EvenRowStyle = CellStyle.Foreground(lightGray) // BorderStyle is the lipgloss style used for the table border. BorderStyle = lipgloss.NewStyle().Foreground(white) // CheckboxStyle is the lipgloss style used for the runtime selector CheckboxStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("212")) )
var CLI = &cli.Command{ Name: Name, Aliases: []string{Alias}, Usage: Usage, Flags: []cli.Flag{ command.Cflag(command.FlagRuntime), cflag(FlagTarget), cflag(FlagNamespace), cflag(FlagPod), cflag(FlagDebugImage), cflag(FlagEntrypoint), cflag(FlagCmd), cflag(FlagShellCmd), cflag(FlagWorkdir), cflag(FlagEnv), cflag(FlagLoadTargetEnvVars), cflag(FlagMount), cflag(FlagMountTargetVolumes), cflag(FlagTerminal), cflag(FlagRunAsTargetShell), cflag(FlagListSessions), cflag(FlagShowSessionLogs), cflag(FlagConnectSession), cflag(FlagSession), cflag(FlagListNamespaces), cflag(FlagListPods), cflag(FlagListDebuggableContainers), cflag(FlagListDebugImage), cflag(FlagKubeconfig), cflag(FlagUID), cflag(FlagGID), cflag(FlagRunPrivileged), cflag(FlagSecurityContextFromTarget), cflag(FlagFallbackToTargetUser), command.Cflag(command.FlagTUI), }, Action: func(ctx *cli.Context) error { gcvalues := command.GlobalFlagValues(ctx) if ctx.Bool(command.FlagTUI) { initialTUI := InitialTUI(true, gcvalues) tui.RunTUI(initialTUI, true) return nil } xc := app.NewExecutionContext( Name, gcvalues.QuietCLIMode, gcvalues.OutputFormat) if ctx.Bool(FlagListDebugImage) { xc.Out.State("action.list_debug_images") for k, v := range debugImages { xc.Out.Info("debug.image", ovars{"name": k, "description": v}) } return nil } commandParams := &CommandParams{ Runtime: ctx.String(command.FlagRuntime), TargetRef: ctx.String(FlagTarget), TargetNamespace: ctx.String(FlagNamespace), TargetPod: ctx.String(FlagPod), DebugContainerImage: ctx.String(FlagDebugImage), DoTerminal: ctx.Bool(FlagTerminal), DoRunAsTargetShell: ctx.Bool(FlagRunAsTargetShell), Kubeconfig: ctx.String(FlagKubeconfig), Workdir: ctx.String(FlagWorkdir), EnvVars: ParseNameValueList(ctx.StringSlice(FlagEnv)), DoLoadTargetEnvVars: ctx.Bool(FlagLoadTargetEnvVars), Volumes: ParseMountList(ctx.StringSlice(FlagMount)), DoMountTargetVolumes: ctx.Bool(FlagMountTargetVolumes), Session: ctx.String(FlagSession), ActionListNamespaces: ctx.Bool(FlagListNamespaces), ActionListPods: ctx.Bool(FlagListPods), ActionListDebuggableContainers: ctx.Bool(FlagListDebuggableContainers), ActionListSessions: ctx.Bool(FlagListSessions), ActionShowSessionLogs: ctx.Bool(FlagShowSessionLogs), ActionConnectSession: ctx.Bool(FlagConnectSession), UID: ctx.Int64(FlagUID), GID: ctx.Int64(FlagGID), DoRunPrivileged: ctx.Bool(FlagRunPrivileged), UseSecurityContextFromTarget: ctx.Bool(FlagSecurityContextFromTarget), DoFallbackToTargetUser: ctx.Bool(FlagFallbackToTargetUser), TUI: ctx.Bool(command.FlagTUI), } if commandParams.ActionListNamespaces && commandParams.Runtime == crt.DockerRuntime { xc.Out.Error("param", "unsupported runtime flag") xc.Out.State("exited", ovars{ "runtime.provided": commandParams.Runtime, "runtime.required": fmt.Sprintf("%s|%s", crt.KubernetesRuntime, crt.ContainerdRuntime), "action": commandParams.ActionListNamespaces, "exit.code": -1, }) xc.Exit(-1) } if commandParams.ActionListPods && commandParams.Runtime != crt.KubernetesRuntime { xc.Out.Error("param", "unsupported runtime flag") xc.Out.State("exited", ovars{ "runtime.provided": commandParams.Runtime, "runtime.required": crt.KubernetesRuntime, "action": commandParams.ActionListPods, "exit.code": -1, }) xc.Exit(-1) } var err error if rawEntrypoint := ctx.String(FlagEntrypoint); rawEntrypoint != "" { commandParams.Entrypoint, err = command.ParseExec(rawEntrypoint) if err != nil { return err } } if rawCmd := ctx.String(FlagCmd); rawCmd != "" { commandParams.Cmd, err = command.ParseExec(rawCmd) if err != nil { return err } } if rawCmd := ctx.String(FlagShellCmd); rawCmd != "" { commandParams.CmdIsShell = true commandParams.Cmd, err = command.ParseExec(rawCmd) if err != nil { return err } } if len(commandParams.Entrypoint) > 0 || len(commandParams.Cmd) > 0 { commandParams.DoRunAsTargetShell = false } if commandParams.DoRunAsTargetShell { commandParams.DoTerminal = true } if !commandParams.ActionListNamespaces && !commandParams.ActionListPods && !commandParams.ActionListDebuggableContainers && !commandParams.ActionListSessions && !commandParams.ActionShowSessionLogs && !commandParams.ActionConnectSession && commandParams.TargetRef == "" { if ctx.Args().Len() < 1 { if commandParams.Runtime != crt.KubernetesRuntime { xc.Out.Error("param.target", "missing target") cli.ShowCommandHelp(ctx, Name) return nil } } else { commandParams.TargetRef = ctx.Args().First() if ctx.Args().Len() > 1 && ctx.Args().Slice()[1] == "--" { cmdSlice := ctx.Args().Slice()[2:] var cmdClean []string for _, v := range cmdSlice { v = strings.TrimSpace(v) if v != "" { cmdClean = append(cmdClean, v) } } if len(cmdClean) > 0 { commandParams.CmdIsShell = true commandParams.Cmd = cmdClean commandParams.DoTerminal = false commandParams.DoRunAsTargetShell = false } } } } if commandParams.DebugContainerImage == "" { commandParams.DebugContainerImage = BusyboxImage } OnCommand( xc, gcvalues, commandParams) return nil }, }
var CommandFlagSuggestions = &command.FlagSuggestions{ Names: []prompt.Suggest{ {Text: command.FullFlagName(command.FlagRuntime), Description: command.FlagRuntimeUsage}, {Text: command.FullFlagName(FlagTarget), Description: FlagTargetUsage}, {Text: command.FullFlagName(FlagNamespace), Description: FlagNamespaceUsage}, {Text: command.FullFlagName(FlagPod), Description: FlagPodUsage}, {Text: command.FullFlagName(FlagDebugImage), Description: FlagDebugImageUsage}, {Text: command.FullFlagName(FlagEntrypoint), Description: FlagEntrypointUsage}, {Text: command.FullFlagName(FlagCmd), Description: FlagCmdUsage}, {Text: command.FullFlagName(FlagShellCmd), Description: FlagShellCmdUsage}, {Text: command.FullFlagName(FlagWorkdir), Description: FlagWorkdirUsage}, {Text: command.FullFlagName(FlagEnv), Description: FlagEnvUsage}, {Text: command.FullFlagName(FlagMount), Description: FlagMountUsage}, {Text: command.FullFlagName(FlagMountTargetVolumes), Description: FlagMountTargetVolumesUsage}, {Text: command.FullFlagName(FlagLoadTargetEnvVars), Description: FlagLoadTargetEnvVarsUsage}, {Text: command.FullFlagName(FlagUID), Description: FlagUIDUsage}, {Text: command.FullFlagName(FlagGID), Description: FlagGIDUsage}, {Text: command.FullFlagName(FlagRunPrivileged), Description: FlagRunPrivilegedUsage}, {Text: command.FullFlagName(FlagSecurityContextFromTarget), Description: FlagSecurityContextFromTargetUsage}, {Text: command.FullFlagName(FlagFallbackToTargetUser), Description: FlagFallbackToTargetUserUsage}, {Text: command.FullFlagName(FlagTerminal), Description: FlagTerminalUsage}, {Text: command.FullFlagName(FlagRunAsTargetShell), Description: FlagRunAsTargetShellUsage}, {Text: command.FullFlagName(FlagListSessions), Description: FlagListSessionsUsage}, {Text: command.FullFlagName(FlagShowSessionLogs), Description: FlagShowSessionLogsUsage}, {Text: command.FullFlagName(FlagConnectSession), Description: FlagConnectSessionUsage}, {Text: command.FullFlagName(FlagSession), Description: FlagSessionUsage}, {Text: command.FullFlagName(FlagListNamespaces), Description: FlagListNamespacesUsage}, {Text: command.FullFlagName(FlagListPods), Description: FlagListPodsUsage}, {Text: command.FullFlagName(FlagListDebuggableContainers), Description: FlagListDebuggableContainersUsage}, {Text: command.FullFlagName(FlagListDebugImage), Description: FlagListDebugImageUsage}, {Text: command.FullFlagName(FlagKubeconfig), Description: FlagKubeconfigUsage}, }, Values: map[string]command.CompleteValue{ command.FullFlagName(command.FlagRuntime): command.CompleteRuntime, command.FullFlagName(FlagTarget): completeTarget, command.FullFlagName(FlagDebugImage): completeDebugImage, command.FullFlagName(FlagTerminal): command.CompleteTBool, command.FullFlagName(FlagRunAsTargetShell): command.CompleteTBool, command.FullFlagName(FlagListSessions): command.CompleteBool, command.FullFlagName(FlagShowSessionLogs): command.CompleteBool, command.FullFlagName(FlagConnectSession): command.CompleteBool, command.FullFlagName(FlagSession): completeSession, command.FullFlagName(FlagListNamespaces): command.CompleteBool, command.FullFlagName(FlagListPods): command.CompleteBool, command.FullFlagName(FlagListDebuggableContainers): command.CompleteBool, command.FullFlagName(FlagListDebugImage): command.CompleteBool, command.FullFlagName(FlagNamespace): completeNamespace, command.FullFlagName(FlagPod): completePod, command.FullFlagName(FlagMountTargetVolumes): command.CompleteBool, command.FullFlagName(FlagLoadTargetEnvVars): command.CompleteTBool, command.FullFlagName(FlagRunPrivileged): command.CompleteTBool, command.FullFlagName(FlagSecurityContextFromTarget): command.CompleteBool, command.FullFlagName(FlagFallbackToTargetUser): command.CompleteTBool, }, }
var CommandSuggestion = prompt.Suggest{ Text: Name, Description: Usage, }
var Flags = map[string]cli.Flag{ FlagTarget: &cli.StringFlag{ Name: FlagTarget, Value: "", Usage: FlagTargetUsage, EnvVars: []string{"DSLIM_DBG_TARGET"}, }, FlagNamespace: &cli.StringFlag{ Name: FlagNamespace, Value: crt.NamespaceDefault, Usage: FlagNamespaceUsage, EnvVars: []string{"DSLIM_DBG_TARGET_NS"}, }, FlagPod: &cli.StringFlag{ Name: FlagPod, Value: "", Usage: FlagPodUsage, EnvVars: []string{"DSLIM_DBG_TARGET_POD"}, }, FlagDebugImage: &cli.StringFlag{ Name: FlagDebugImage, Value: BusyboxImage, Usage: FlagDebugImageUsage, EnvVars: []string{"DSLIM_DBG_IMAGE"}, }, FlagEntrypoint: &cli.StringFlag{ Name: FlagEntrypoint, Value: "", Usage: FlagEntrypointUsage, EnvVars: []string{"DSLIM_DBG_ENTRYPOINT"}, }, FlagCmd: &cli.StringFlag{ Name: FlagCmd, Value: "", Usage: FlagCmdUsage, EnvVars: []string{"DSLIM_DBG_CMD"}, }, FlagShellCmd: &cli.StringFlag{ Name: FlagShellCmd, Value: "", Usage: FlagShellCmdUsage, EnvVars: []string{"DSLIM_DBG_SHELL_CMD"}, }, FlagWorkdir: &cli.StringFlag{ Name: FlagWorkdir, Value: "", Usage: FlagWorkdirUsage, EnvVars: []string{"DSLIM_DBG_WDIR"}, }, FlagEnv: &cli.StringSliceFlag{ Name: FlagEnv, Value: cli.NewStringSlice(), Usage: FlagEnvUsage, EnvVars: []string{"DSLIM_DBG_ENV"}, }, FlagLoadTargetEnvVars: &cli.BoolFlag{ Name: FlagLoadTargetEnvVars, Value: true, Usage: FlagLoadTargetEnvVarsUsage, EnvVars: []string{"DSLIM_DBG_LOAD_TARGET_ENVS"}, }, FlagMount: &cli.StringSliceFlag{ Name: FlagMount, Value: cli.NewStringSlice(), Usage: FlagMountUsage, EnvVars: []string{"DSLIM_DBG_MOUNT"}, }, FlagMountTargetVolumes: &cli.BoolFlag{ Name: FlagMountTargetVolumes, Value: false, Usage: FlagMountTargetVolumesUsage, EnvVars: []string{"DSLIM_DBG_MOUNT_TARGET_VOLUMES"}, }, FlagTerminal: &cli.BoolFlag{ Name: FlagTerminal, Value: true, Usage: FlagTerminalUsage, EnvVars: []string{"DSLIM_DBG_TERMINAL"}, }, FlagRunAsTargetShell: &cli.BoolFlag{ Name: FlagRunAsTargetShell, Value: true, Usage: FlagRunAsTargetShellUsage, EnvVars: []string{"DSLIM_DBG_RATS"}, }, FlagListSessions: &cli.BoolFlag{ Name: FlagListSessions, Value: false, Usage: FlagListSessionsUsage, EnvVars: []string{"DSLIM_DBG_LIST_SESSIONS"}, }, FlagShowSessionLogs: &cli.BoolFlag{ Name: FlagShowSessionLogs, Value: false, Usage: FlagShowSessionLogsUsage, EnvVars: []string{"DSLIM_DBG_SHOW_SESSION_LOGS"}, }, FlagConnectSession: &cli.BoolFlag{ Name: FlagConnectSession, Value: false, Usage: FlagConnectSessionUsage, EnvVars: []string{"DSLIM_DBG_CONNECT_SESSION"}, }, FlagSession: &cli.StringFlag{ Name: FlagSession, Value: "", Usage: FlagSessionUsage, EnvVars: []string{"DSLIM_DBG_SESSION"}, }, FlagListNamespaces: &cli.BoolFlag{ Name: FlagListNamespaces, Value: false, Usage: FlagListNamespacesUsage, EnvVars: []string{"DSLIM_DBG_LIST_NAMESPACES"}, }, FlagListPods: &cli.BoolFlag{ Name: FlagListPods, Value: false, Usage: FlagListPodsUsage, EnvVars: []string{"DSLIM_DBG_LIST_PODS"}, }, FlagListDebuggableContainers: &cli.BoolFlag{ Name: FlagListDebuggableContainers, Value: false, Usage: FlagListDebuggableContainersUsage, EnvVars: []string{"DSLIM_DBG_LIST_CONTAINERS"}, }, FlagListDebugImage: &cli.BoolFlag{ Name: FlagListDebugImage, Value: false, Usage: FlagListDebugImageUsage, EnvVars: []string{"DSLIM_DBG_LIST_IMAGES"}, }, FlagKubeconfig: &cli.StringFlag{ Name: FlagKubeconfig, Value: crt.KubeconfigDefault, Usage: FlagKubeconfigUsage, EnvVars: []string{"DSLIM_DBG_KUBECONFIG"}, }, FlagUID: &cli.Int64Flag{ Name: FlagUID, Value: -1, Usage: FlagUIDUsage, EnvVars: []string{"DSLIM_DBG_UID"}, }, FlagGID: &cli.Int64Flag{ Name: FlagGID, Value: -1, Usage: FlagGIDUsage, EnvVars: []string{"DSLIM_DBG_GID"}, }, FlagRunPrivileged: &cli.BoolFlag{ Name: FlagRunPrivileged, Value: true, Usage: FlagRunPrivilegedUsage, EnvVars: []string{"DSLIM_DBG_RUN_PRIV"}, }, FlagSecurityContextFromTarget: &cli.BoolFlag{ Name: FlagSecurityContextFromTarget, Value: false, Usage: FlagSecurityContextFromTargetUsage, EnvVars: []string{"DSLIM_DBG_USE_TARGET_SEC_CTX"}, }, FlagFallbackToTargetUser: &cli.BoolFlag{ Name: FlagFallbackToTargetUser, Value: true, Usage: FlagFallbackToTargetUserUsage, EnvVars: []string{"DSLIM_DBG_FALLBACK_TO_TARGET_USER"}, }, }
Functions ¶
func HandleContainerdRuntime ¶
func HandleContainerdRuntime( logger *log.Entry, xc *app.ExecutionContext, gparams *command.GenericParams, commandParams *CommandParams, sid string, debugContainerName string)
HandleContainerdRuntime implements support for the ContainerD runtime
func HandleDockerRuntime ¶
func HandleDockerRuntime( logger *log.Entry, xc *app.ExecutionContext, gparams *command.GenericParams, commandParams *CommandParams, client *dockerapi.Client, sid string, debugContainerName string)
HandleDockerRuntime implements support for the docker runtime
func HandleKubernetesRuntime ¶
func HandleKubernetesRuntime( logger *log.Entry, xc *app.ExecutionContext, gparams *command.GenericParams, commandParams *CommandParams, dockerClient *dockerapi.Client, sid string, debugContainerName string)
HandleKubernetesRuntime implements support for the k8s runtime
func HandlePodmanRuntime ¶
func HandlePodmanRuntime( logger *log.Entry, xc *app.ExecutionContext, gparams *command.GenericParams, commandParams *CommandParams, sid string, debugContainerName string)
HandlePodmanRuntime implements support for the Podman runtime
func OnCommand ¶
func OnCommand( xc *app.ExecutionContext, gparams *command.GenericParams, commandParams *CommandParams)
OnCommand implements the 'debug' command
func RegisterCommand ¶
func RegisterCommand()
func ShellCommandPrefix ¶
Types ¶
type CommandParams ¶
type CommandParams struct { RuntimeCommunicator *RuntimeCommunicator /// the runtime environment type Runtime string /// the running container which we want to attach to TargetRef string /// the target namespace (k8s runtime) TargetNamespace string /// the target pod (k8s runtime) TargetPod string /// the name/id of the container image used for debugging DebugContainerImage string /// ENTRYPOINT used launching the debugging container Entrypoint []string CmdIsShell bool /// CMD used launching the debugging container Cmd []string /// WORKDIR used launching the debugging container Workdir string /// Environment variables used launching the debugging container EnvVars []NVPair /// load the environment variables from the target container's container spec into the debug container DoLoadTargetEnvVars bool /// volumes to mount in the debug side-car container Volumes []Volume /// mount all volumes mounted in the target container DoMountTargetVolumes bool /// launch the debug container with an interactive terminal attached (like '--it' in docker) DoTerminal bool /// make it look like shell is running in the target container DoRunAsTargetShell bool /// Kubeconfig file path (k8s runtime) Kubeconfig string /// Debug session container name Session string /// Simple (non-debug) action - list namespaces ActionListNamespaces bool /// Simple (non-debug) action - list pods ActionListPods bool /// Simple (non-debug) action - list debuggable container ActionListDebuggableContainers bool /// Simple (non-debug) action - list debug sessions ActionListSessions bool /// Simple (non-debug) action - show debug sessions logs ActionShowSessionLogs bool /// Simple (non-debug) action - connect to an existing debug session ActionConnectSession bool /// UID to use for the debugging sidecar container UID int64 /// GID to use for the debugging sidecar container GID int64 /// run the debug sidecar as a privileged container DoRunPrivileged bool /// use the security context params from the target container with the debug sidecar container UseSecurityContextFromTarget bool /// fallback to using target container user if it's non-root (mostly for kubernetes) DoFallbackToTargetUser bool // `debug --tui` use mode` TUI bool }
type CreateContainerError ¶
func (*CreateContainerError) Error ¶
func (e *CreateContainerError) Error() string
type DebugContainerInfo ¶
type DebugContainerInfo struct { TargetContainerName string Name string SpecImage string Command []string Args []string WorkingDir string TTY bool ContainerID string RunningImage string RunningImageID string StartTime string FinishTime string State string ExitCode int32 ExitReason string ExitMessage string WaitReason string WaitMessage string }
type DebuggableContainer ¶
type InputKey ¶
type InputKey struct { Rune rune Special SpecialKey }
type NVPair ¶
func ParseNameValueList ¶
type RuntimeCommunicator ¶
type RuntimeCommunicator struct {
InputChan chan InputKey
}
We want to genericize this handler to: a general RuntimeCommunicationHandler. This handler is what will be passed to: Docker, Podman, Kubernetes & Containerd. This handler should not live on CommandParams, but be passed in to OnCommand, then to the respective runtime handler.
type SpecialKey ¶
type SpecialKey int
const ( NotSpecial SpecialKey = iota Enter Backspace Up Down Left Right )
type TUI ¶
type TUI struct {
// contains filtered or unexported fields
}
TUI represents the internal state of the terminal user interface.
func InitialTUI ¶
func InitialTUI(standalone bool, gcvalues *command.GenericParams) *TUI
InitialTUI returns the initial state of the model.