-
Notifications
You must be signed in to change notification settings - Fork 3
/
gen.go
46 lines (41 loc) · 905 Bytes
/
gen.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
package main
//go:generate go run -ldflags "${LD_FLAGS}" $GOFILE
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"path"
"runtime"
)
const metadataFile = "plugin-meta.json"
var (
GitCommit string
GitBranch string
GitRepo string
Version string
Executable string
OutputDir string
)
func main() {
if len(OutputDir) == 0 {
OutputDir = "build"
}
meta := make(map[string]interface{})
meta["name"] = "quorum-plugin-qlight-token-manager"
meta["version"] = Version
meta["os"] = runtime.GOOS
meta["arch"] = runtime.GOARCH
meta["gitCommit"] = GitCommit
meta["gitBranch"] = GitBranch
meta["gitRepo"] = GitRepo
meta["entrypoint"] = Executable
data, err := json.MarshalIndent(meta, "", " ")
if err != nil {
log.Fatal(err)
}
if err := ioutil.WriteFile(path.Join(OutputDir, metadataFile), data, 0644); err != nil {
log.Fatal(err)
}
fmt.Println("Wrote", metadataFile)
}