From df7841113e3a17585afaf0bc1f446b2008594f4a Mon Sep 17 00:00:00 2001 From: Yuan Chen Date: Thu, 9 May 2024 18:39:39 -0700 Subject: [PATCH] Fix golint errors Signed-off-by: Yuan Chen --- pkg/config/config.go | 1 + pkg/utils/k8s_config_test.go | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 8154cb4..956f87c 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -55,6 +55,7 @@ func New(data []byte) (*TaskConfig, error) { // NewFromFile populates test config from YAML file func NewFromFile(path string) (*TaskConfig, error) { + path = filepath.Clean(path) data, err := os.ReadFile(path) if err != nil { return nil, err diff --git a/pkg/utils/k8s_config_test.go b/pkg/utils/k8s_config_test.go index 3ef40b7..6eb0cff 100644 --- a/pkg/utils/k8s_config_test.go +++ b/pkg/utils/k8s_config_test.go @@ -110,11 +110,11 @@ func TestGetK8sConfig(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - os.Unsetenv("KUBECONFIG") + _ = os.Unsetenv("KUBECONFIG") if len(tc.envCfg) != 0 { f, err := os.CreateTemp("", "test") require.NoError(t, err) - defer os.Remove(f.Name()) + defer func() { _ = os.Remove(f.Name()) }() _, err = f.Write([]byte(tc.envCfg)) require.NoError(t, err) @@ -127,7 +127,7 @@ func TestGetK8sConfig(t *testing.T) { if len(tc.kubeCfg) != 0 { f, err := os.CreateTemp("", "test") require.NoError(t, err) - defer os.Remove(f.Name()) + defer func() { _ = os.Remove(f.Name()) }() _, err = f.Write([]byte(tc.kubeCfg)) require.NoError(t, err)