-
Notifications
You must be signed in to change notification settings - Fork 3
/
packman.go
49 lines (40 loc) · 966 Bytes
/
packman.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
package packman
import (
"encoding/json"
"github.com/securenative/packman/internal"
"github.com/securenative/packman/internal/business"
"io/ioutil"
"os"
)
const PackageNameFlag = business.PackageName
const PackagePathFlag = business.PackagePath
func Unpack(remote, path string, flagsMap map[string]string) error {
return internal.M.TemplatingService.Unpack(remote, path, flagsMap)
}
func Auth(username, password string) error {
return internal.M.ConfigService.SetAuth(username, password)
}
func ReadFlags() map[string]string {
var out map[string]string
path := os.Args[1]
flagsContent, err := ioutil.ReadFile(path)
if err != nil {
panic(err)
}
err = json.Unmarshal(flagsContent, &out)
if err != nil {
panic(err)
}
return out
}
func WriteReply(model interface{}) {
bytes, err := json.Marshal(model)
if err != nil {
panic(err)
}
path := os.Args[2]
err = ioutil.WriteFile(path, bytes, os.ModePerm)
if err != nil {
panic(err)
}
}