Skip to content

Commit

Permalink
fix: list command unlimited recursion default behavior
Browse files Browse the repository at this point in the history
Revert back to old behavior.

Signed-off-by: Artem Chernyshev <artem.0xD2@gmail.com>
  • Loading branch information
Unix4ever authored and talos-bot committed Jan 15, 2021
1 parent 9883d0a commit d515613
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -684,16 +684,20 @@ func (s *Server) List(req *machine.ListRequest, obj machine.MachineService_ListS
req.Root = "/"
}

var opts []archiver.WalkerOption
var recursionDepth int

if req.Recurse {
if req.RecursionDepth == 0 {
opts = append(opts, archiver.WithMaxRecurseDepth(-1))
recursionDepth = -1
} else {
opts = append(opts, archiver.WithMaxRecurseDepth(int(req.RecursionDepth)))
recursionDepth = int(req.RecursionDepth)
}
}

opts := []archiver.WalkerOption{
archiver.WithMaxRecurseDepth(recursionDepth),
}

if len(req.Types) > 0 {
types := make([]archiver.FileType, 0, len(req.Types))

Expand Down
3 changes: 3 additions & 0 deletions internal/integration/cli/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ func (suite *ListSuite) SuiteName() string {
func (suite *ListSuite) TestSuccess() {
suite.RunCLI([]string{"list", "--nodes", suite.RandomDiscoveredNode(), "/etc"},
base.StdoutShouldMatch(regexp.MustCompile(`os-release`)))

suite.RunCLI([]string{"list", "--nodes", suite.RandomDiscoveredNode(), "/"},
base.StdoutShouldNotMatch(regexp.MustCompile(`os-release`)))
}

func init() {
Expand Down

0 comments on commit d515613

Please sign in to comment.