mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-09 16:00:22 +00:00
cleanup: fix static checks
fix SA1019 static check to replace io/utils with os package Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
8ccf6a805d
commit
e9e33fb851
@ -19,7 +19,6 @@ package kms
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
@ -254,7 +253,6 @@ func (vc *vaultConnection) initConnection(config map[string]interface{}) error {
|
||||
// initCertificates sets VAULT_* environment variables in the vc.vaultConfig map,
|
||||
// these settings will be used when connecting to the Vault service with
|
||||
// vc.connectVault().
|
||||
//
|
||||
func (vc *vaultConnection) initCertificates(config map[string]interface{}, secrets map[string]string) error {
|
||||
vaultConfig := make(map[string]interface{})
|
||||
|
||||
@ -481,9 +479,9 @@ func detectAuthMountPath(path string) (string, error) {
|
||||
}
|
||||
|
||||
// createTempFile writes data to a temporary file that contains the pattern in
|
||||
// the filename (see ioutil.TempFile for details).
|
||||
// the filename (see os.CreateTemp for details).
|
||||
func createTempFile(pattern string, data []byte) (string, error) {
|
||||
t, err := ioutil.TempFile("", pattern)
|
||||
t, err := os.CreateTemp("", pattern)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to create temporary file: %w", err)
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/libopenstorage/secrets/vault"
|
||||
@ -321,7 +320,7 @@ func (kms *vaultTenantSA) getToken() (string, error) {
|
||||
// linked from the ServiceAccount. This path can then be used in place of the
|
||||
// standard `/var/run/secrets/kubernetes.io/serviceaccount/token` location.
|
||||
func (kms *vaultTenantSA) getTokenPath() (string, error) {
|
||||
dir, err := ioutil.TempDir("", kms.tenantSAName)
|
||||
dir, err := os.MkdirTemp("", kms.tenantSAName)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to create directory for ServiceAccount %s/%s: %w", kms.tenantSAName, kms.Tenant, err)
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ package rbd
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
@ -252,7 +251,7 @@ func TestStrategicActionOnLogFile(t *testing.T) {
|
||||
|
||||
var logFile [3]string
|
||||
for i := 0; i < 3; i++ {
|
||||
f, err := ioutil.TempFile(tmpDir, "rbd-*.log")
|
||||
f, err := os.CreateTemp(tmpDir, "rbd-*.log")
|
||||
if err != nil {
|
||||
t.Errorf("creating tempfile failed: %v", err)
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ package util
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
)
|
||||
|
||||
@ -43,7 +42,7 @@ type Credentials struct {
|
||||
}
|
||||
|
||||
func storeKey(key string) (string, error) {
|
||||
tmpfile, err := ioutil.TempFile(tmpKeyFileLocation, tmpKeyFileNamePrefix)
|
||||
tmpfile, err := os.CreateTemp(tmpKeyFileLocation, tmpKeyFileNamePrefix)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("error creating a temporary keyfile: %w", err)
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ package log
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
@ -28,7 +27,7 @@ import (
|
||||
func TestGzipLogFile(t *testing.T) {
|
||||
t.Parallel()
|
||||
tmpDir := t.TempDir()
|
||||
logFile, err := ioutil.TempFile(tmpDir, "rbd-*.log")
|
||||
logFile, err := os.CreateTemp(tmpDir, "rbd-*.log")
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user