Update staticcheck version and fix all warnings (#1381)

This commit is contained in:
Ta-Ching Chen
2019-11-05 18:09:12 +08:00
committed by GitHub
parent 93d4b88d84
commit b9a5588ca9
43 changed files with 122 additions and 219 deletions
+1 -2
View File
@@ -53,7 +53,6 @@ type (
builderManagerUrl string
workflowApiUrl string
functionNamespace string
useIstio bool
featureStatus map[string]string
}
@@ -167,7 +166,7 @@ func (api *API) getLogDBConfig(dbType string) logDBConfig {
func (api *API) HomeHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=utf-8")
fmt.Fprintf(w, info.ApiInfo().String())
w.Write([]byte(info.ApiInfo().String()))
}
func (api *API) ApiVersionMismatchHandler(w http.ResponseWriter, r *http.Request) {
+3 -3
View File
@@ -20,13 +20,13 @@ import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"net/http"
"strings"
"time"
"github.com/pkg/errors"
"golang.org/x/net/context/ctxhttp"
ferror "github.com/fission/fission/pkg/error"
@@ -58,9 +58,9 @@ func (c *Client) delete(relativeUrl string) error {
if resp.StatusCode != 200 {
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return errors.New("Delete failed")
return errors.Wrap(err, "error deleting")
} else {
return errors.New("Delete failed: " + string(body))
return errors.Errorf("failed to delete: %v", string(body))
}
}
+3 -1
View File
@@ -22,6 +22,8 @@ import (
"io/ioutil"
"net/http"
"github.com/pkg/errors"
apiv1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
@@ -84,7 +86,7 @@ func (c *Client) GetSvcURL(label string) (string, error) {
}
if resp == nil {
return "", fmt.Errorf("Failed to find service for given label: %v", label)
return "", errors.Errorf("failed to find service for given label: %v", label)
}
defer resp.Body.Close()
+1 -8
View File
@@ -106,12 +106,6 @@ func RegisterFunctionRoute(ws *restful.WebService) {
Returns(http.StatusOK, "Only HTTP status returned", nil))
}
func (a *API) getIstioServiceLabels(fnName string) map[string]string {
return map[string]string{
"functionName": fnName,
}
}
func (a *API) FunctionApiList(w http.ResponseWriter, r *http.Request) {
ns := a.extractQueryParamFromRequest(r, "namespace")
if len(ns) == 0 {
@@ -325,7 +319,7 @@ func (a *API) FunctionPodLogs(w http.ResponseWriter, r *http.Request) {
if len(pods) > 0 {
podLogsReq = a.kubernetesClient.CoreV1().Pods(ns).GetLogs(pods[0].ObjectMeta.Name, &podLogOpts)
} else {
a.respondWithError(w, errors.New("No active pods found"))
a.respondWithError(w, errors.New("no active pods found"))
return
}
@@ -341,5 +335,4 @@ func (a *API) FunctionPodLogs(w http.ResponseWriter, r *http.Request) {
a.respondWithError(w, err)
return
}
return
}