File tree Expand file tree Collapse file tree 2 files changed +21
-4
lines changed
Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Original file line number Diff line number Diff line change 11package cp
22
33import (
4+ "fmt"
5+
46 "github.com/sikalabs/gobble/pkg/libtask"
57 "github.com/sikalabs/gobble/pkg/utils/exec_utils"
68)
79
810type TaskCp struct {
11+ // Copy from local to remote
912 LocalSrc string `yaml:"local_src"`
1013 RemoteDst string `yaml:"remote_dst"`
14+ // Copy from remote to local
15+ RemoteSrc string `yaml:"remote_src"`
16+ LocalDst string `yaml:"local_dst"`
1117}
1218
1319func Run (
1420 taskInput libtask.TaskInput ,
1521 taskParams TaskCp ,
1622) libtask.TaskOutput {
17- err := exec_utils .SCP (taskInput , taskParams .LocalSrc , taskParams .RemoteDst )
18- return libtask.TaskOutput {
19- Error : err ,
23+ if taskParams .LocalSrc != "" && taskParams .RemoteDst != "" {
24+ err := exec_utils .SCP (taskInput , taskParams .LocalSrc , taskParams .RemoteDst )
25+ return libtask.TaskOutput {
26+ Error : err ,
27+ }
28+ } else if taskParams .RemoteSrc != "" && taskParams .LocalDst != "" {
29+ err := exec_utils .SCPRemoteToLocal (taskInput , taskParams .RemoteSrc , taskParams .LocalDst )
30+ return libtask.TaskOutput {
31+ Error : err ,
32+ }
33+ } else {
34+ return libtask.TaskOutput {
35+ Error : fmt .Errorf ("invalid cp task params" ),
36+ }
2037 }
2138}
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ func Run(
3131 switch {
3232 case task .AptInstall .Name != "" :
3333 return apt_install .Run (taskInput , task .AptInstall )
34- case task .Cp .LocalSrc != "" :
34+ case task .Cp .LocalSrc != "" || task . Cp . RemoteSrc != "" :
3535 return cp .Run (taskInput , task .Cp )
3636 case task .Template .Path != "" :
3737 return template .Run (taskInput , task .Template )
You can’t perform that action at this time.
0 commit comments