mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-18 02:50:30 +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 (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -254,7 +253,6 @@ func (vc *vaultConnection) initConnection(config map[string]interface{}) error {
|
|||||||
// initCertificates sets VAULT_* environment variables in the vc.vaultConfig map,
|
// initCertificates sets VAULT_* environment variables in the vc.vaultConfig map,
|
||||||
// these settings will be used when connecting to the Vault service with
|
// these settings will be used when connecting to the Vault service with
|
||||||
// vc.connectVault().
|
// vc.connectVault().
|
||||||
//
|
|
||||||
func (vc *vaultConnection) initCertificates(config map[string]interface{}, secrets map[string]string) error {
|
func (vc *vaultConnection) initCertificates(config map[string]interface{}, secrets map[string]string) error {
|
||||||
vaultConfig := make(map[string]interface{})
|
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
|
// 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) {
|
func createTempFile(pattern string, data []byte) (string, error) {
|
||||||
t, err := ioutil.TempFile("", pattern)
|
t, err := os.CreateTemp("", pattern)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("failed to create temporary file: %w", err)
|
return "", fmt.Errorf("failed to create temporary file: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/libopenstorage/secrets/vault"
|
"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
|
// linked from the ServiceAccount. This path can then be used in place of the
|
||||||
// standard `/var/run/secrets/kubernetes.io/serviceaccount/token` location.
|
// standard `/var/run/secrets/kubernetes.io/serviceaccount/token` location.
|
||||||
func (kms *vaultTenantSA) getTokenPath() (string, error) {
|
func (kms *vaultTenantSA) getTokenPath() (string, error) {
|
||||||
dir, err := ioutil.TempDir("", kms.tenantSAName)
|
dir, err := os.MkdirTemp("", kms.tenantSAName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("failed to create directory for ServiceAccount %s/%s: %w", kms.tenantSAName, kms.Tenant, err)
|
return "", fmt.Errorf("failed to create directory for ServiceAccount %s/%s: %w", kms.tenantSAName, kms.Tenant, err)
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ package rbd
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@ -252,7 +251,7 @@ func TestStrategicActionOnLogFile(t *testing.T) {
|
|||||||
|
|
||||||
var logFile [3]string
|
var logFile [3]string
|
||||||
for i := 0; i < 3; i++ {
|
for i := 0; i < 3; i++ {
|
||||||
f, err := ioutil.TempFile(tmpDir, "rbd-*.log")
|
f, err := os.CreateTemp(tmpDir, "rbd-*.log")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("creating tempfile failed: %v", err)
|
t.Errorf("creating tempfile failed: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ package util
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -43,7 +42,7 @@ type Credentials struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func storeKey(key string) (string, error) {
|
func storeKey(key string) (string, error) {
|
||||||
tmpfile, err := ioutil.TempFile(tmpKeyFileLocation, tmpKeyFileNamePrefix)
|
tmpfile, err := os.CreateTemp(tmpKeyFileLocation, tmpKeyFileNamePrefix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("error creating a temporary keyfile: %w", err)
|
return "", fmt.Errorf("error creating a temporary keyfile: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ package log
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@ -28,7 +27,7 @@ import (
|
|||||||
func TestGzipLogFile(t *testing.T) {
|
func TestGzipLogFile(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
tmpDir := t.TempDir()
|
tmpDir := t.TempDir()
|
||||||
logFile, err := ioutil.TempFile(tmpDir, "rbd-*.log")
|
logFile, err := os.CreateTemp(tmpDir, "rbd-*.log")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user