mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
kubectl createall command extends Factory
This commit is contained in:
parent
30fcf24131
commit
2295d4b2e9
@ -94,12 +94,12 @@ Find more information at https://github.com/GoogleCloudPlatform/kubernetes.`,
|
|||||||
cmds.AddCommand(f.NewCmdGet(out))
|
cmds.AddCommand(f.NewCmdGet(out))
|
||||||
cmds.AddCommand(f.NewCmdDescribe(out))
|
cmds.AddCommand(f.NewCmdDescribe(out))
|
||||||
cmds.AddCommand(f.NewCmdCreate(out))
|
cmds.AddCommand(f.NewCmdCreate(out))
|
||||||
|
cmds.AddCommand(f.NewCmdCreateAll(out))
|
||||||
cmds.AddCommand(f.NewCmdUpdate(out))
|
cmds.AddCommand(f.NewCmdUpdate(out))
|
||||||
cmds.AddCommand(f.NewCmdDelete(out))
|
cmds.AddCommand(f.NewCmdDelete(out))
|
||||||
|
|
||||||
cmds.AddCommand(NewCmdNamespace(out))
|
cmds.AddCommand(NewCmdNamespace(out))
|
||||||
cmds.AddCommand(NewCmdLog(out))
|
cmds.AddCommand(NewCmdLog(out))
|
||||||
cmds.AddCommand(NewCmdCreateAll(out))
|
|
||||||
|
|
||||||
if err := cmds.Execute(); err != nil {
|
if err := cmds.Execute(); err != nil {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
@ -19,9 +19,7 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
|
||||||
errs "github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
|
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/api/meta"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/config"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/config"
|
||||||
@ -69,7 +67,7 @@ func DataToObjects(m meta.RESTMapper, t runtime.ObjectTyper, data []byte) (resul
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCmdCreateAll(out io.Writer) *cobra.Command {
|
func (f *Factory) NewCmdCreateAll(out io.Writer) *cobra.Command {
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "createall -f filename",
|
Use: "createall -f filename",
|
||||||
Short: "Create all resources specified in filename or stdin",
|
Short: "Create all resources specified in filename or stdin",
|
||||||
@ -84,11 +82,6 @@ Examples:
|
|||||||
$ cat config.json | kubectl apply -f -
|
$ cat config.json | kubectl apply -f -
|
||||||
<creates all resources listed in config.json>`,
|
<creates all resources listed in config.json>`,
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
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) {
|
clientFunc := func(*meta.RESTMapping) (*client.RESTClient, error) {
|
||||||
return getKubeClient(cmd).RESTClient, nil
|
return getKubeClient(cmd).RESTClient, nil
|
||||||
}
|
}
|
||||||
@ -101,8 +94,8 @@ Examples:
|
|||||||
data, err := ReadConfigData(filename)
|
data, err := ReadConfigData(filename)
|
||||||
checkErr(err)
|
checkErr(err)
|
||||||
|
|
||||||
items, errs := DataToObjects(mapper, typer, data)
|
items, errs := DataToObjects(f.Mapper, f.Typer, data)
|
||||||
applyErrs := config.CreateObjects(typer, mapper, clientFunc, items)
|
applyErrs := config.CreateObjects(f.Typer, f.Mapper, clientFunc, items)
|
||||||
errs = append(errs, applyErrs...)
|
errs = append(errs, applyErrs...)
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
for _, e := range errs {
|
for _, e := range errs {
|
||||||
|
Loading…
Reference in New Issue
Block a user