From 0e0f946f5c84b8f97842ccc373a9786e0066aa7c Mon Sep 17 00:00:00 2001 From: Sadayuki Matsuno Date: Fri, 5 Jun 2020 14:30:08 +0900 Subject: [PATCH] add 32 bit releaser and add exit code in cmd --- .goreleaser.yml | 6 ++++++ contrib/future-vuls/cmd/main.go | 5 ++++- contrib/trivy/cmd/main.go | 5 +++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index c9402a62..bbb62643 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -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: diff --git a/contrib/future-vuls/cmd/main.go b/contrib/future-vuls/cmd/main.go index 1b4b233a..52fe857d 100644 --- a/contrib/future-vuls/cmd/main.go +++ b/contrib/future-vuls/cmd/main.go @@ -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 diff --git a/contrib/trivy/cmd/main.go b/contrib/trivy/cmd/main.go index 3c075c42..d946e713 100644 --- a/contrib/trivy/cmd/main.go +++ b/contrib/trivy/cmd/main.go @@ -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) } }