mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-06 13:26:26 +00:00
Clean up unused variables and functions (#5818)
Signed-off-by: Fish-pro <zechun.chen@daocloud.io>
This commit is contained in:
@@ -69,11 +69,6 @@ func (o *option) bindFlags(flags *pflag.FlagSet) {
|
||||
flags.BoolVar(&o.verbose, "verbose", false, "When it's set to true the debug messages by crashd will be printed during execution. Default value is false.")
|
||||
}
|
||||
|
||||
func (o *option) asCrashdArgs() string {
|
||||
return fmt.Sprintf("output=%s,namespace=%s,basedir=%s,backup=%s,restore=%s,kubeconfig=%s,kubecontext=%s",
|
||||
o.outputPath, o.namespace, o.baseDir, o.backup, o.restore, o.kubeconfigPath, o.kubeContext)
|
||||
}
|
||||
|
||||
func (o *option) asCrashdArgMap() exec.ArgMap {
|
||||
return exec.ArgMap{
|
||||
"cmd": o.currCmd,
|
||||
|
||||
@@ -83,8 +83,6 @@ type CreateOptions struct {
|
||||
Schedule string
|
||||
UseOwnerReferencesInBackup bool
|
||||
Paused bool
|
||||
|
||||
labelSelector *metav1.LabelSelector
|
||||
}
|
||||
|
||||
func NewCreateOptions() *CreateOptions {
|
||||
|
||||
@@ -49,7 +49,6 @@ import (
|
||||
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
|
||||
pkgbackup "github.com/vmware-tanzu/velero/pkg/backup"
|
||||
"github.com/vmware-tanzu/velero/pkg/builder"
|
||||
informers "github.com/vmware-tanzu/velero/pkg/generated/informers/externalversions"
|
||||
"github.com/vmware-tanzu/velero/pkg/metrics"
|
||||
persistencemocks "github.com/vmware-tanzu/velero/pkg/persistence/mocks"
|
||||
"github.com/vmware-tanzu/velero/pkg/plugin/clientmgmt"
|
||||
@@ -60,7 +59,6 @@ import (
|
||||
|
||||
type backupDeletionControllerTestData struct {
|
||||
fakeClient client.Client
|
||||
sharedInformers informers.SharedInformerFactory
|
||||
volumeSnapshotter *velerotest.FakeVolumeSnapshotter
|
||||
backupStore *persistencemocks.BackupStore
|
||||
controller *backupDeletionReconciler
|
||||
|
||||
@@ -144,18 +144,3 @@ func (c *genericController) processNextWorkItem() bool {
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *genericController) enqueue(obj interface{}) {
|
||||
key, err := cache.MetaNamespaceKeyFunc(obj)
|
||||
if err != nil {
|
||||
c.logger.WithError(errors.WithStack(err)).
|
||||
Error("Error creating queue key, item not added to queue")
|
||||
return
|
||||
}
|
||||
|
||||
c.queue.Add(key)
|
||||
}
|
||||
|
||||
func (c *genericController) enqueueSecond(_, obj interface{}) {
|
||||
c.enqueue(obj)
|
||||
}
|
||||
|
||||
@@ -87,7 +87,6 @@ type testEnvironment struct {
|
||||
Config *rest.Config
|
||||
|
||||
doneMgr context.Context
|
||||
cancel context.CancelFunc
|
||||
}
|
||||
|
||||
// newTestEnvironment creates a new environment spinning up a local api-server.
|
||||
|
||||
@@ -31,7 +31,6 @@ import (
|
||||
type restartableDeleteItemAction struct {
|
||||
key process.KindAndName
|
||||
sharedPluginProcess process.RestartableProcess
|
||||
config map[string]string
|
||||
}
|
||||
|
||||
// NewRestartableDeleteItemAction returns a new restartableDeleteItemAction.
|
||||
|
||||
@@ -51,7 +51,6 @@ func AdaptedRestoreItemActions() []AdaptedRestoreItemAction {
|
||||
type RestartableRestoreItemAction struct {
|
||||
Key process.KindAndName
|
||||
SharedPluginProcess process.RestartableProcess
|
||||
config map[string]string
|
||||
}
|
||||
|
||||
// NewRestartableRestoreItemAction returns a new RestartableRestoreItemAction.
|
||||
|
||||
@@ -59,7 +59,6 @@ func AdaptedRestoreItemActions() []AdaptedRestoreItemAction {
|
||||
type RestartableRestoreItemAction struct {
|
||||
Key process.KindAndName
|
||||
SharedPluginProcess process.RestartableProcess
|
||||
config map[string]string
|
||||
}
|
||||
|
||||
// NewRestartableRestoreItemAction returns a new RestartableRestoreItemAction.
|
||||
|
||||
@@ -233,10 +233,6 @@ ForEachVolume:
|
||||
return podVolumeBackups, errs
|
||||
}
|
||||
|
||||
type pvcGetter interface {
|
||||
Get(ctx context.Context, name string, opts metav1.GetOptions) (*corev1api.PersistentVolumeClaim, error)
|
||||
}
|
||||
|
||||
type pvGetter interface {
|
||||
Get(ctx context.Context, name string, opts metav1.GetOptions) (*corev1api.PersistentVolume, error)
|
||||
}
|
||||
|
||||
@@ -737,17 +737,6 @@ func (ctx *restoreContext) getApplicableActions(groupResource schema.GroupResour
|
||||
return actions
|
||||
}
|
||||
|
||||
func (ctx *restoreContext) getApplicableItemSnapshotters(groupResource schema.GroupResource, namespace string) []framework.ItemSnapshotterResolvedAction {
|
||||
var actions []framework.ItemSnapshotterResolvedAction
|
||||
for _, action := range ctx.itemSnapshotterActions {
|
||||
if action.ShouldUse(groupResource, namespace, nil, ctx.log) {
|
||||
actions = append(actions, action)
|
||||
}
|
||||
}
|
||||
|
||||
return actions
|
||||
}
|
||||
|
||||
func (ctx *restoreContext) shouldRestore(name string, pvClient client.Dynamic) (bool, error) {
|
||||
pvLogger := ctx.log.WithField("pvName", name)
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ import (
|
||||
"sigs.k8s.io/controller-runtime/pkg/client/fake"
|
||||
|
||||
"github.com/vmware-tanzu/velero/pkg/builder"
|
||||
"github.com/vmware-tanzu/velero/pkg/test"
|
||||
velerotest "github.com/vmware-tanzu/velero/pkg/test"
|
||||
)
|
||||
|
||||
@@ -141,21 +140,6 @@ func TestEnsureNamespaceExistsAndIsReady(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
type harness struct {
|
||||
*test.APIServer
|
||||
|
||||
log logrus.FieldLogger
|
||||
}
|
||||
|
||||
func newHarness(t *testing.T) *harness {
|
||||
t.Helper()
|
||||
|
||||
return &harness{
|
||||
APIServer: test.NewAPIServer(t),
|
||||
log: logrus.StandardLogger(),
|
||||
}
|
||||
}
|
||||
|
||||
// TestGetVolumeDirectorySuccess tests that the GetVolumeDirectory function
|
||||
// returns a volume's name or a volume's name plus '/mount' when a PVC is present.
|
||||
func TestGetVolumeDirectorySuccess(t *testing.T) {
|
||||
|
||||
@@ -35,7 +35,6 @@ import (
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
|
||||
"github.com/vmware-tanzu/velero/pkg/cmd/util/flag"
|
||||
. "github.com/vmware-tanzu/velero/test/e2e"
|
||||
@@ -43,8 +42,6 @@ import (
|
||||
|
||||
type AzureStorage string
|
||||
|
||||
const fqdn = "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute"
|
||||
|
||||
const (
|
||||
subscriptionIDConfigKey = "subscriptionId"
|
||||
subscriptionIDEnvVar = "AZURE_SUBSCRIPTION_ID"
|
||||
@@ -54,15 +51,6 @@ const (
|
||||
storageAccount = "storageAccount"
|
||||
subscriptionID = "subscriptionId"
|
||||
resourceGroup = "resourceGroup"
|
||||
|
||||
apiTimeoutConfigKey = "apiTimeout"
|
||||
snapsIncrementalConfigKey = "incremental"
|
||||
|
||||
snapshotsResource = "snapshots"
|
||||
disksResource = "disks"
|
||||
|
||||
resourceGroupConfigKey = "resourceGroup"
|
||||
credentialsFileConfigKey = "credentialsFile"
|
||||
)
|
||||
|
||||
func getStorageCredential(cloudCredentialsFile, bslConfig string) (string, string, error) {
|
||||
@@ -198,23 +186,6 @@ func getRequiredValues(getValue func(string) string, keys ...string) (map[string
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func validateConfigKeys(config map[string]string, validKeys ...string) error {
|
||||
validKeysSet := sets.NewString(validKeys...)
|
||||
|
||||
var invalidKeys []string
|
||||
for k := range config {
|
||||
if !validKeysSet.Has(k) {
|
||||
invalidKeys = append(invalidKeys, k)
|
||||
}
|
||||
}
|
||||
|
||||
if len(invalidKeys) > 0 {
|
||||
return errors.Errorf("config has invalid keys %v; valid keys are %v", invalidKeys, validKeys)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func deleteBlob(p pipeline.Pipeline, accountName, containerName, blobName string) error {
|
||||
ctx := context.Background()
|
||||
|
||||
@@ -311,11 +282,6 @@ func (s AzureStorage) DeleteObjectsInBucket(cloudCredentialsFile, bslBucket, bsl
|
||||
return nil
|
||||
}
|
||||
|
||||
func mapLookup(data map[string]string) func(string) string {
|
||||
return func(key string) string {
|
||||
return data[key]
|
||||
}
|
||||
}
|
||||
func (s AzureStorage) IsSnapshotExisted(cloudCredentialsFile, bslConfig, backupName string, snapshotCheck SnapshotCheckPoint) error {
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
Reference in New Issue
Block a user