diff --git a/nogo_config.json b/nogo_config.json index 4439b57a8fb1..ee4e3581db61 100644 --- a/nogo_config.json +++ b/nogo_config.json @@ -154,7 +154,6 @@ "tests/network/": "tests/network/ pkg does not pass errcheck yet", "tests/reporter/": "tests/reporter pkg does not pass errcheck yet", "tests/storage/": "tests/storage/ pkg does not pass errcheck yet", - "tests/virtctl/": "tests/virtctl/ pkg does not pass errcheck yet", "tests/canary_upgrade_test.go": "canary_upgrade_test does not pass errcheck yet", "tests/infra_test.go": "infra_test.go does not pass errcheck yet", "tests/kubectl_test.go": "kubectl_test does not pass errcheck yet", diff --git a/tests/virtctl/BUILD.bazel b/tests/virtctl/BUILD.bazel index ed06125aee74..71fd1ad103cf 100644 --- a/tests/virtctl/BUILD.bazel +++ b/tests/virtctl/BUILD.bazel @@ -14,6 +14,7 @@ go_library( "//tests:go_default_library", "//tests/clientcmd:go_default_library", "//tests/console:go_default_library", + "//tests/errorhandling:go_default_library", "//tests/libvmi:go_default_library", "//tests/util:go_default_library", "//vendor/github.com/onsi/ginkgo/v2:go_default_library", diff --git a/tests/virtctl/key.go b/tests/virtctl/key.go index 7dffbbb979b2..1d8f53a74207 100644 --- a/tests/virtctl/key.go +++ b/tests/virtctl/key.go @@ -10,6 +10,8 @@ import ( "os" "golang.org/x/crypto/ssh" + + "kubevirt.io/kubevirt/tests/errorhandling" ) func NewKeyPair() (*ecdsa.PrivateKey, ssh.PublicKey, error) { @@ -37,7 +39,7 @@ func DumpPrivateKey(privateKey *ecdsa.PrivateKey, file string) error { if err != nil { return err } - defer f.Close() + defer errorhandling.SafelyCloseFile(f) if err = pem.Encode(f, privateKeyBlock); err != nil { return fmt.Errorf("error when encode private pem: %s", err)