Skip to content

Commit

Permalink
[DELETE] Delete unnecessary error param in setupArgs function
Browse files Browse the repository at this point in the history
Signed-off-by: Pooya Azarpour <pooya_azarpour@yahoo.com>
  • Loading branch information
poyaz committed Apr 8, 2024
1 parent d1319f0 commit 9b4216a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 20 deletions.
9 changes: 4 additions & 5 deletions operator/archivecontroller/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@ func (a *ArchiveExecutor) Execute(ctx context.Context) error {
batchJob.Spec.Template.Spec.Containers[0].VolumeMounts = a.attachMoreVolumeMounts()
batchJob.Spec.Template.Spec.Volumes = a.attachMoreVolumes()

args, argsErr := a.setupArgs()
batchJob.Spec.Template.Spec.Containers[0].Args = args
batchJob.Spec.Template.Spec.Containers[0].Args = a.setupArgs()

return argsErr
return nil
})
if err != nil {
log.Error(err, "could not create job")
Expand All @@ -77,14 +76,14 @@ func (a *ArchiveExecutor) jobName() string {
return k8upv1.ArchiveType.String() + "-" + a.Obj.GetName()
}

func (a *ArchiveExecutor) setupArgs() ([]string, error) {
func (a *ArchiveExecutor) setupArgs() []string {
args := []string{"-varDir", cfg.Config.PodVarDir, "-archive", "-restoreType", "s3"}
if a.archive.Spec.RestoreSpec != nil && len(a.archive.Spec.RestoreSpec.Tags) > 0 {
args = append(args, executor.BuildTagArgs(a.archive.Spec.RestoreSpec.Tags)...)
}
args = append(args, a.appendOptionsArgs()...)

return args, nil
return args
}

func (a *ArchiveExecutor) setupEnvVars(ctx context.Context, archive *k8upv1.Archive) []corev1.EnvVar {
Expand Down
4 changes: 2 additions & 2 deletions operator/backupcontroller/backup_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ func (b *BackupExecutor) createServiceAccountAndBinding(ctx context.Context) err
return err
}

func (b *BackupExecutor) setupArgs() ([]string, error) {
func (b *BackupExecutor) setupArgs() []string {
args := []string{"--varDir", cfg.Config.PodVarDir}
if len(b.backup.Spec.Tags) > 0 {
args = append(args, executor.BuildTagArgs(b.backup.Spec.Tags)...)
}
args = append(args, b.appendOptionsArgs()...)

return args, nil
return args
}

func (b *BackupExecutor) setupEnvVars() ([]corev1.EnvVar, error) {
Expand Down
5 changes: 2 additions & 3 deletions operator/backupcontroller/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,10 @@ func (b *BackupExecutor) startBackup(ctx context.Context) error {
b.attachMoreVolumeMounts()...,
)

args, argsErr := b.setupArgs()
batchJob.job.Spec.Template.Spec.Containers[0].Args = args
batchJob.job.Spec.Template.Spec.Containers[0].Args = b.setupArgs()

index++
return argsErr
return nil
})
if err != nil {
return fmt.Errorf("unable to createOrUpdate(%q): %w", batchJob.job.Name, err)
Expand Down
9 changes: 4 additions & 5 deletions operator/checkcontroller/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@ func (c *CheckExecutor) Execute(ctx context.Context) error {
batchJob.Spec.Template.Spec.Volumes = c.attachMoreVolumes()
batchJob.Labels[job.K8upExclusive] = "true"

args, argsErr := c.setupArgs()
batchJob.Spec.Template.Spec.Containers[0].Args = args
batchJob.Spec.Template.Spec.Containers[0].Args = c.setupArgs()

return argsErr
return nil
},
)
if err != nil {
Expand All @@ -76,11 +75,11 @@ func (c *CheckExecutor) jobName() string {
return k8upv1.CheckType.String() + "-" + c.check.Name
}

func (c *CheckExecutor) setupArgs() ([]string, error) {
func (c *CheckExecutor) setupArgs() []string {
args := []string{"-varDir", cfg.Config.PodVarDir, "-check"}
args = append(args, c.appendOptionsArgs()...)

return args, nil
return args
}

func (c *CheckExecutor) setupEnvVars(ctx context.Context) []corev1.EnvVar {
Expand Down
9 changes: 4 additions & 5 deletions operator/prunecontroller/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ func (p *PruneExecutor) Execute(ctx context.Context) error {
batchJob.Spec.Template.Spec.Volumes = p.attachMoreVolumes()
batchJob.Labels[job.K8upExclusive] = "true"

args, argsErr := p.setupArgs()
batchJob.Spec.Template.Spec.Containers[0].Args = args
batchJob.Spec.Template.Spec.Containers[0].Args = p.setupArgs()

return argsErr
return nil
})
if err != nil {
p.SetConditionFalseWithMessage(ctx, k8upv1.ConditionReady, k8upv1.ReasonCreationFailed, "could not create job: %v", err)
Expand All @@ -70,14 +69,14 @@ func (p *PruneExecutor) jobName() string {
return k8upv1.PruneType.String() + "-" + p.prune.Name
}

func (p *PruneExecutor) setupArgs() ([]string, error) {
func (p *PruneExecutor) setupArgs() []string {
args := []string{"-varDir", cfg.Config.PodVarDir, "-prune"}
if len(p.prune.Spec.Retention.Tags) > 0 {
args = append(args, executor.BuildTagArgs(p.prune.Spec.Retention.Tags)...)
}
args = append(args, p.appendOptionsArgs()...)

return args, nil
return args
}

// Exclusive should return true for jobs that can't run while other jobs run.
Expand Down

0 comments on commit 9b4216a

Please sign in to comment.