Skip to content

Commit

Permalink
fix: lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mhrabovcin committed Apr 13, 2023
1 parent c1c66d8 commit f04d048
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 22 deletions.
3 changes: 2 additions & 1 deletion pkg/bundle/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import (
"fmt"
"strings"

"github.com/mhrabovcin/troubleshoot-live/pkg/utils"
"github.com/spf13/afero"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/yaml"

"github.com/mhrabovcin/troubleshoot-live/pkg/utils"
)

// LoadResourcesFromFile tries to k8s API resources from a given file. It supports
Expand Down
21 changes: 2 additions & 19 deletions pkg/proxy/rewrite.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func readResponseBody(r *http.Response) ([]byte, error) {
return nil, err
}
}
defer r.Body.Close()

return io.ReadAll(reader)
}
Expand All @@ -105,7 +106,6 @@ func writeResponseBody(r *http.Response, data []byte) error {
if err != nil {
return err
}

gzipWriter.Close()
data = gzipped.Bytes()
}
Expand All @@ -123,26 +123,9 @@ func remapFields(in runtime.Object, rr rewriter.ResourceRewriter) error {

u, ok := in.(*unstructured.Unstructured)
if !ok {
// TODO(mh):
// TODO(mh): handle non-unstructured objects
return nil
}

return rr.BeforeServing(u)
// o, err := meta.Accessor(in)
// if err != nil {
// return err
// }
// annotations := o.GetAnnotations()
// if originalTime, ok := annotations[importer.AnnotationForOriginalValue("creationTimestamp")]; ok {
// parsedTime, err := time.Parse(time.RFC3339, originalTime)
// if err != nil {
// return nil
// }
// o.SetCreationTimestamp(metav1.NewTime(parsedTime))
// delete(annotations, importer.AnnotationForOriginalValue("creationTimestamp"))
// log.Printf("[%s] %s/%s: resource creationTimestamp modified\n", in.GetObjectKind().GroupVersionKind(), o.GetNamespace(), o.GetName())
// }
// o.SetAnnotations(annotations)

// return nil
}
4 changes: 3 additions & 1 deletion pkg/proxy/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ func New(cfg *rest.Config, b bundle.Bundle, rr rewriter.ResourceRewriter) http.H
if err != nil {
log.Fatalln(err)
}
proxyHandler.ModifyResponse = proxyModifyResponse(rr)
// disable bodyclose linting as it seems like false positive
// https://github.com/timakin/bodyclose/issues/42
proxyHandler.ModifyResponse = proxyModifyResponse(rr) //nolint:bodyclose // false positive

r := mux.NewRouter()
r.Handle("/api/v1/namespaces/{namespace}/pods/{pod}/log", LogsHandler(b))
Expand Down
3 changes: 2 additions & 1 deletion pkg/utils/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"errors"
"testing"

"github.com/mhrabovcin/troubleshoot-live/pkg/utils"
"github.com/stretchr/testify/assert"

"github.com/mhrabovcin/troubleshoot-live/pkg/utils"
)

func TestMaxErrorString(t *testing.T) {
Expand Down

0 comments on commit f04d048

Please sign in to comment.