Skip to content

Commit

Permalink
bugtool: allow to specify bpftool on client cli
Browse files Browse the repository at this point in the history
Signed-off-by: Djalal Harouni <[email protected]>
  • Loading branch information
tixxdz committed Jul 12, 2023
1 parent dfa8470 commit 8667e86
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion cmd/tetra/bugtool/bugtool.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,20 @@ import (

var (
outFile string
bpfTool string
)

func New() *cobra.Command {
bugtoolCmd := &cobra.Command{
Use: "bugtool",
Short: "Produce a tar archive with debug information",
Run: func(cmd *cobra.Command, args []string) {
bugtool.Bugtool(outFile)
bugtool.Bugtool(outFile, bpfTool)
},
}

flags := bugtoolCmd.Flags()
flags.StringVarP(&outFile, "out", "o", "tetragon-bugtool.tar.gz", "Output filename")
flags.StringVar(&bpfTool, "bpftool", "", "Path to bpftool binary")
return bugtoolCmd
}
6 changes: 5 additions & 1 deletion pkg/bugtool/bugtool.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,16 @@ func (s *bugtoolInfo) tarAddFile(tarWriter *tar.Writer, fnameSrc string, fnameDs
}

// Bugtool gathers information and writes it as a tar archive in the given filename
func Bugtool(outFname string) error {
func Bugtool(outFname string, bpftool string) error {
info, err := LoadInitInfo()
if err != nil {
return err
}

if bpftool != "" {
info.BpfToolPath = bpftool
}

return doBugtool(info, outFname)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/observer/observer_test_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func withNotestfail(notestfail bool) TestOption {
func testDone(t *testing.T, obs *Observer) {
if t.Failed() {
bugtoolFname := "/tmp/tetragon-bugtool.tar.gz"
if err := bugtool.Bugtool(bugtoolFname); err == nil {
if err := bugtool.Bugtool(bugtoolFname, ""); err == nil {
logger.GetLogger().WithField("test", t.Name()).
WithField("file", bugtoolFname).Info("Dumped bugtool info")
} else {
Expand Down

0 comments on commit 8667e86

Please sign in to comment.