From f8475af5a6c9b782f7a0ee38b6a4699c8d2f55e2 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 4 Oct 2022 10:39:28 -0700 Subject: [PATCH] do not log random errors using Go logger (#2355) we need to make sure that we print in consistent format for the logs, remove the unnecessary logs everywhere used via `log.Print*` --- .golangci.yml | 7 +------ pkg/subnet/subnet.go | 2 -- restapi/configure_console.go | 19 +++++++++++-------- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 89f2c905e..6f15fbd41 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -14,24 +14,19 @@ linters-settings: linters: disable-all: true enable: - - typecheck - goimports - misspell - govet - revive - ineffassign - gosimple - - deadcode - - structcheck - gomodguard - gofmt - unused - - structcheck - unconvert - varcheck - gocritic - gofumpt - - tenv - durationcheck service: @@ -51,4 +46,4 @@ run: skip-dirs: - pkg/clientgen - pkg/apis/networking.gke.io - - restapi/operations \ No newline at end of file + - restapi/operations diff --git a/pkg/subnet/subnet.go b/pkg/subnet/subnet.go index 3ee39adb7..9ecdfe477 100644 --- a/pkg/subnet/subnet.go +++ b/pkg/subnet/subnet.go @@ -22,7 +22,6 @@ import ( "encoding/json" "errors" "fmt" - "log" "github.com/minio/console/pkg/http" @@ -150,7 +149,6 @@ func ParseLicense(client http.ClientI, license string) (*licverifier.LicenseInfo subnetPubKey, err := downloadSubnetPublicKey(client) if err != nil { - log.Print(err) // there was an issue getting the subnet public key // use hardcoded public keys instead publicKeys = OfflinePublicKeys diff --git a/restapi/configure_console.go b/restapi/configure_console.go index 39fab692a..698bfba83 100644 --- a/restapi/configure_console.go +++ b/restapi/configure_console.go @@ -372,20 +372,23 @@ func handleSPA(w http.ResponseWriter, r *http.Request) { sf.ObjectBrowser = true err := ValidateEncodedStyles(overridenStyles) - if err != nil { - log.Println(err) - } else { - sf.CustomStyleOB = overridenStyles + http.Error(w, err.Error(), http.StatusInternalServerError) + return } + sf.CustomStyleOB = overridenStyles + sessionID, err := login(consoleCreds, sf) if err != nil { - log.Println(err) - } else { - cookie := NewSessionCookieForConsole(*sessionID) - http.SetCookie(w, &cookie) + http.Error(w, err.Error(), http.StatusInternalServerError) + return } + + cookie := NewSessionCookieForConsole(*sessionID) + + http.SetCookie(w, &cookie) + // Allow us to be iframed w.Header().Del("X-Frame-Options") }