Fix golang lint errors (#2068)

* Fix golang lint errors

Signed-off-by: Harsh Thakur <harshthakur9030@gmail.com>

* Typo for fields

Signed-off-by: Harsh Thakur <harshthakur9030@gmail.com>

* Multi error fix

Signed-off-by: Harsh Thakur <harshthakur9030@gmail.com>

* Multi error fix

Signed-off-by: Harsh Thakur <harshthakur9030@gmail.com>

* Add nolint to logtostderr errcheck

Signed-off-by: Harsh Thakur <harshthakur9030@gmail.com>
This commit is contained in:
Harsh Thakur
2021-06-15 15:03:42 +05:30
committed by GitHub
parent 377600d0a3
commit 6facdac464
19 changed files with 82 additions and 91 deletions
+6 -1
View File
@@ -34,7 +34,12 @@ func main() {
if err != nil {
log.Fatalf("can't initialize zap logger: %v", err)
}
defer logger.Sync()
defer func() {
err := logger.Sync()
if err != nil {
log.Fatal(err)
}
}()
shareVolume := os.Args[1]
if _, err := os.Stat(shareVolume); err != nil {
+5 -1
View File
@@ -21,6 +21,7 @@ import (
"encoding/json"
"flag"
"fmt"
"log"
"net/http"
"os"
@@ -136,9 +137,12 @@ func Run(logger *zap.Logger) {
mux.HandleFunc("/readniess-healthz", readinessHandler)
logger.Info("fetcher ready to receive requests")
http.ListenAndServe(":8000", &ochttp.Handler{
err = http.ListenAndServe(":8000", &ochttp.Handler{
Handler: mux,
})
if err != nil {
log.Fatal(err)
}
}
func fetcherUsage() {
+6 -2
View File
@@ -33,7 +33,11 @@ func main() {
if err != nil {
log.Fatalf("can't initialize zap logger: %v", err)
}
defer logger.Sync()
defer func() {
err := logger.Sync()
if err != nil {
log.Fatal(err)
}
}()
app.Run(logger)
}
+10 -4
View File
@@ -176,12 +176,15 @@ func registerTraceExporter(logger *zap.Logger, arguments map[string]interface{})
}
func main() {
var err error
// From https://github.com/containous/traefik/pull/1817/files
// Tell glog to log into STDERR. Otherwise, we risk
// certain kinds of API errors getting logged into a directory not
// available in a `FROM scratch` Docker container, causing glog to abort
// hard with an exit code > 0.
flag.Set("logtostderr", "true")
// TODO: fix the lint error. Error checking here is causing all components to crash with error "logtostderr not found"
flag.Set("logtostderr", "true") //nolint: errcheck
usage := `fission-bundle: Package of all fission microservices: controller, router, executor.
@@ -236,7 +239,6 @@ Options:
`
var logger *zap.Logger
var err error
var config zap.Config
isDebugEnv, _ := strconv.ParseBool(os.Getenv("DEBUG_ENV"))
@@ -253,8 +255,12 @@ Options:
if err != nil {
log.Fatalf("I can't initialize zap logger: %v", err)
}
defer logger.Sync()
defer func() {
err := logger.Sync()
if err != nil {
log.Fatal(err)
}
}()
version := fmt.Sprintf("Fission Bundle Version: %v", info.BuildInfo().String())
arguments, err := docopt.ParseArgs(usage, nil, version)
if err != nil {
+6 -1
View File
@@ -42,7 +42,12 @@ func main() {
if err != nil {
log.Fatalf("can't initialize zap logger: %v", err)
}
defer logger.Sync()
defer func() {
err := logger.Sync()
if err != nil {
log.Fatal(err)
}
}()
usage := `Package to perform operations needed prior to fission installation
Usage:
+11 -2
View File
@@ -16,6 +16,8 @@ limitations under the License.
package app
import (
"log"
"github.com/fission/fission/pkg/tracker"
"github.com/spf13/cobra"
)
@@ -49,6 +51,7 @@ func eventCommandHandler(cmd *cobra.Command, args []string) error {
return tracker.Tracker.SendEvent(event)
}
//EventCommand reports an event to analytics
func EventCommand() *cobra.Command {
eventCmd := &cobra.Command{
Use: "event",
@@ -61,7 +64,13 @@ func EventCommand() *cobra.Command {
persistentFlags.StringP("action", "a", "", "event action")
persistentFlags.StringP("label", "l", "", "event label")
persistentFlags.StringP("value", "v", "", "event value")
eventCmd.MarkPersistentFlagRequired("category")
eventCmd.MarkPersistentFlagRequired("action")
err := eventCmd.MarkPersistentFlagRequired("category")
if err != nil {
log.Fatal(err)
}
err = eventCmd.MarkPersistentFlagRequired("action")
if err != nil {
log.Fatal(err)
}
return eventCmd
}
+6 -1
View File
@@ -17,9 +17,14 @@ limitations under the License.
package main
import (
"log"
"github.com/fission/fission/cmd/reporter/app"
)
func main() {
app.App().Execute()
err := app.App().Execute()
if err != nil {
log.Fatal(err)
}
}