Skip to content

Commit

Permalink
fix(restic): Don't set --options if there are none
Browse files Browse the repository at this point in the history
Calling `strings.Split` on an empty string still returns a slice with
one empty string in it, hence setting `options`.

This commit changes the implementation to _first_ check for empty
strings, before even calling `strings.Split`.

Signed-off-by: Manuel Hutter <[email protected]>
  • Loading branch information
mhutter committed Oct 9, 2024
1 parent 7713061 commit 5f41381
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions restic/cli/restic.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ type clientCert struct {
func New(ctx context.Context, logger logr.Logger, statsHandler StatsHandler) *Restic {
globalFlags := Flags{}

options := strings.Split(cfg.Config.ResticOptions, ",")
if len(options) > 0 {
if cfg.Config.ResticOptions != "" {
options := strings.Split(cfg.Config.ResticOptions, ",")
logger.Info("using the following restic options", "options", options)
globalFlags.AddFlag("--option", options...)
}
Expand Down

0 comments on commit 5f41381

Please sign in to comment.