diff --git a/pkg/executor/kopia/kopiabackup.go b/pkg/executor/kopia/kopiabackup.go index 50284a775..c26699262 100644 --- a/pkg/executor/kopia/kopiabackup.go +++ b/pkg/executor/kopia/kopiabackup.go @@ -35,7 +35,7 @@ var ( bkpNamespace string compression string excludeFileList string - logLevel string + logLevelDebug string ) var ( @@ -70,7 +70,7 @@ func newBackupCommand() *cobra.Command { backupCommand.Flags().StringVar(&sourcePathGlob, "source-path-glob", "", "The regexp should match only one path that will be used for backup") backupCommand.Flags().StringVar(&compression, "compression", "", "Compression type to be used") backupCommand.Flags().StringVar(&excludeFileList, "exclude-file-list", "", " list of dir names that need to be exclude in the kopia snapshot") - backupCommand.Flags().StringVar(&logLevel, "log-level", "", "If debug mode in kopia is to be used") + backupCommand.Flags().StringVar(&logLevelDebug, "log-level", "", "If debug mode in kopia is to be used") return backupCommand } @@ -237,6 +237,7 @@ func runKopiaCreateRepo(repository *executor.Repository) error { kopiaProviderType[repository.Type], repository.S3Config.Region, repository.S3Config.DisableSSL, + logLevelDebug, ) default: repoCreateCmd, err = kopia.GetCreateCommand( @@ -246,6 +247,7 @@ func runKopiaCreateRepo(repository *executor.Repository) error { kopiaProviderType[repository.Type], "", false, + logLevelDebug, ) } if err != nil { @@ -263,7 +265,7 @@ func runKopiaCreateRepo(repository *executor.Repository) error { } initExecutor := kopia.NewCreateExecutor(repoCreateCmd) - if err := initExecutor.Run(logLevel); err != nil { + if err := initExecutor.Run(); err != nil { err = fmt.Errorf("failed to run repository create command: %v", err) return err } @@ -321,6 +323,7 @@ func runKopiaBackup(repository *executor.Repository, sourcePath string) error { repository.Password, string(repository.Type), sourcePath, + logLevelDebug, ) if err != nil { return err @@ -329,7 +332,7 @@ func runKopiaBackup(repository *executor.Repository, sourcePath string) error { // the pod got terminated. Now user triggers another backup, so we need to pass // credentials for "snapshot create". backupExecutor := kopia.NewBackupExecutor(backupCmd) - if err := backupExecutor.Run(logLevel); err != nil { + if err := backupExecutor.Run(); err != nil { err = fmt.Errorf("failed to run backup command: %v", err) return err } @@ -374,6 +377,7 @@ func runKopiaRepositoryConnect(repository *executor.Repository) error { kopiaProviderType[repository.Type], repository.S3Config.Region, repository.S3Config.DisableSSL, + logLevelDebug, ) default: connectCmd, err = kopia.GetConnectCommand( @@ -383,6 +387,7 @@ func runKopiaRepositoryConnect(repository *executor.Repository) error { kopiaProviderType[repository.Type], "", false, + logLevelDebug, ) } if err != nil { @@ -398,7 +403,7 @@ func runKopiaRepositoryConnect(repository *executor.Repository) error { connectCmd = populateAzureccessDetails(connectCmd, repository) } connectExecutor := kopia.NewConnectExecutor(connectCmd) - if err := connectExecutor.Run(logLevel); err != nil { + if err := connectExecutor.Run(); err != nil { err = fmt.Errorf("failed to run repository connect command: %v", err) return err } @@ -428,7 +433,7 @@ func runKopiaRepositoryConnect(repository *executor.Repository) error { func setGlobalPolicy() error { logrus.Infof("Setting global policy") - policyCmd, err := kopia.SetGlobalPolicyCommand() + policyCmd, err := kopia.SetGlobalPolicyCommand(logLevelDebug) if err != nil { return err } @@ -436,7 +441,7 @@ func setGlobalPolicy() error { // for the repository, setting them to very high values policyCmd = addPolicySetting(policyCmd) policyExecutor := kopia.NewSetGlobalPolicyExecutor(policyCmd) - if err := policyExecutor.Run(logLevel); err != nil { + if err := policyExecutor.Run(); err != nil { errMsg := fmt.Sprintf("failed to run setting global policy command: %v", err) logrus.Errorf("%v", errMsg) return fmt.Errorf(errMsg) @@ -481,12 +486,13 @@ func runKopiaExcludeFileList(repository *executor.Repository, sourcePath string) excludeFileListCmd, err := kopia.GetExcludeFileListCommand( sourcePath, excludeFileList, + logLevelDebug, ) if err != nil { return err } excludeFileListExecutor := kopia.NewExcludeFileListExecutor(excludeFileListCmd) - if err := excludeFileListExecutor.Run(logLevel); err != nil { + if err := excludeFileListExecutor.Run(); err != nil { err = fmt.Errorf("failed to run exclude file list command: %v", err) return err } @@ -527,12 +533,13 @@ func runKopiaCompression(repository *executor.Repository, sourcePath string) err compressionCmd, err := kopia.GetCompressionCommand( sourcePath, compression, + logLevelDebug, ) if err != nil { return err } compressionExecutor := kopia.NewCompressionExecutor(compressionCmd) - if err := compressionExecutor.Run(logLevel); err != nil { + if err := compressionExecutor.Run(); err != nil { err = fmt.Errorf("failed to run compression command: %v", err) return err } diff --git a/pkg/executor/kopia/kopiadelete.go b/pkg/executor/kopia/kopiadelete.go index d8b01c935..7eda74ee7 100644 --- a/pkg/executor/kopia/kopiadelete.go +++ b/pkg/executor/kopia/kopiadelete.go @@ -21,7 +21,7 @@ func newDeleteCommand() *cobra.Command { credSecretNamespace string volumeBackupDeleteName string volumeBackupDeleteNamespace string - logLevel string + logLevelDebug string ) deleteCommand := &cobra.Command{ Use: "delete", @@ -35,7 +35,7 @@ func newDeleteCommand() *cobra.Command { deleteCommand.Flags().StringVar(&credSecretNamespace, "cred-secret-namespace", "", "cred secret namespace for kopia backup snapshot that need to be deleted") deleteCommand.Flags().StringVar(&volumeBackupDeleteName, "volume-backup-delete-name", "", "volumeBackupdelete CR name for kopia backup snapshot that need to be deleted") deleteCommand.Flags().StringVar(&volumeBackupDeleteNamespace, "volume-backup-delete-namespace", "", "volumeBackupdelete CR namespace for kopia backup snapshot that need to be deleted") - deleteCommand.Flags().StringVar(&logLevel, "log-level", "", "If debug mode in kopia is to be used") + deleteCommand.Flags().StringVar(&logLevelDebug, "log-level", "", "If debug mode in kopia is to be used") return deleteCommand } @@ -129,6 +129,7 @@ func runKopiaDelete(repository *executor.Repository, snapshotID string) error { logrus.Infof("kopia delete started") deleteCmd, err := kopia.GetDeleteCommand( snapshotID, + logLevelDebug, ) if err != nil { errMsg := fmt.Sprintf("getting delete backup snapshot command for snapshot ID [%v] failed: %v", snapshotID, err) @@ -136,7 +137,7 @@ func runKopiaDelete(repository *executor.Repository, snapshotID string) error { return fmt.Errorf(errMsg) } initExecutor := kopia.NewDeleteExecutor(deleteCmd) - if err := initExecutor.Run(logLevel); err != nil { + if err := initExecutor.Run(); err != nil { errMsg := fmt.Sprintf("running delete backup snapshot command for snapshotID [%v] failed: %v", snapshotID, err) logrus.Errorf("%s %v", fn, errMsg) return fmt.Errorf(errMsg) @@ -164,14 +165,14 @@ func runKopiaSnapshotList(repository *executor.Repository) ([]string, error) { var err error var listCmd *kopia.Command logrus.Infof("Executing kopia snapshot list command") - listCmd, err = kopia.GetListCommand() + listCmd, err = kopia.GetListCommand(logLevelDebug) if err != nil { return nil, err } listExecutor := kopia.NewListExecutor(listCmd) - if err := listExecutor.Run(logLevel); err != nil { + if err := listExecutor.Run(); err != nil { err = fmt.Errorf("failed to run snapshot list command: %v", err) return nil, err } diff --git a/pkg/executor/kopia/maintenance.go b/pkg/executor/kopia/maintenance.go index 72bb17355..4699cf85d 100644 --- a/pkg/executor/kopia/maintenance.go +++ b/pkg/executor/kopia/maintenance.go @@ -38,7 +38,7 @@ func newMaintenanceCommand() *cobra.Command { credSecretName string credSecretNamespace string maintenanceType string - logLevel string + logLevelDebug string ) maintenanceCommand := &cobra.Command{ Use: "maintenance", @@ -52,7 +52,7 @@ func newMaintenanceCommand() *cobra.Command { maintenanceCommand.Flags().StringVar(&maintenanceStatusName, "maintenance-status-name", "", "backuplocation maintenance status CR name, where repo maintenance status will be stored") maintenanceCommand.Flags().StringVar(&maintenanceStatusNamespace, "maintenance-status-namespace", "", "backuplocation maintenance status CR namespace, where repo maintenance status will be stored") maintenanceCommand.Flags().StringVar(&maintenanceType, "maintenance-type", "", "full - will run full maintenance and quick - will run quick maintenance") - maintenanceCommand.Flags().StringVar(&logLevel, "log-level", "", "If debug mode in kopia is to be used") + maintenanceCommand.Flags().StringVar(&logLevelDebug, "log-level", "", "If debug mode in kopia is to be used") return maintenanceCommand } @@ -276,7 +276,7 @@ func getBackupPathWithRepoName(repoName string) string { } func runKopiaQuickMaintenanceExecute(repository *executor.Repository) error { fn := "runKopiaQuickMaintenanceExecute:" - maintenanceRunCmd, err := kopia.GetMaintenanceRunCommand() + maintenanceRunCmd, err := kopia.GetMaintenanceRunCommand(logLevelDebug) if err != nil { errMsg := fmt.Sprintf("getting maintenance run command for [%v] failed: %v", repository.Name, err) logrus.Errorf("%s %v", fn, errMsg) @@ -284,7 +284,7 @@ func runKopiaQuickMaintenanceExecute(repository *executor.Repository) error { } initExecutor := kopia.NewMaintenanceRunExecutor(maintenanceRunCmd) - if err := initExecutor.Run(logLevel); err != nil { + if err := initExecutor.Run(); err != nil { errMsg := fmt.Sprintf("running maintenance run command for [%v] failed: %v", repository.Name, err) logrus.Errorf("%s %v", fn, errMsg) return fmt.Errorf(errMsg) @@ -308,14 +308,14 @@ func runKopiaQuickMaintenanceExecute(repository *executor.Repository) error { func runKopiaMaintenanceExecute(repository *executor.Repository) error { fn := "runKopiaMaintenanceRun:" - maintenanceRunCmd, err := kopia.GetMaintenanceRunCommand() + maintenanceRunCmd, err := kopia.GetMaintenanceRunCommand(logLevelDebug) if err != nil { errMsg := fmt.Sprintf("getting maintenance run command for [%v] failed: %v", repository.Name, err) logrus.Errorf("%s %v", fn, errMsg) return fmt.Errorf(errMsg) } initExecutor := kopia.NewMaintenanceRunExecutor(maintenanceRunCmd) - if err := initExecutor.Run(logLevel); err != nil { + if err := initExecutor.Run(); err != nil { errMsg := fmt.Sprintf("running maintenance run command for [%v] failed: %v", repository.Name, err) logrus.Errorf("%s %v", fn, errMsg) return fmt.Errorf(errMsg) @@ -339,14 +339,14 @@ func runKopiaMaintenanceExecute(repository *executor.Repository) error { func runKopiaMaintenanceSet(repository *executor.Repository) error { fn := "runKopiaMaintenanceSet:" - maintenanceSetCmd, err := kopia.GetMaintenanceSetCommand() + maintenanceSetCmd, err := kopia.GetMaintenanceSetCommand(logLevelDebug) if err != nil { errMsg := fmt.Sprintf("getting maintenance set command for failed: %v", err) logrus.Errorf("%s %v", fn, errMsg) return fmt.Errorf(errMsg) } initExecutor := kopia.NewMaintenanceSetExecutor(maintenanceSetCmd) - if err := initExecutor.Run(logLevel); err != nil { + if err := initExecutor.Run(); err != nil { errMsg := fmt.Sprintf("running maintenance set command for failed: %v", err) logrus.Errorf("%s %v", fn, errMsg) return fmt.Errorf(errMsg) diff --git a/pkg/executor/kopia/restore.go b/pkg/executor/kopia/restore.go index c52c74ba8..5217e0d17 100644 --- a/pkg/executor/kopia/restore.go +++ b/pkg/executor/kopia/restore.go @@ -18,9 +18,9 @@ var ( func newRestoreCommand() *cobra.Command { var ( - targetPath string - snapshotID string - logLevel string + targetPath string + snapshotID string + logLevelDebug string ) restoreCommand := &cobra.Command{ Use: "restore", @@ -41,7 +41,7 @@ func newRestoreCommand() *cobra.Command { restoreCommand.Flags().StringVar(&targetPath, "target-path", "", "Destination path for kopia restore") restoreCommand.Flags().StringVar(&snapshotID, "snapshot-id", "", "Snapshot id of the restore") restoreCommand.Flags().StringVar(&appRestoreCR, "app-restore-cr", "", "ApplicationRestore CR name") - restoreCommand.Flags().StringVar(&logLevel, "log-level", "", "If debug mode in kopia is to be used") + restoreCommand.Flags().StringVar(&logLevelDebug, "log-level", "", "If debug mode in kopia is to be used") return restoreCommand } @@ -105,13 +105,14 @@ func runKopiaRestore(repository *executor.Repository, targetPath, snapshotID str string(repository.Type), targetPath, snapshotID, + logLevelDebug, ) if err != nil { return err } initExecutor := kopia.NewRestoreExecutor(restoreCmd) - if err := initExecutor.Run(logLevel); err != nil { + if err := initExecutor.Run(); err != nil { err = fmt.Errorf("failed to run restore command: %v", err) return err } diff --git a/pkg/kopia/backup.go b/pkg/kopia/backup.go index 92b5dc994..f180eb83b 100644 --- a/pkg/kopia/backup.go +++ b/pkg/kopia/backup.go @@ -75,7 +75,7 @@ type backupExecutor struct { } // GetBackupCommand returns a wrapper over the kopia backup command -func GetBackupCommand(path, repoName, password, provider, sourcePath string) (*Command, error) { +func GetBackupCommand(path, repoName, password, provider, sourcePath string, logLevelDebug string) (*Command, error) { if repoName == "" { return nil, fmt.Errorf("repository name cannot be empty") } @@ -88,6 +88,7 @@ func GetBackupCommand(path, repoName, password, provider, sourcePath string) (*C Dir: sourcePath, Provider: provider, Args: []string{"."}, + LoglevelDebug: logLevelDebug, }, nil } @@ -101,8 +102,8 @@ func NewBackupExecutor(cmd *Command) Executor { } } -func (b *backupExecutor) Run(debugMode string) error { - b.execCmd = b.cmd.BackupCmd(debugMode) +func (b *backupExecutor) Run() error { + b.execCmd = b.cmd.BackupCmd() b.execCmd.Stdout = b.outBuf b.execCmd.Stderr = b.errBuf diff --git a/pkg/kopia/command.go b/pkg/kopia/command.go index 51bb30718..662fa3786 100644 --- a/pkg/kopia/command.go +++ b/pkg/kopia/command.go @@ -53,6 +53,8 @@ type Command struct { ExcludeFileList string // Region for S3 object Region string + //LoglevelDebug for kopia commands + LoglevelDebug string } // Executor interface defines APIs for implementing a command wrapper @@ -61,7 +63,7 @@ type Command struct { type Executor interface { // Run a long running command. Returns a unique CommandID that can be // used for fetching the status of the command - Run(string) error + Run() error // Status returns the status of Status() (*cmdexec.Status, error) @@ -86,7 +88,7 @@ func (c *Command) AddEnv(envs []string) *Command { } // CreateCmd returns os/exec.Cmd object for the kopia repo create Command -func (c *Command) CreateCmd(debugMode string) *exec.Cmd { +func (c *Command) CreateCmd() *exec.Cmd { // Get all the flags var argsSlice []string switch c.Provider { @@ -170,7 +172,7 @@ func (c *Command) CreateCmd(debugMode string) *exec.Cmd { } // check if debug mode in kopia is enabled - if debugMode != "" { + if c.LoglevelDebug != "" { argsSliceForDebug := []string{ "--log-level", debug, @@ -190,7 +192,7 @@ func (c *Command) CreateCmd(debugMode string) *exec.Cmd { } // BackupCmd returns os/exec.Cmd object for the kopia create Command -func (c *Command) BackupCmd(debugMode string) *exec.Cmd { +func (c *Command) BackupCmd() *exec.Cmd { // Get all the flags argsSlice := []string{ @@ -204,7 +206,7 @@ func (c *Command) BackupCmd(debugMode string) *exec.Cmd { } // check if debug mode in kopia is enabled - if debugMode != "" { + if c.LoglevelDebug != "" { argsSliceForDebug := []string{ "--log-level", debug, @@ -225,7 +227,7 @@ func (c *Command) BackupCmd(debugMode string) *exec.Cmd { } // ConnectCmd returns os/exec.Cmd object for the kopia connect Command -func (c *Command) ConnectCmd(debugMode string) *exec.Cmd { +func (c *Command) ConnectCmd() *exec.Cmd { var argsSlice []string switch c.Provider { case "azure": @@ -307,7 +309,7 @@ func (c *Command) ConnectCmd(debugMode string) *exec.Cmd { } // check if debug mode in kopia is enabled - if debugMode != "" { + if c.LoglevelDebug != "" { argsSliceForDebug := []string{ "--log-level", debug, @@ -327,7 +329,7 @@ func (c *Command) ConnectCmd(debugMode string) *exec.Cmd { } // RestoreCmd returns os/exec.Cmd object for the kopia restore Command -func (c *Command) RestoreCmd(debugMode string) *exec.Cmd { +func (c *Command) RestoreCmd() *exec.Cmd { // Get all the flags argsSlice := []string{ "snapshot", @@ -339,7 +341,7 @@ func (c *Command) RestoreCmd(debugMode string) *exec.Cmd { } // check if debug mode in kopia is enabled - if debugMode != "" { + if c.LoglevelDebug != "" { argsSliceForDebug := []string{ "--log-level", debug, @@ -359,7 +361,7 @@ func (c *Command) RestoreCmd(debugMode string) *exec.Cmd { } // SetPolicyCmd returns os/exec.Cmd object for the kopia policy Command -func (c *Command) SetPolicyCmd(debugMode string) *exec.Cmd { +func (c *Command) SetPolicyCmd() *exec.Cmd { // Get all the flags argsSlice := []string{ "policy", @@ -372,7 +374,7 @@ func (c *Command) SetPolicyCmd(debugMode string) *exec.Cmd { } // check if debug mode in kopia is enabled - if debugMode != "" { + if c.LoglevelDebug != "" { argsSliceForDebug := []string{ "--log-level", debug, @@ -393,7 +395,7 @@ func (c *Command) SetPolicyCmd(debugMode string) *exec.Cmd { } // DeleteCmd returns os/exec.Cmd object for the kopia snapshot delete Command -func (c *Command) DeleteCmd(debugMode string) *exec.Cmd { +func (c *Command) DeleteCmd() *exec.Cmd { // Get all the flags argsSlice := []string{ "snapshot", @@ -407,7 +409,7 @@ func (c *Command) DeleteCmd(debugMode string) *exec.Cmd { } // check if debug mode in kopia is enabled - if debugMode != "" { + if c.LoglevelDebug != "" { argsSliceForDebug := []string{ "--log-level", debug, @@ -429,7 +431,7 @@ func (c *Command) DeleteCmd(debugMode string) *exec.Cmd { // QuickMaintenanceRunCmd returns os/exec.Cmd object for the kopia quick maintenance run Command // For quick maintenance, we need not to give "--full" option. -func (c *Command) QuickMaintenanceRunCmd(debugMode string) *exec.Cmd { +func (c *Command) QuickMaintenanceRunCmd() *exec.Cmd { // Get all the flags argsSlice := []string{ c.Name, // maintenance command @@ -441,7 +443,7 @@ func (c *Command) QuickMaintenanceRunCmd(debugMode string) *exec.Cmd { } // check if debug mode in kopia is enabled - if debugMode != "" { + if c.LoglevelDebug != "" { argsSliceForDebug := []string{ "--log-level", debug, @@ -462,7 +464,7 @@ func (c *Command) QuickMaintenanceRunCmd(debugMode string) *exec.Cmd { } // MaintenanceRunCmd returns os/exec.Cmd object for the kopia maintenance run Command -func (c *Command) MaintenanceRunCmd(debugMode string) *exec.Cmd { +func (c *Command) MaintenanceRunCmd() *exec.Cmd { // Get all the flags argsSlice := []string{ c.Name, // maintenance command @@ -475,7 +477,7 @@ func (c *Command) MaintenanceRunCmd(debugMode string) *exec.Cmd { } // check if debug mode in kopia is enabled - if debugMode != "" { + if c.LoglevelDebug != "" { argsSliceForDebug := []string{ "--log-level", debug, @@ -496,7 +498,7 @@ func (c *Command) MaintenanceRunCmd(debugMode string) *exec.Cmd { } // SnapshotListCmd returns os/exec.Cmd object for the kopia snapshot list Command -func (c *Command) SnapshotListCmd(debugMode string) *exec.Cmd { +func (c *Command) SnapshotListCmd() *exec.Cmd { // Get all the flags argsSlice := []string{ c.Name, // snapshot list command @@ -509,7 +511,7 @@ func (c *Command) SnapshotListCmd(debugMode string) *exec.Cmd { } // check if debug mode in kopia is enabled - if debugMode != "" { + if c.LoglevelDebug != "" { argsSliceForDebug := []string{ "--log-level", debug, @@ -530,7 +532,7 @@ func (c *Command) SnapshotListCmd(debugMode string) *exec.Cmd { } // MaintenanceSetCmd returns os/exec.Cmd object for the kopia maintenance set Command -func (c *Command) MaintenanceSetCmd(debugMode string) *exec.Cmd { +func (c *Command) MaintenanceSetCmd() *exec.Cmd { // Get all the flags argsSlice := []string{ @@ -545,7 +547,7 @@ func (c *Command) MaintenanceSetCmd(debugMode string) *exec.Cmd { } // check if debug mode in kopia is enabled - if debugMode != "" { + if c.LoglevelDebug != "" { argsSliceForDebug := []string{ "--log-level", debug, @@ -566,7 +568,7 @@ func (c *Command) MaintenanceSetCmd(debugMode string) *exec.Cmd { } // CompressionCmd returns os/exec.Cmd object for the kopia policy set -func (c *Command) CompressionCmd(debugMode string) *exec.Cmd { +func (c *Command) CompressionCmd() *exec.Cmd { // Get all the flags argsSlice := []string{ c.Name, // compression command @@ -581,7 +583,7 @@ func (c *Command) CompressionCmd(debugMode string) *exec.Cmd { } // check if debug mode in kopia is enabled - if debugMode != "" { + if c.LoglevelDebug != "" { argsSliceForDebug := []string{ "--log-level", debug, @@ -602,7 +604,7 @@ func (c *Command) CompressionCmd(debugMode string) *exec.Cmd { } // ExcludeFileListCmd returns os/exec.Cmd object for the kopia policy set -func (c *Command) ExcludeFileListCmd(debugMode string) *exec.Cmd { +func (c *Command) ExcludeFileListCmd() *exec.Cmd { // Get all the flags argsSlice := []string{ c.Name, // compression command @@ -615,7 +617,7 @@ func (c *Command) ExcludeFileListCmd(debugMode string) *exec.Cmd { } // check if debug mode in kopia is enabled - if debugMode != "" { + if c.LoglevelDebug != "" { argsSliceForDebug := []string{ "--log-level", debug, diff --git a/pkg/kopia/compression.go b/pkg/kopia/compression.go index 6b42b0a37..d8d404c79 100644 --- a/pkg/kopia/compression.go +++ b/pkg/kopia/compression.go @@ -20,14 +20,15 @@ type compressionExecutor struct { } // GetCompressionCommand returns a wrapper over the kopia policy set -func GetCompressionCommand(path, compression string) (*Command, error) { +func GetCompressionCommand(path, compression string, logLevelDebug string) (*Command, error) { if path == "" { return nil, fmt.Errorf("path name cannot be empty") } return &Command{ - Name: "policy", - Path: path, - Compression: compression, + Name: "policy", + Path: path, + Compression: compression, + LoglevelDebug: logLevelDebug, }, nil } @@ -41,8 +42,8 @@ func NewCompressionExecutor(cmd *Command) Executor { } } -func (c *compressionExecutor) Run(debugMode string) error { - c.execCmd = c.cmd.CompressionCmd(debugMode) +func (c *compressionExecutor) Run() error { + c.execCmd = c.cmd.CompressionCmd() c.execCmd.Stdout = c.outBuf c.execCmd.Stderr = c.errBuf diff --git a/pkg/kopia/connect.go b/pkg/kopia/connect.go index a0b550321..4f5c1331c 100644 --- a/pkg/kopia/connect.go +++ b/pkg/kopia/connect.go @@ -30,7 +30,7 @@ const ( ) // GetConnectCommand returns a wrapper over the kopia connect command -func GetConnectCommand(path, repoName, password, provider, region string, disableSsl bool) (*Command, error) { +func GetConnectCommand(path, repoName, password, provider, region string, disableSsl bool, logLevelDebug string) (*Command, error) { if repoName == "" { return nil, fmt.Errorf("repository name cannot be empty") } @@ -42,6 +42,7 @@ func GetConnectCommand(path, repoName, password, provider, region string, disabl Path: path, DisableSsl: disableSsl, Region: region, + LoglevelDebug: logLevelDebug, }, nil } @@ -55,8 +56,8 @@ func NewConnectExecutor(cmd *Command) Executor { } } -func (b *connectExecutor) Run(debugMode string) error { - b.execCmd = b.cmd.ConnectCmd(debugMode) +func (b *connectExecutor) Run() error { + b.execCmd = b.cmd.ConnectCmd() b.execCmd.Stdout = b.outBuf b.execCmd.Stderr = b.errBuf diff --git a/pkg/kopia/create.go b/pkg/kopia/create.go index 68f3af1f2..8ce4b08db 100644 --- a/pkg/kopia/create.go +++ b/pkg/kopia/create.go @@ -35,7 +35,7 @@ type createExecutor struct { } // GetCreateCommand returns a wrapper over the kopia repo create command -func GetCreateCommand(path, repoName, password, provider, region string, disableSsl bool) (*Command, error) { +func GetCreateCommand(path, repoName, password, provider, region string, disableSsl bool, logLevelDebug string) (*Command, error) { if repoName == "" { return nil, fmt.Errorf("repository name cannot be empty") } @@ -47,6 +47,7 @@ func GetCreateCommand(path, repoName, password, provider, region string, disable Path: path, DisableSsl: disableSsl, Region: region, + LoglevelDebug: logLevelDebug, }, nil } @@ -60,8 +61,8 @@ func NewCreateExecutor(cmd *Command) Executor { } } -func (b *createExecutor) Run(debugMode string) error { - b.execCmd = b.cmd.CreateCmd(debugMode) +func (b *createExecutor) Run() error { + b.execCmd = b.cmd.CreateCmd() b.execCmd.Stdout = b.outBuf b.execCmd.Stderr = b.errBuf diff --git a/pkg/kopia/delete.go b/pkg/kopia/delete.go index 5828e2bab..554ac1913 100644 --- a/pkg/kopia/delete.go +++ b/pkg/kopia/delete.go @@ -20,10 +20,11 @@ type deleteExecutor struct { } // GetDeleteCommand returns a wrapper over the kopia snapshot delete command -func GetDeleteCommand(snapshotID string) (*Command, error) { +func GetDeleteCommand(snapshotID string, logLevelDebug string) (*Command, error) { return &Command{ - Name: "delete", - SnapshotID: snapshotID, + Name: "delete", + SnapshotID: snapshotID, + LoglevelDebug: logLevelDebug, }, nil } @@ -37,8 +38,8 @@ func NewDeleteExecutor(cmd *Command) Executor { } } -func (d *deleteExecutor) Run(debugMode string) error { - d.execCmd = d.cmd.DeleteCmd(debugMode) +func (d *deleteExecutor) Run() error { + d.execCmd = d.cmd.DeleteCmd() d.execCmd.Stdout = d.outBuf d.execCmd.Stderr = d.errBuf diff --git a/pkg/kopia/excludefilelist.go b/pkg/kopia/excludefilelist.go index 0507574ef..0d9c119d8 100644 --- a/pkg/kopia/excludefilelist.go +++ b/pkg/kopia/excludefilelist.go @@ -20,7 +20,7 @@ type excludeFileListExecutor struct { } // GetExcludeFileListCommand returns a wrapper over the kopia policy set -func GetExcludeFileListCommand(path, excludeFileList string) (*Command, error) { +func GetExcludeFileListCommand(path, excludeFileList string, logLevelDebug string) (*Command, error) { if path == "" { return nil, fmt.Errorf("path name cannot be empty") } @@ -28,6 +28,7 @@ func GetExcludeFileListCommand(path, excludeFileList string) (*Command, error) { Name: "policy", Path: path, ExcludeFileList: excludeFileList, + LoglevelDebug: logLevelDebug, }, nil } @@ -41,8 +42,8 @@ func NewExcludeFileListExecutor(cmd *Command) Executor { } } -func (c *excludeFileListExecutor) Run(debugMode string) error { - c.execCmd = c.cmd.ExcludeFileListCmd(debugMode) +func (c *excludeFileListExecutor) Run() error { + c.execCmd = c.cmd.ExcludeFileListCmd() c.execCmd.Stdout = c.outBuf c.execCmd.Stderr = c.errBuf diff --git a/pkg/kopia/global_policy.go b/pkg/kopia/global_policy.go index c4c3cd921..03b21c7c9 100644 --- a/pkg/kopia/global_policy.go +++ b/pkg/kopia/global_policy.go @@ -19,9 +19,10 @@ type globalPolicyExecutor struct { } // SetGlobalPolicyCommand returns a wrapper over the kopia set policy command -func SetGlobalPolicyCommand() (*Command, error) { +func SetGlobalPolicyCommand(logLevelDebug string) (*Command, error) { return &Command{ - Name: "set", + Name: "set", + LoglevelDebug: logLevelDebug, }, nil } @@ -35,8 +36,8 @@ func NewSetGlobalPolicyExecutor(cmd *Command) Executor { } } -func (b *globalPolicyExecutor) Run(debugMode string) error { - b.execCmd = b.cmd.SetPolicyCmd(debugMode) +func (b *globalPolicyExecutor) Run() error { + b.execCmd = b.cmd.SetPolicyCmd() b.execCmd.Stdout = b.outBuf b.execCmd.Stderr = b.errBuf diff --git a/pkg/kopia/list.go b/pkg/kopia/list.go index cc8e07198..6187370fa 100644 --- a/pkg/kopia/list.go +++ b/pkg/kopia/list.go @@ -26,9 +26,10 @@ type listExecutor struct { } // GetListCommand returns a wrapper over the kopia snapshot list command -func GetListCommand() (*Command, error) { +func GetListCommand(logLevelDebug string) (*Command, error) { return &Command{ - Name: "snapshot", + Name: "snapshot", + LoglevelDebug: logLevelDebug, }, nil } @@ -42,8 +43,8 @@ func NewListExecutor(cmd *Command) Executor { } } -func (b *listExecutor) Run(debugMode string) error { - b.execCmd = b.cmd.SnapshotListCmd(debugMode) +func (b *listExecutor) Run() error { + b.execCmd = b.cmd.SnapshotListCmd() b.execCmd.Stdout = b.outBuf b.execCmd.Stderr = b.errBuf diff --git a/pkg/kopia/maintenancequickrun.go b/pkg/kopia/maintenancequickrun.go index 635c1c752..84aa5c829 100644 --- a/pkg/kopia/maintenancequickrun.go +++ b/pkg/kopia/maintenancequickrun.go @@ -20,9 +20,10 @@ type quickMaintenanceRunExecutor struct { } // GetQuickMaintenanceRunCommand returns a wrapper over the kopia repo maintenance run command -func GetQuickMaintenanceRunCommand() (*Command, error) { +func GetQuickMaintenanceRunCommand(logLevelDebug string) (*Command, error) { return &Command{ - Name: "maintenance", + Name: "maintenance", + LoglevelDebug: logLevelDebug, }, nil } @@ -36,8 +37,8 @@ func NewQuickMaintenanceRunExecutor(cmd *Command) Executor { } } -func (qmr *quickMaintenanceRunExecutor) Run(debugMode string) error { - qmr.execCmd = qmr.cmd.QuickMaintenanceRunCmd(debugMode) +func (qmr *quickMaintenanceRunExecutor) Run() error { + qmr.execCmd = qmr.cmd.QuickMaintenanceRunCmd() qmr.execCmd.Stdout = qmr.outBuf qmr.execCmd.Stderr = qmr.errBuf diff --git a/pkg/kopia/maintenancerun.go b/pkg/kopia/maintenancerun.go index e9e069cac..d3f72785c 100644 --- a/pkg/kopia/maintenancerun.go +++ b/pkg/kopia/maintenancerun.go @@ -20,9 +20,10 @@ type maintenanceRunExecutor struct { } // GetMaintenanceRunCommand returns a wrapper over the kopia repo maintenance run command -func GetMaintenanceRunCommand() (*Command, error) { +func GetMaintenanceRunCommand(logLevelDebug string) (*Command, error) { return &Command{ - Name: "maintenance", + Name: "maintenance", + LoglevelDebug: logLevelDebug, }, nil } @@ -36,8 +37,8 @@ func NewMaintenanceRunExecutor(cmd *Command) Executor { } } -func (mr *maintenanceRunExecutor) Run(debugMode string) error { - mr.execCmd = mr.cmd.MaintenanceRunCmd(debugMode) +func (mr *maintenanceRunExecutor) Run() error { + mr.execCmd = mr.cmd.MaintenanceRunCmd() mr.execCmd.Stdout = mr.outBuf mr.execCmd.Stderr = mr.errBuf diff --git a/pkg/kopia/maintenanceset.go b/pkg/kopia/maintenanceset.go index 9a6a20a7a..7e9b3991f 100644 --- a/pkg/kopia/maintenanceset.go +++ b/pkg/kopia/maintenanceset.go @@ -25,7 +25,7 @@ type maintenanceSetExecutor struct { } // GetMaintenanceSetCommand returns a wrapper over the kopia repo maintenance set command -func GetMaintenanceSetCommand() (*Command, error) { +func GetMaintenanceSetCommand(logLevelDebug string) (*Command, error) { hostname, err := os.Hostname() if err != nil { errMsg := fmt.Sprintf("failed in getting hostname: %v", err) @@ -45,6 +45,7 @@ func GetMaintenanceSetCommand() (*Command, error) { return &Command{ Name: "maintenance", MaintenanceOwner: owner, + LoglevelDebug: logLevelDebug, }, nil } @@ -58,8 +59,8 @@ func NewMaintenanceSetExecutor(cmd *Command) Executor { } } -func (ms *maintenanceSetExecutor) Run(debugMode string) error { - ms.execCmd = ms.cmd.MaintenanceSetCmd(debugMode) +func (ms *maintenanceSetExecutor) Run() error { + ms.execCmd = ms.cmd.MaintenanceSetCmd() ms.execCmd.Stdout = ms.outBuf ms.execCmd.Stderr = ms.errBuf diff --git a/pkg/kopia/restore.go b/pkg/kopia/restore.go index 7ab457f7c..cedf767d0 100644 --- a/pkg/kopia/restore.go +++ b/pkg/kopia/restore.go @@ -38,7 +38,7 @@ const ( ) // GetRestoreCommand returns a wrapper over the kopia restore command. -func GetRestoreCommand(path, repoName, password, provider, targetPath, snapshotID string) (*Command, error) { +func GetRestoreCommand(path, repoName, password, provider, targetPath, snapshotID string, logLevelDebug string) (*Command, error) { if targetPath == "" { return nil, fmt.Errorf("destination path cannot be empty") } @@ -55,11 +55,12 @@ func GetRestoreCommand(path, repoName, password, provider, targetPath, snapshotI args := []string{snapshotID, "."} return &Command{ - Name: "restore", - Password: password, - Dir: targetPath, - Provider: provider, - Args: args, + Name: "restore", + Password: password, + Dir: targetPath, + Provider: provider, + Args: args, + LoglevelDebug: logLevelDebug, }, nil } @@ -95,9 +96,9 @@ func NewRestoreExecutor(cmd *Command) Executor { } } -func (b *restoreExecutor) Run(debugMode string) error { +func (b *restoreExecutor) Run() error { - b.execCmd = b.cmd.RestoreCmd(debugMode) + b.execCmd = b.cmd.RestoreCmd() b.execCmd.Stdout = b.outBuf b.execCmd.Stderr = b.errBuf