Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion get_git.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
type GitGetter struct {
Detectors []Detector

// Timeout sets a deadline which all hg CLI operations should
// Timeout sets a deadline which all git CLI operations should
// complete within. Defaults to zero which means no timeout.
Timeout time.Duration
}
Expand Down
15 changes: 13 additions & 2 deletions get_smbclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ import (
"os/exec"
"path/filepath"
"regexp"
"strconv"
"strings"
"syscall"
)

// SmbClientGetter is a Getter implementation that will download a module from
// a shared folder using smbclient cli.
type SmbClientGetter struct{}
type SmbClientGetter struct {

// Timeout in seconds sets a deadline which all smb client CLI operations should
// complete within. Defaults to zero which means to use the default client timeout of 20 seconds.
Timeout int
}

func (g *SmbClientGetter) Mode(ctx context.Context, u *url.URL) (Mode, error) {
if u.Host == "" || u.Path == "" {
Expand Down Expand Up @@ -216,6 +222,10 @@ func (g *SmbClientGetter) smbclientCmdArgs(used *url.Userinfo, hostPath string,
baseCmd = append(baseCmd, hostPath)
baseCmd = append(baseCmd, "--directory")
baseCmd = append(baseCmd, fileDir)
if g.Timeout > 0 {
baseCmd = append(baseCmd, "-t")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

baseCmd = append(baseCmd, strconv.Itoa(g.Timeout))
}
return baseCmd
}

Expand Down Expand Up @@ -254,7 +264,8 @@ func (g *SmbClientGetter) isDirectory(args []string, object string) (bool, error
}

func (g *SmbClientGetter) runSmbClientCommand(dst string, args []string) (string, error) {
cmd := exec.Command("smbclient", args...)
ctx := context.Background()
cmd := exec.CommandContext(ctx, "smbclient", args...)

if dst != "" {
cmd.Dir = dst
Expand Down