Files
buildx/monitor/commands/show.go
Kohei Tokunaga bcf21dee44 monitor: support step-by-step breakpoint debugger
This commit adds a set of commands to monitor for enabling breakpoint debugger.
This is implemented based on the walker utility for step-by-step LLB inspection.
For each vertex and breakpoint, monitor calls Solve API so the user can enter to
the debugger container on each vertex for inspection.

User can enter to the breakpoint debugger mode by --invoke=debug-step flag.

Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2023-06-30 22:05:06 +09:00

40 lines
930 B
Go

package commands
import (
"context"
"io"
"github.com/docker/buildx/monitor/types"
monitorutils "github.com/docker/buildx/monitor/utils"
"github.com/pkg/errors"
)
type ShowCmd struct {
m types.Monitor
stdout io.WriteCloser
}
func NewShowCmd(m types.Monitor, stdout io.WriteCloser) types.Command {
return &ShowCmd{m, stdout}
}
func (cm *ShowCmd) Info() types.CommandInfo {
return types.CommandInfo{
Name: "show",
HelpMessage: "shows the debugging Dockerfile with breakpoint information",
HelpMessageLong: `
Usage:
show
`,
}
}
func (cm *ShowCmd) Exec(ctx context.Context, args []string) error {
st := cm.m.GetWalkerController().Inspect()
if len(st.Definition.Source.Infos) != 1 {
return errors.Errorf("list: multiple sources isn't supported")
}
monitorutils.PrintLines(cm.stdout, st.Definition.Source.Infos[0], st.Cursors, cm.m.GetWalkerController().Breakpoints(), 0, 0, true)
return nil
}