Skip to content

Commit

Permalink
Add bash command in restic package
Browse files Browse the repository at this point in the history
Signed-off-by: Anisur Rahman <anisur@appscode.com>
  • Loading branch information
anisurrahman75 committed Nov 19, 2024
1 parent 2e1520f commit f586a26
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/restic/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (

const (
ResticCMD = "/bin/restic"
BashCMD = "/bin/bash"
)

type Snapshot struct {
Expand Down Expand Up @@ -438,7 +439,7 @@ func (w *ResticWrapper) run(commands ...Command) ([]byte, error) {
return nil, err
}
}
w.sh.Command(cmd.Name, cmd.Args...)
w.sh.Command(BashCMD, "-c", cmd.getCommandAsString())
}
out, err := w.sh.Output()
if err != nil {
Expand Down Expand Up @@ -581,3 +582,11 @@ func (w *ResticWrapper) appendInsecureTLSFlag(args []interface{}) []interface{}
}
return args
}

func (c *Command) getCommandAsString() string {
cmdParts := []string{c.Name}
for _, arg := range c.Args {
cmdParts = append(cmdParts, fmt.Sprintf("%v", arg))
}
return strings.Join(cmdParts, " ")
}

0 comments on commit f586a26

Please sign in to comment.