From 893e32e67e45bed7826e53ca1813875948fd589a Mon Sep 17 00:00:00 2001 From: Rogger Vasquez Date: Fri, 15 Sep 2023 10:56:29 -0500 Subject: [PATCH] rpk: improved err msg in rpk tune --output-script If the user used a directory it would fail without giving any meaningful error. (cherry picked from commit 35e6b394bd53141e3257ee06535e1605a8a65b45) --- src/go/rpk/pkg/cli/redpanda/tune/tune.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/go/rpk/pkg/cli/redpanda/tune/tune.go b/src/go/rpk/pkg/cli/redpanda/tune/tune.go index 3d74bfb2f7a7..b546a3415a8f 100644 --- a/src/go/rpk/pkg/cli/redpanda/tune/tune.go +++ b/src/go/rpk/pkg/cli/redpanda/tune/tune.go @@ -93,6 +93,11 @@ To learn more about a tuner, run 'rpk redpanda tune help '. out.MaybeDie(err, "unable to load config: %v", err) var tunerFactory factory.TunersFactory if outTuneScriptFile != "" { + isDir, err := afero.IsDir(fs, outTuneScriptFile) + out.MaybeDie(err, "unable to check if %q is a dir or a file: %v", outTuneScriptFile, err) + if isDir { + out.Die("please use a filename instead of a directory name in --output-script") + } tunerFactory = factory.NewScriptRenderingTunersFactory(fs, y.Rpk.Tuners, outTuneScriptFile, timeout) } else { tunerFactory = factory.NewDirectExecutorTunersFactory(fs, y.Rpk.Tuners, timeout)