Remove github.com/pkg/errors with appropriate replacements (#3172)
* errors.Wrap* removal Signed-off-by: Sanket Sudake <sanketsudake@gmail.com> * remove errors.Errorf Signed-off-by: Sanket Sudake <sanketsudake@gmail.com> * Remove remaining calls Signed-off-by: Sanket Sudake <sanketsudake@gmail.com> * Few more errors Signed-off-by: Sanket Sudake <sanketsudake@gmail.com> * Fix golint errors Signed-off-by: Sanket Sudake <sanketsudake@gmail.com> --------- Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
@@ -29,7 +29,6 @@ import (
|
||||
"time"
|
||||
|
||||
influxdbClient "github.com/influxdata/influxdb/client/v2"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
ferror "github.com/fission/fission/pkg/error"
|
||||
"github.com/fission/fission/pkg/fission-cli/util"
|
||||
@@ -153,12 +152,12 @@ func (influx InfluxDB) GetLogs(ctx context.Context, filter LogFilter, output *by
|
||||
msg := fmt.Sprintf("Timestamp: %s\nNamespace: %s\nFunction Name: %s\nFunction ID: %s\nPod: %s\nContainer: %s\nStream: %s\nLog: %s\n---\n",
|
||||
logEntry.Timestamp, logEntry.Namespace, logEntry.FuncName, logEntry.FuncUid, logEntry.Pod, logEntry.Container, logEntry.Stream, logEntry.Message)
|
||||
if _, err := output.WriteString(msg); err != nil {
|
||||
return errors.Wrapf(err, "error copying pod log")
|
||||
return fmt.Errorf("error copying pod log: %w", err)
|
||||
}
|
||||
} else {
|
||||
msg := fmt.Sprintf("[%s] %s\n", logEntry.Timestamp, logEntry.Message)
|
||||
if _, err := output.WriteString(msg); err != nil {
|
||||
return errors.Wrapf(err, "error copying pod log")
|
||||
return fmt.Errorf("error copying pod log: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -173,7 +172,7 @@ func (influx InfluxDB) query(ctx context.Context, query influxdbClient.Query) (*
|
||||
|
||||
req, err := http.NewRequest(http.MethodPost, influx.endpoint, nil)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "error creating request for log proxy")
|
||||
return nil, fmt.Errorf("error creating request for log proxy: %w", err)
|
||||
}
|
||||
req.SetBasicAuth(username, password)
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@ import (
|
||||
"sort"
|
||||
"strconv"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
@@ -85,7 +84,7 @@ func GetFunctionPodLogs(ctx context.Context, client cmd.Client, logFilter LogFil
|
||||
}
|
||||
|
||||
if len(podList.Items) <= 0 {
|
||||
return errors.Errorf("no active pods found for function in namespace %s", podNs)
|
||||
return fmt.Errorf("no active pods found for function in namespace %s", podNs)
|
||||
}
|
||||
|
||||
pods := podList.Items
|
||||
@@ -94,7 +93,7 @@ func GetFunctionPodLogs(ctx context.Context, client cmd.Client, logFilter LogFil
|
||||
// get the pod with highest resource version
|
||||
err = streamContainerLog(ctx, client.KubernetesClient, &pod, logFilter, podLogs)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error getting container logs")
|
||||
return fmt.Errorf("error getting container logs: %w", err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -108,7 +107,7 @@ func GetFunctionPodLogs(ctx context.Context, client cmd.Client, logFilter LogFil
|
||||
// get the pod with highest resource version
|
||||
err = streamContainerLog(ctx, client.KubernetesClient, &pods[0], logFilter, podLogs)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error getting container logs")
|
||||
return fmt.Errorf("error getting container logs: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +131,7 @@ func streamContainerLog(ctx context.Context, kubernetesClient kubernetes.Interfa
|
||||
|
||||
podLogs, err := podLogsReq.Stream(ctx)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error streaming pod log")
|
||||
return fmt.Errorf("error streaming pod log: %w", err)
|
||||
}
|
||||
|
||||
if logFilter.Details {
|
||||
@@ -140,13 +139,13 @@ func streamContainerLog(ctx context.Context, kubernetesClient kubernetes.Interfa
|
||||
msg := fmt.Sprintf("\n=== Function=%s Environment=%s Namespace=%s Pod=%s Container=%s Node=%s\n",
|
||||
fn.ObjectMeta.Name, fn.Spec.Environment.Name, pod.Namespace, pod.Name, container.Name, pod.Spec.NodeName)
|
||||
if _, err := output.WriteString(msg); err != nil {
|
||||
return errors.Wrapf(err, "error copying pod log")
|
||||
return fmt.Errorf("error copying pod log: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
_, err = io.Copy(output, podLogs)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error copying pod log")
|
||||
return fmt.Errorf("error copying pod log: %w", err)
|
||||
}
|
||||
|
||||
podLogs.Close()
|
||||
|
||||
Reference in New Issue
Block a user