add 32 bit releaser and add exit code in cmd

This commit is contained in:
Sadayuki Matsuno
2020-06-05 14:30:08 +09:00
parent 621fa8a01f
commit 0e0f946f5c
3 changed files with 15 additions and 1 deletions

View File

@@ -11,11 +11,13 @@ builds:
- linux
goarch:
- amd64
- 386
main: .
flags:
- -a
ldflags: -s -w -X main.version={{.Version}} -X main.revision={{.Commit}}
binary: vuls
- id: trivy-to-vuls
goos:
- linux
@@ -23,6 +25,7 @@ builds:
- amd64
main: ./contrib/trivy/cmd/main.go
binary: trivy-to-vuls
- id: future-vuls
goos:
- linux
@@ -31,6 +34,7 @@ builds:
main: ./contrib/future-vuls/cmd/main.go
binary: future-vuls
archives:
- id: vuls
name_template: '{{ .Binary }}_{{.Version}}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
builds:
@@ -41,6 +45,7 @@ archives:
- NOTICE
- README*
- CHANGELOG.md
- id: trivy-to-vuls
name_template: '{{ .Binary }}_{{.Version}}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
builds:
@@ -54,6 +59,7 @@ archives:
- id: future-vuls
name_template: '{{ .Binary }}_{{.Version}}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
builds:
- future-vuls
format: tar.gz
files:

View File

@@ -58,12 +58,14 @@ func main() {
scanResultJSON = buf.Bytes()
} else {
fmt.Println("use --stdin option")
os.Exit(1)
return
}
var scanResult models.ScanResult
if err = json.Unmarshal(scanResultJSON, &scanResult); err != nil {
fmt.Println("Failed to parse json", err)
os.Exit(1)
return
}
scanResult.ServerUUID = serverUUID
@@ -72,7 +74,8 @@ func main() {
config.Conf.Saas.Token = token
config.Conf.Saas.URL = url
if err = (report.SaasWriter{}).Write(scanResult); err != nil {
fmt.Println("Failed to create json", err)
fmt.Println(err)
os.Exit(1)
return
}
return

View File

@@ -34,12 +34,14 @@ func main() {
reader := bufio.NewReader(os.Stdin)
buf := new(bytes.Buffer)
if _, err = buf.ReadFrom(reader); err != nil {
os.Exit(1)
return
}
trivyJSON = buf.Bytes()
} else {
if trivyJSON, err = ioutil.ReadFile(jsonFilePath); err != nil {
fmt.Println("Failed to read file", err)
os.Exit(1)
return
}
}
@@ -50,11 +52,13 @@ func main() {
}
if scanResult, err = parser.Parse(trivyJSON, scanResult); err != nil {
fmt.Println("Failed to execute command", err)
os.Exit(1)
return
}
var resultJSON []byte
if resultJSON, err = json.MarshalIndent(scanResult, "", " "); err != nil {
fmt.Println("Failed to create json", err)
os.Exit(1)
return
}
fmt.Println(string(resultJSON))
@@ -68,6 +72,7 @@ func main() {
var rootCmd = &cobra.Command{Use: "trivy-to-vuls"}
rootCmd.AddCommand(cmdTrivyToVuls)
if err = rootCmd.Execute(); err != nil {
os.Exit(1)
fmt.Println("Failed to execute command", err)
}
}