Add a kubectl stop command

This commit is contained in:
Jeff Lowdermilk
2015-01-20 18:58:04 -08:00
parent ac2e2c9fbb
commit b1aa037990
7 changed files with 393 additions and 10 deletions

View File

@@ -64,6 +64,8 @@ type Factory struct {
Printer func(cmd *cobra.Command, mapping *meta.RESTMapping, noHeaders bool) (kubectl.ResourcePrinter, error)
// Returns a Resizer for changing the size of the specified RESTMapping type or an error
Resizer func(cmd *cobra.Command, mapping *meta.RESTMapping) (kubectl.Resizer, error)
// Returns a Reaper for gracefully shutting down resources.
Reaper func(cmd *cobra.Command, mapping *meta.RESTMapping) (kubectl.Reaper, error)
// Returns a schema that can validate objects stored on disk.
Validator func(*cobra.Command) (validation.Schema, error)
}
@@ -119,11 +121,14 @@ func NewFactory() *Factory {
if err != nil {
return nil, err
}
resizer, ok := kubectl.ResizerFor(mapping.Kind, client)
if !ok {
return nil, fmt.Errorf("no resizer has been implemented for %q", mapping.Kind)
return kubectl.ResizerFor(mapping.Kind, client)
},
Reaper: func(cmd *cobra.Command, mapping *meta.RESTMapping) (kubectl.Reaper, error) {
client, err := clients.ClientForVersion(mapping.APIVersion)
if err != nil {
return nil, err
}
return resizer, nil
return kubectl.ReaperFor(mapping.Kind, client)
},
Validator: func(cmd *cobra.Command) (validation.Schema, error) {
if GetFlagBool(cmd, "validate") {
@@ -193,6 +198,7 @@ Find more information at https://github.com/GoogleCloudPlatform/kubernetes.`,
cmds.AddCommand(f.NewCmdResize(out))
cmds.AddCommand(f.NewCmdRunContainer(out))
cmds.AddCommand(f.NewCmdStop(out))
return cmds
}