diff --git a/cmd/ignite/cmd/root.go b/cmd/ignite/cmd/root.go index c5498309d..04e72acb6 100644 --- a/cmd/ignite/cmd/root.go +++ b/cmd/ignite/cmd/root.go @@ -17,6 +17,8 @@ import ( "github.com/weaveworks/ignite/pkg/network" networkflag "github.com/weaveworks/ignite/pkg/network/flag" "github.com/weaveworks/ignite/pkg/providers" + "github.com/weaveworks/ignite/pkg/providers/ignite" + "github.com/weaveworks/ignite/pkg/util" versioncmd "github.com/weaveworks/ignite/pkg/version/cmd" ) @@ -37,6 +39,25 @@ func NewIgniteCommand(in io.Reader, out, err io.Writer) *cobra.Command { logs.Logger.SetLevel(logLevel) // Set the desired network plugin providers.NetworkPlugin = providers.NetworkPlugins[network.ActivePlugin] + + // 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 { + logrus.Fatal(err) + } }, Long: dedent.Dedent(fmt.Sprintf(` Ignite is a containerized Firecracker microVM administration tool. diff --git a/cmd/ignite/ignite.go b/cmd/ignite/ignite.go index 75b00b029..055d4f717 100644 --- a/cmd/ignite/ignite.go +++ b/cmd/ignite/ignite.go @@ -17,15 +17,7 @@ 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()) - - // Populate the providers + // Preload necessary providers util.GenericCheckErr(providers.Populate(ignite.Providers)) c := cmd.NewIgniteCommand(os.Stdin, os.Stdout, os.Stderr) diff --git a/go.mod b/go.mod index c1e92b36f..ba7ddc734 100644 --- a/go.mod +++ b/go.mod @@ -47,7 +47,7 @@ require ( gotest.tools v2.2.0+incompatible // indirect k8s.io/apimachinery v0.0.0-20190612205821-1799e75a0719 k8s.io/klog v0.4.0 // indirect - k8s.io/kube-openapi v0.0.0-20190709113604-33be087ad058 + k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf sigs.k8s.io/yaml v1.1.0 ) diff --git a/go.sum b/go.sum index 162277b69..5effea242 100644 --- a/go.sum +++ b/go.sum @@ -130,7 +130,6 @@ github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.0.0 h1:b4Gk+7WdP/d3HZH8EJsZpvV7EtDOgaZLtnaNGIu1adA= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/gnostic v0.0.0-20170426233943-68f4ded48ba9/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d h1:7XGaL1e6bYS1yIonGp9761ExpPPV1ui0SAC59Yube9k= github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= github.com/goombaio/namegenerator v0.0.0-20181006234301-989e774b106e h1:XmA6L9IPRdUr28a+SK/oMchGgQy159wvzXA5tJ7l+40= @@ -354,8 +353,8 @@ k8s.io/klog v0.4.0 h1:lCJCxf/LIowc2IGS9TPjWDyXY4nOmdGdfcwwDQCOURQ= k8s.io/klog v0.4.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 h1:TRb4wNWoBVrH9plmkp2q86FIDppkbrEXdXlxU3a3BMI= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= -k8s.io/kube-openapi v0.0.0-20190709113604-33be087ad058 h1:di3XCwddOR9cWBNpfgXaskhh6cgJuwcK54rvtwUaC10= -k8s.io/kube-openapi v0.0.0-20190709113604-33be087ad058/go.mod h1:nfDlWeOsu3pUf4yWGL+ERqohP4YsZcBJXWMK+gkzOA4= +k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf h1:EYm5AW/UUDbnmnI+gK0TJDVK9qPLhM+sRHYanNKw0EQ= +k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/vendor/k8s.io/kube-openapi/pkg/common/common.go b/vendor/k8s.io/kube-openapi/pkg/common/common.go index 7d5534b24..f1c87c300 100644 --- a/vendor/k8s.io/kube-openapi/pkg/common/common.go +++ b/vendor/k8s.io/kube-openapi/pkg/common/common.go @@ -24,6 +24,12 @@ import ( "github.com/go-openapi/spec" ) +const ( + // TODO: Make this configurable. + ExtensionPrefix = "x-kubernetes-" + ExtensionV2Schema = ExtensionPrefix + "v2-schema" +) + // OpenAPIDefinition describes single type. Normally these definitions are auto-generated using gen-openapi. type OpenAPIDefinition struct { Schema spec.Schema @@ -43,6 +49,10 @@ type OpenAPIDefinitionGetter interface { OpenAPIDefinition() *OpenAPIDefinition } +type OpenAPIV3DefinitionGetter interface { + OpenAPIV3Definition() *OpenAPIDefinition +} + type PathHandler interface { Handle(path string, handler http.Handler) } @@ -172,3 +182,11 @@ func EscapeJsonPointer(p string) string { p = strings.Replace(p, "/", "~1", -1) return p } + +func EmbedOpenAPIDefinitionIntoV2Extension(main OpenAPIDefinition, embedded OpenAPIDefinition) OpenAPIDefinition { + if main.Schema.Extensions == nil { + main.Schema.Extensions = make(map[string]interface{}) + } + main.Schema.Extensions[ExtensionV2Schema] = embedded.Schema + return main +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 1a7ac4af7..d7b50bf44 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -257,7 +257,7 @@ k8s.io/apimachinery/pkg/util/validation k8s.io/apimachinery/pkg/util/net # k8s.io/klog v0.4.0 k8s.io/klog -# k8s.io/kube-openapi v0.0.0-20190709113604-33be087ad058 +# k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf k8s.io/kube-openapi/pkg/common k8s.io/kube-openapi/pkg/util/proto # sigs.k8s.io/yaml v1.1.0