mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-03 14:47:08 +00:00
golangci-lint: use exclude-rules instead of skip-files and skip-dirs
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
@@ -58,7 +58,6 @@ func BackupRestoreRetainedPVWithRestic() {
|
||||
}
|
||||
|
||||
func BackupRestoreTest(backupRestoreTestConfig BackupRestoreTestConfig) {
|
||||
|
||||
var (
|
||||
backupName, restoreName, kibishiiNamespace string
|
||||
err error
|
||||
|
||||
@@ -73,7 +73,6 @@ func BackupsSyncTest() {
|
||||
Expect(VeleroUninstall(ctx, veleroCfg.VeleroCLI, veleroCfg.VeleroNamespace)).To(Succeed())
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
It("Backups in object storage should be synced to a new Velero successfully", func() {
|
||||
|
||||
@@ -51,7 +51,6 @@ func (b *TTL) Init() {
|
||||
b.backupName = "backup-ttl-test-" + UUIDgen.String()
|
||||
b.restoreName = "restore-ttl-test-" + UUIDgen.String()
|
||||
b.ttl = 10 * time.Minute
|
||||
|
||||
}
|
||||
|
||||
func TTLTest() {
|
||||
@@ -159,7 +158,6 @@ func TTLTest() {
|
||||
veleroCfg.CloudCredentialsFile, veleroCfg.BSLBucket,
|
||||
veleroCfg.BSLPrefix, veleroCfg.BSLConfig, test.restoreName,
|
||||
RestoreObjectsPrefix)).NotTo(HaveOccurred(), "Fail to get restore object")
|
||||
|
||||
})
|
||||
|
||||
By("Check TTL was set correctly", func() {
|
||||
@@ -198,7 +196,6 @@ func TTLTest() {
|
||||
veleroCfg.CloudCredentialsFile, veleroCfg.BSLBucket,
|
||||
veleroCfg.BSLPrefix, veleroCfg.BSLConfig, test.restoreName,
|
||||
RestoreObjectsPrefix, 5)).NotTo(HaveOccurred(), "Fail to get restore object")
|
||||
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -91,7 +91,6 @@ func APIExtensionsVersionsTest() {
|
||||
veleroCfg.ClientToInstallVelero = veleroCfg.DefaultClient
|
||||
})
|
||||
}
|
||||
|
||||
})
|
||||
Context("When EnableAPIGroupVersions flag is set", func() {
|
||||
It("Enable API Group to B/R CRD APIExtensionsVersions", func() {
|
||||
|
||||
@@ -238,7 +238,6 @@ func runEnableAPIGroupVersionsTests(ctx context.Context, client TestClient, grou
|
||||
fmt.Println(errors.Wrapf(err, "failed to delete crd %q", crdName))
|
||||
}
|
||||
}(fmt.Sprintf("rockband%ds.music.example.io.%d", i, i))
|
||||
|
||||
}
|
||||
|
||||
time.Sleep(6 * time.Minute)
|
||||
@@ -328,7 +327,6 @@ func runEnableAPIGroupVersionsTests(ctx context.Context, client TestClient, grou
|
||||
)
|
||||
return errors.New(msg)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -465,7 +463,6 @@ func resourceInfo(ctx context.Context, g, v, r string, index int) (map[string]ma
|
||||
// are found in the haystack argument values.
|
||||
func containsAll(haystack, needles map[string]string) bool {
|
||||
for nkey, nval := range needles {
|
||||
|
||||
hval, ok := haystack[nkey]
|
||||
if !ok {
|
||||
return false
|
||||
|
||||
@@ -83,7 +83,6 @@ func (s *StorageClasssChanging) CreateResources() error {
|
||||
})
|
||||
|
||||
By(fmt.Sprintf("Create a deployment in namespace %s", s.VeleroCfg.VeleroNamespace), func() {
|
||||
|
||||
pvc, err := CreatePVC(s.Client, s.namespace, s.pvcName, s.srcStorageClass, nil)
|
||||
Expect(err).To(Succeed())
|
||||
vols := CreateVolumes(pvc.Name, []string{s.volume})
|
||||
|
||||
@@ -321,7 +321,6 @@ func BslDeletionTest(useVolumeSnapshots bool) {
|
||||
var snapshotCheckPoint SnapshotCheckPoint
|
||||
snapshotCheckPoint.NamespaceBackedUp = bslDeletionTestNs
|
||||
By(fmt.Sprintf("Snapshot should not be deleted in cloud object store after deleting bsl %s", backupLocation_1), func() {
|
||||
|
||||
snapshotCheckPoint, err = GetSnapshotCheckPoint(*veleroCfg.ClientToInstallVelero, veleroCfg, 1, bslDeletionTestNs, backupName_1, []string{podName_1})
|
||||
Expect(err).NotTo(HaveOccurred(), "Fail to get Azure CSI snapshot checkpoint")
|
||||
Expect(SnapshotsShouldBeCreatedInCloud(veleroCfg.CloudProvider,
|
||||
|
||||
@@ -101,7 +101,6 @@ func init() {
|
||||
flag.StringVar(&VeleroCfg.EKSPolicyARN, "eks-policy-arn", "", "EKS plicy ARN for creating AWS IAM service account.")
|
||||
flag.StringVar(&VeleroCfg.DefaultCLSServiceAccountName, "default-cls-service-account-name", "", "default cluster service account name.")
|
||||
flag.StringVar(&VeleroCfg.StandbyCLSServiceAccountName, "standby-cls-service-account-name", "", "standby cluster service account name.")
|
||||
|
||||
}
|
||||
|
||||
// Add label [SkipVanillaZfs]:
|
||||
|
||||
@@ -108,7 +108,6 @@ func MigrationTest(useVolumeSnapshots bool, veleroCLI2Version VeleroCLI2Version)
|
||||
veleroCfg.ClusterToInstallVelero = veleroCfg.DefaultClusterName
|
||||
})
|
||||
}
|
||||
|
||||
})
|
||||
When("kibishii is the sample workload", func() {
|
||||
It("should be successfully backed up and restored to the default BackupStorageLocation", func() {
|
||||
|
||||
@@ -55,7 +55,6 @@ func (p *PVBackupFiltering) Init() error {
|
||||
// annotation will be ignored, so it's only set for opt-out test
|
||||
if p.annotation == OPT_OUT_ANN {
|
||||
p.BackupArgs = append(p.BackupArgs, "--default-volumes-to-fs-backup")
|
||||
|
||||
}
|
||||
p.RestoreArgs = []string{
|
||||
"create", "--namespace", p.VeleroCfg.VeleroNamespace, "restore", p.RestoreName,
|
||||
|
||||
@@ -90,7 +90,6 @@ func (e *ExcludeNamespaces) Init() error {
|
||||
"create", "--namespace", e.VeleroCfg.VeleroNamespace, "restore", e.RestoreName,
|
||||
"--from-backup", e.BackupName, "--wait",
|
||||
}
|
||||
|
||||
} else {
|
||||
*e.NSIncluded = append(*e.NSIncluded, *e.nsExcluded...)
|
||||
e.BackupArgs = []string{
|
||||
|
||||
@@ -79,7 +79,6 @@ func (i *IncludeNamespaces) Init() error {
|
||||
"create", "--namespace", i.VeleroCfg.VeleroNamespace, "restore", i.RestoreName,
|
||||
"--from-backup", i.BackupName, "--wait",
|
||||
}
|
||||
|
||||
} else {
|
||||
i.BackupName = "backup-" + i.UUIDgen
|
||||
i.RestoreName = "restore-" + i.CaseBaseName
|
||||
|
||||
@@ -177,7 +177,6 @@ func (r *ResourcePoliciesCase) Verify() error {
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -200,7 +200,6 @@ func (n *ScheduleBackup) Verify() error {
|
||||
fmt.Printf("Restored configmap is %v\n", configmap)
|
||||
Expect(err).ShouldNot(HaveOccurred(), fmt.Sprintf("failed to list configmap in namespace: %q\n", ns))
|
||||
}
|
||||
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -123,7 +123,6 @@ func BackupUpgradeRestoreTest(useVolumeSnapshots bool, veleroCLI2Version VeleroC
|
||||
veleroCfg.GCFrequency = ""
|
||||
By(fmt.Sprintf("Install the expected old version Velero (%s) for upgrade",
|
||||
veleroCLI2Version.VeleroVersion), func() {
|
||||
|
||||
//Set VeleroImage and RestoreHelperImage to blank
|
||||
//VeleroImage and RestoreHelperImage should be the default value in originalCli
|
||||
tmpCfgForOldVeleroInstall := veleroCfg
|
||||
@@ -230,7 +229,6 @@ func BackupUpgradeRestoreTest(useVolumeSnapshots bool, veleroCLI2Version VeleroC
|
||||
}
|
||||
|
||||
By(fmt.Sprintf("Upgrade Velero by CLI %s", tmpCfg.VeleroCLI), func() {
|
||||
|
||||
tmpCfg.GCFrequency = ""
|
||||
tmpCfg.UseRestic = false
|
||||
tmpCfg.UseNodeAgent = !useVolumeSnapshots
|
||||
|
||||
@@ -130,7 +130,6 @@ func (c VeleroConfig) Colorized() bool {
|
||||
}
|
||||
|
||||
return colorized
|
||||
|
||||
}
|
||||
|
||||
func (c VeleroConfig) CACertFile() string {
|
||||
|
||||
@@ -114,7 +114,6 @@ func (d *DeploymentBuilder) WithVolume(volumes []*v1.Volume) *DeploymentBuilder
|
||||
MountPath: "/" + v.Name,
|
||||
})
|
||||
d.Spec.Template.Spec.Volumes = append(d.Spec.Template.Spec.Volumes, *v)
|
||||
|
||||
}
|
||||
|
||||
// NOTE here just mount volumes to the first container
|
||||
|
||||
@@ -28,7 +28,6 @@ import (
|
||||
)
|
||||
|
||||
func CreatePersistentVolume(client TestClient, name string) (*corev1.PersistentVolume, error) {
|
||||
|
||||
p := &corev1.PersistentVolume{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: name,
|
||||
|
||||
@@ -107,7 +107,6 @@ func GetPod(ctx context.Context, client TestClient, namespace string, pod string
|
||||
}
|
||||
|
||||
func AddAnnotationToPod(ctx context.Context, client TestClient, namespace, podName string, ann map[string]string) (*corev1.Pod, error) {
|
||||
|
||||
newPod, err := GetPod(ctx, client, namespace, podName)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, fmt.Sprintf("Fail to ge pod %s in namespace %s", podName, namespace))
|
||||
|
||||
@@ -76,7 +76,6 @@ func GetClusterRoleBinding(ctx context.Context, client TestClient, rolebinding s
|
||||
}
|
||||
|
||||
func CleanupClusterRole(ctx context.Context, client TestClient, CaseBaseName string) error {
|
||||
|
||||
clusterroles, err := client.ClientGo.RbacV1().ClusterRoles().List(ctx, metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Could not retrieve clusterroles")
|
||||
@@ -95,7 +94,6 @@ func CleanupClusterRole(ctx context.Context, client TestClient, CaseBaseName str
|
||||
}
|
||||
|
||||
func CleanupClusterRoleBinding(ctx context.Context, client TestClient, CaseBaseName string) error {
|
||||
|
||||
clusterrolebindings, err := client.ClientGo.RbacV1().ClusterRoleBindings().List(ctx, metav1.ListOptions{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Could not retrieve clusterrolebindings")
|
||||
|
||||
@@ -128,7 +128,6 @@ func newS3Client(cfg aws.Config, url string, forcePathStyle bool) (*s3.Client, e
|
||||
// GetBucketRegion returns the AWS region that a bucket is in, or an error
|
||||
// if the region cannot be determined.
|
||||
func GetBucketRegion(bucket string) (string, error) {
|
||||
|
||||
cfg, err := config.LoadDefaultConfig(context.Background())
|
||||
if err != nil {
|
||||
return "", errors.WithStack(err)
|
||||
|
||||
@@ -270,7 +270,6 @@ func (s AzureStorage) DeleteObjectsInBucket(cloudCredentialsFile, bslBucket, bsl
|
||||
|
||||
marker = listBlob.NextMarker
|
||||
for _, blobInfo := range listBlob.Segment.BlobItems {
|
||||
|
||||
if strings.Contains(blobInfo.Name, bslPrefix+backupObject+"/") {
|
||||
deleteBlob(p, accountName, containerName, blobInfo.Name)
|
||||
if err != nil {
|
||||
@@ -284,7 +283,6 @@ func (s AzureStorage) DeleteObjectsInBucket(cloudCredentialsFile, bslBucket, bsl
|
||||
}
|
||||
|
||||
func (s AzureStorage) IsSnapshotExisted(cloudCredentialsFile, bslConfig, backupName string, snapshotCheck SnapshotCheckPoint) error {
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
if err := loadCredentialsIntoEnv(cloudCredentialsFile); err != nil {
|
||||
|
||||
@@ -173,7 +173,6 @@ func getPluginsByVersion(version, cloudProvider, objectStoreProvider, feature st
|
||||
plugins = append(plugins, pluginsForDatamover...)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return plugins, nil
|
||||
}
|
||||
@@ -181,7 +180,6 @@ func getPluginsByVersion(version, cloudProvider, objectStoreProvider, feature st
|
||||
// getProviderVeleroInstallOptions returns Velero InstallOptions for the provider.
|
||||
func getProviderVeleroInstallOptions(veleroCfg *VeleroConfig,
|
||||
plugins []string) (*cliinstall.Options, error) {
|
||||
|
||||
if veleroCfg.CloudCredentialsFile == "" && veleroCfg.ServiceAccountNameToInstall == "" {
|
||||
return nil, errors.Errorf("No credentials were supplied to use for E2E tests")
|
||||
}
|
||||
@@ -1184,7 +1182,6 @@ func DeleteBslResource(ctx context.Context, veleroCLI string, bslName string) er
|
||||
}
|
||||
|
||||
func SnapshotCRsCountShouldBe(ctx context.Context, namespace, backupName string, expectedCount int) error {
|
||||
|
||||
checkSnapshotCmd := exec.CommandContext(ctx, "kubectl",
|
||||
"get", "-n", namespace, "snapshots.backupdriver.cnsdp.vmware.com", "-o=jsonpath='{range .items[*]}{.metadata.labels.velero\\.io\\/backup-name}{\"\\n\"}{end}'")
|
||||
fmt.Printf("checkSnapshotCmd cmd =%v\n", checkSnapshotCmd)
|
||||
@@ -1603,7 +1600,6 @@ func InstallTestStorageClasses(path string) error {
|
||||
}
|
||||
|
||||
func GetPvName(ctx context.Context, client TestClient, pvcName, namespace string) (string, error) {
|
||||
|
||||
pvcList, err := GetPvcByPVCName(context.Background(), namespace, pvcName)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -1622,7 +1618,6 @@ func GetPvName(ctx context.Context, client TestClient, pvcName, namespace string
|
||||
}
|
||||
|
||||
return pvList[0], nil
|
||||
|
||||
}
|
||||
func DeletePVs(ctx context.Context, client TestClient, pvList []string) error {
|
||||
for _, pv := range pvList {
|
||||
@@ -1637,7 +1632,6 @@ func DeletePVs(ctx context.Context, client TestClient, pvList []string) error {
|
||||
}
|
||||
|
||||
func CleanAllRetainedPV(ctx context.Context, client TestClient) {
|
||||
|
||||
pvNameList, err := GetAllPVNames(ctx, client)
|
||||
if err != nil {
|
||||
fmt.Println("fail to list PV")
|
||||
|
||||
Reference in New Issue
Block a user