Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Update ignite help, image and kernel to no longer require root #676

Merged
merged 1 commit into from
Sep 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion cmd/ignite/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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)
Expand Down