mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-08-24 16:16:09 +00:00
Fix linter issues in secret utilities
- Fix import ordering in test file (gofmt) - Add nolint:gosec for BackupPVCSecretLabel constant (not a credential) - Use assert.Error instead of assert.True(err != nil) (testifylint) Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
This commit is contained in:
@@ -58,7 +58,7 @@ func GetSecretKey(client kbclient.Client, namespace string, selector *corev1api.
|
||||
const (
|
||||
// BackupPVCSecretLabel is the label applied to secrets copied to the Velero namespace
|
||||
// for backup PVC provisioning. The value is the owning DataUpload name.
|
||||
BackupPVCSecretLabel = "velero.io/backup-pvc-secret"
|
||||
BackupPVCSecretLabel = "velero.io/backup-pvc-secret" //nolint:gosec // not a credential
|
||||
)
|
||||
|
||||
// ErrSecretCollision is returned when a secret with the same name but different data
|
||||
|
||||
@@ -25,8 +25,8 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
corev1api "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/kubernetes/fake"
|
||||
k8sruntime "k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/client-go/kubernetes/fake"
|
||||
)
|
||||
|
||||
func TestCopySecret(t *testing.T) {
|
||||
@@ -146,7 +146,7 @@ func TestDeleteSecretIfAny(t *testing.T) {
|
||||
|
||||
_, err := fakeClient.CoreV1().Secrets("velero").Get(
|
||||
context.Background(), "test-secret", metav1.GetOptions{})
|
||||
assert.True(t, err != nil)
|
||||
assert.Error(t, err)
|
||||
})
|
||||
|
||||
t.Run("no error when secret does not exist", func(t *testing.T) {
|
||||
@@ -178,7 +178,7 @@ func TestDeleteSecretsWithLabel(t *testing.T) {
|
||||
|
||||
_, err := fakeClient.CoreV1().Secrets("velero").Get(
|
||||
context.Background(), "secret-1", metav1.GetOptions{})
|
||||
assert.True(t, err != nil, "secret-1 should be deleted")
|
||||
require.Error(t, err, "secret-1 should be deleted")
|
||||
|
||||
_, err = fakeClient.CoreV1().Secrets("velero").Get(
|
||||
context.Background(), "secret-2", metav1.GetOptions{})
|
||||
|
||||
Reference in New Issue
Block a user