From 2295d4b2e9dc040954c0aeca23965950972ac4d7 Mon Sep 17 00:00:00 2001 From: Maria Nita Date: Tue, 11 Nov 2014 15:03:27 +0100 Subject: [PATCH] kubectl createall command extends Factory --- pkg/kubectl/cmd/cmd.go | 2 +- pkg/kubectl/cmd/createall.go | 13 +++---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/pkg/kubectl/cmd/cmd.go b/pkg/kubectl/cmd/cmd.go index e071e7a1081..a24e3c62be4 100644 --- a/pkg/kubectl/cmd/cmd.go +++ b/pkg/kubectl/cmd/cmd.go @@ -94,12 +94,12 @@ Find more information at https://github.com/GoogleCloudPlatform/kubernetes.`, cmds.AddCommand(f.NewCmdGet(out)) cmds.AddCommand(f.NewCmdDescribe(out)) cmds.AddCommand(f.NewCmdCreate(out)) + cmds.AddCommand(f.NewCmdCreateAll(out)) cmds.AddCommand(f.NewCmdUpdate(out)) cmds.AddCommand(f.NewCmdDelete(out)) cmds.AddCommand(NewCmdNamespace(out)) cmds.AddCommand(NewCmdLog(out)) - cmds.AddCommand(NewCmdCreateAll(out)) if err := cmds.Execute(); err != nil { os.Exit(1) diff --git a/pkg/kubectl/cmd/createall.go b/pkg/kubectl/cmd/createall.go index 0f0b237036b..e5731b468e9 100644 --- a/pkg/kubectl/cmd/createall.go +++ b/pkg/kubectl/cmd/createall.go @@ -19,9 +19,7 @@ package cmd import ( "io" - "github.com/GoogleCloudPlatform/kubernetes/pkg/api" errs "github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors" - "github.com/GoogleCloudPlatform/kubernetes/pkg/api/latest" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/meta" "github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/config" @@ -69,7 +67,7 @@ func DataToObjects(m meta.RESTMapper, t runtime.ObjectTyper, data []byte) (resul return } -func NewCmdCreateAll(out io.Writer) *cobra.Command { +func (f *Factory) NewCmdCreateAll(out io.Writer) *cobra.Command { cmd := &cobra.Command{ Use: "createall -f filename", Short: "Create all resources specified in filename or stdin", @@ -84,11 +82,6 @@ Examples: $ cat config.json | kubectl apply -f - `, Run: func(cmd *cobra.Command, args []string) { - // TODO: Replace this with Factory.Typer - typer := api.Scheme - // TODO: Replace this with Factory.Mapper - mapper := latest.RESTMapper - // TODO: Replace this with Factory.Client clientFunc := func(*meta.RESTMapping) (*client.RESTClient, error) { return getKubeClient(cmd).RESTClient, nil } @@ -101,8 +94,8 @@ Examples: data, err := ReadConfigData(filename) checkErr(err) - items, errs := DataToObjects(mapper, typer, data) - applyErrs := config.CreateObjects(typer, mapper, clientFunc, items) + items, errs := DataToObjects(f.Mapper, f.Typer, data) + applyErrs := config.CreateObjects(f.Typer, f.Mapper, clientFunc, items) errs = append(errs, applyErrs...) if len(errs) > 0 { for _, e := range errs {