From 8cb211a61f859069312a2014a5efdbe6f50d4b76 Mon Sep 17 00:00:00 2001 From: Manuel Hutter Date: Wed, 9 Oct 2024 14:40:12 +0200 Subject: [PATCH] fix(restic): Don't set `--options` if there are none 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 --- restic/cli/restic.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/restic/cli/restic.go b/restic/cli/restic.go index c65770ad7..1f3ddf111 100644 --- a/restic/cli/restic.go +++ b/restic/cli/restic.go @@ -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...) }