Skip to content

Commit

Permalink
tetra: move the dump command to a debug sub command
Browse files Browse the repository at this point in the history
Also creates a hidden alias to not break compatibility with dump being a
top command. But now we have the debug command to host those kind of sub
commands.

Signed-off-by: Mahe Tardy <[email protected]>
  • Loading branch information
mtardy committed Sep 27, 2024
1 parent 4d81e96 commit c9abfca
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
3 changes: 1 addition & 2 deletions cmd/tetra/commands_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/cilium/tetragon/cmd/tetra/bugtool"
"github.com/cilium/tetragon/cmd/tetra/cri"
"github.com/cilium/tetragon/cmd/tetra/debug"
"github.com/cilium/tetragon/cmd/tetra/dump"
"github.com/cilium/tetragon/cmd/tetra/loglevel"
"github.com/cilium/tetragon/cmd/tetra/policyfilter"
"github.com/cilium/tetragon/cmd/tetra/probe"
Expand All @@ -19,8 +18,8 @@ func addCommands(rootCmd *cobra.Command) {
addBaseCommands(rootCmd)
rootCmd.AddCommand(bugtool.New())
rootCmd.AddCommand(tracingpolicy.New())
rootCmd.AddCommand(dump.New())
rootCmd.AddCommand(debug.New())
rootCmd.AddCommand(debug.NewDumpAlias())
rootCmd.AddCommand(policyfilter.New())
rootCmd.AddCommand(probe.New())
rootCmd.AddCommand(loglevel.New())
Expand Down
1 change: 1 addition & 0 deletions cmd/tetra/debug/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ func New() *cobra.Command {
Hidden: true,
}
cmd.AddCommand(NewMapCmd())
cmd.AddCommand(NewDumpCommand())
return &cmd
}
15 changes: 11 additions & 4 deletions cmd/tetra/dump/dump.go → cmd/tetra/debug/dump.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Authors of Tetragon

package dump
package debug

import (
"fmt"
Expand All @@ -21,11 +21,18 @@ import (
"google.golang.org/grpc"
)

func New() *cobra.Command {
// NewDumpAlias return a hidden alias of the dump subcommand, dump used to be a
// top level commands and was moved under debug, this avoids a breaking change.
func NewDumpAlias() *cobra.Command {
legacyDump := NewDumpCommand()
legacyDump.Hidden = true
return legacyDump
}

func NewDumpCommand() *cobra.Command {
ret := &cobra.Command{
Use: "dump",
Short: "dump information",
Hidden: true,
Short: "Dump information from tetragon maps and caches",
SilenceUsage: true,
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/tetra/policyfilter/policyfilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"path/filepath"
"strconv"

"github.com/cilium/tetragon/cmd/tetra/dump"
"github.com/cilium/tetragon/cmd/tetra/debug"
"github.com/cilium/tetragon/pkg/cgroups"
"github.com/cilium/tetragon/pkg/defaults"
"github.com/cilium/tetragon/pkg/logger"
Expand Down Expand Up @@ -41,7 +41,7 @@ func dumpDebugCmd() *cobra.Command {
Short: "dump cgroup ID to namespace state",
Args: cobra.ExactArgs(0),
Run: func(_ *cobra.Command, _ []string) {
dump.NamespaceState(mapFname)
debug.NamespaceState(mapFname)
},
}

Expand Down Expand Up @@ -77,7 +77,7 @@ func dumpCmd() *cobra.Command {
Short: "dump policyfilter state",
Args: cobra.ExactArgs(0),
Run: func(_ *cobra.Command, _ []string) {
dump.PolicyfilterState(mapFname)
debug.PolicyfilterState(mapFname)
},
}

Expand Down

0 comments on commit c9abfca

Please sign in to comment.