From 515fcb670c1fc507a956edbce69ee333c5a08fe5 Mon Sep 17 00:00:00 2001 From: Chanwit Kaewkasi Date: Sat, 7 Sep 2019 22:41:16 +0700 Subject: [PATCH] skip root requirement for ignite version Signed-off-by: Chanwit Kaewkasi --- cmd/ignite/cmd/root.go | 15 +++++++++++++++ cmd/ignite/ignite.go | 14 +++----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/cmd/ignite/cmd/root.go b/cmd/ignite/cmd/root.go index 8941eb1ac..c9ecea7cf 100644 --- a/cmd/ignite/cmd/root.go +++ b/cmd/ignite/cmd/root.go @@ -2,6 +2,7 @@ package cmd import ( "fmt" + "github.com/weaveworks/ignite/pkg/util" "io" "os" @@ -37,6 +38,20 @@ func NewIgniteCommand(in io.Reader, out, err io.Writer) *cobra.Command { // Set the desired logging level, now that the flags are parsed logs.Logger.SetLevel(logLevel) + // 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" { + return + } + + // Ignite needs to run as root for now, see + // https://github.com/weaveworks/ignite/issues/46 + // TODO: Remove this when ready + util.GenericCheckErr(util.TestRoot()) + + // Create the directories needed for running + util.GenericCheckErr(util.CreateDirectories()) + // Populate the providers after flags have been parsed if err := providers.Populate(ignite.Providers); err != nil { log.Fatal(err) diff --git a/cmd/ignite/ignite.go b/cmd/ignite/ignite.go index a6e1322fd..08b1555e0 100644 --- a/cmd/ignite/ignite.go +++ b/cmd/ignite/ignite.go @@ -1,12 +1,12 @@ package main import ( - "os" - - "github.com/weaveworks/ignite/cmd/ignite/cmd" "github.com/weaveworks/ignite/pkg/providers" "github.com/weaveworks/ignite/pkg/providers/ignite" "github.com/weaveworks/ignite/pkg/util" + "os" + + "github.com/weaveworks/ignite/cmd/ignite/cmd" ) func main() { @@ -17,14 +17,6 @@ func main() { // Run runs the main cobra command of this application func Run() error { - // Ignite needs to run as root for now, see - // https://github.com/weaveworks/ignite/issues/46 - // TODO: Remove this when ready - util.GenericCheckErr(util.TestRoot()) - - // Create the directories needed for running - util.GenericCheckErr(util.CreateDirectories()) - // Preload necessary providers util.GenericCheckErr(providers.Populate(ignite.Preload))