mirror of
https://github.com/appleboy/drone-scp.git
synced 2026-06-14 22:11:32 +08:00
feat(tar): add Overwrite flag (#102)
* feat(tar): add Overwrite flag * chore: remove * chore: output * chore: output
This commit is contained in:
@@ -61,6 +61,7 @@ type (
|
||||
TarTmpPath string
|
||||
Proxy easyssh.DefaultConfig
|
||||
Debug bool
|
||||
Overwrite bool
|
||||
}
|
||||
|
||||
// Plugin values.
|
||||
@@ -196,8 +197,7 @@ type fileList struct {
|
||||
Source []string
|
||||
}
|
||||
|
||||
// Args get tar command
|
||||
func (p *Plugin) Args(target string) []string {
|
||||
func (p *Plugin) buildArgs(target string) []string {
|
||||
args := []string{}
|
||||
|
||||
args = append(args,
|
||||
@@ -211,6 +211,10 @@ func (p *Plugin) Args(target string) []string {
|
||||
args = append(args, strconv.Itoa(p.Config.StripComponents))
|
||||
}
|
||||
|
||||
if p.Config.Overwrite {
|
||||
args = append(args, "--overwrite")
|
||||
}
|
||||
|
||||
args = append(args,
|
||||
"-C",
|
||||
target,
|
||||
@@ -326,11 +330,19 @@ func (p *Plugin) Exec() error {
|
||||
|
||||
// untar file
|
||||
p.log(host, "untar file", p.DestFile)
|
||||
commamd := strings.Join(p.Args(target), " ")
|
||||
commamd := strings.Join(p.buildArgs(target), " ")
|
||||
if p.Config.Debug {
|
||||
fmt.Println("$", commamd)
|
||||
}
|
||||
_, _, _, err = ssh.Run(commamd, p.Config.CommandTimeout)
|
||||
outStr, errStr, _, err := ssh.Run(commamd, p.Config.CommandTimeout)
|
||||
|
||||
if outStr != "" {
|
||||
p.log(host, "output: ", outStr)
|
||||
}
|
||||
|
||||
if errStr != "" {
|
||||
p.log(host, "error: ", errStr)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
errChannel <- err
|
||||
|
||||
Reference in New Issue
Block a user