From ae6f964ba756b158d3019607ec684f8e1d0cd20e Mon Sep 17 00:00:00 2001 From: Khalian Date: Thu, 27 Aug 2020 02:38:43 +0000 Subject: [PATCH] Update ignite help, image, kernel, completion, inspect and ps commands to no longer require root --- cmd/ignite/cmd/root.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/cmd/ignite/cmd/root.go b/cmd/ignite/cmd/root.go index a3acd273a..f8c276a5b 100644 --- a/cmd/ignite/cmd/root.go +++ b/cmd/ignite/cmd/root.go @@ -43,7 +43,7 @@ func NewIgniteCommand(in io.Reader, out, err io.Writer) *cobra.Command { // TODO Some commands do not need to check root // Currently it seems to be only ignite version that does not require root - if cmd.Name() == "version" && cmd.Parent().Name() == "ignite" { + if isNonRootCommand(cmd.Name(), cmd.Parent().Name()) { return } @@ -117,6 +117,19 @@ func NewIgniteCommand(in io.Reader, out, err io.Writer) *cobra.Command { return root } +func isNonRootCommand(cmd string, parentCmd string) bool { + if parentCmd != "ignite" { + return false + } + + switch cmd { + case "version", "help", "image", "kernel", "completion", "inspect", "ps": + return true + } + + return false +} + func addGlobalFlags(fs *pflag.FlagSet) { AddQuietFlag(fs) logflag.LogLevelFlagVar(fs, &logLevel)