-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathplugin.go
56 lines (46 loc) · 832 Bytes
/
plugin.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main
import (
"fmt"
"os"
"os/exec"
"strings"
)
type (
Config struct {
AccountKey string
Account string
Container string
Source string
}
Plugin struct {
Config Config
}
)
func (p Plugin) Exec() error {
return p.execute(p.command())
}
func (p *Plugin) command() *exec.Cmd {
args := []string{
p.Config.Account,
p.Config.Container,
p.Config.Source,
}
args = append(
args,
fmt.Sprintf("--storageaccountkey=%s", p.Config.AccountKey),
)
return exec.Command(
"blobxfer",
args...,
)
}
func (p Plugin) execute(cmd *exec.Cmd) error {
cmd.Env = os.Environ()
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
p.trace(cmd)
return cmd.Run()
}
func (p *Plugin) trace(cmd *exec.Cmd) {
fmt.Println("+", strings.Replace(strings.Join(cmd.Args, " "), p.Config.AccountKey, "***", -1))
}