Commit d14660c2 authored by shiywang's avatar shiywang

remove deprecated command 'kubectl stop'

parent a7c69bd5
...@@ -109,7 +109,6 @@ docs/man/man1/kubectl-set-selector.1 ...@@ -109,7 +109,6 @@ docs/man/man1/kubectl-set-selector.1
docs/man/man1/kubectl-set-serviceaccount.1 docs/man/man1/kubectl-set-serviceaccount.1
docs/man/man1/kubectl-set-subject.1 docs/man/man1/kubectl-set-subject.1
docs/man/man1/kubectl-set.1 docs/man/man1/kubectl-set.1
docs/man/man1/kubectl-stop.1
docs/man/man1/kubectl-taint.1 docs/man/man1/kubectl-taint.1
docs/man/man1/kubectl-top-node.1 docs/man/man1/kubectl-top-node.1
docs/man/man1/kubectl-top-pod.1 docs/man/man1/kubectl-top-pod.1
...@@ -252,7 +251,6 @@ docs/yaml/kubectl/kubectl_run-container.yaml ...@@ -252,7 +251,6 @@ docs/yaml/kubectl/kubectl_run-container.yaml
docs/yaml/kubectl/kubectl_run.yaml docs/yaml/kubectl/kubectl_run.yaml
docs/yaml/kubectl/kubectl_scale.yaml docs/yaml/kubectl/kubectl_scale.yaml
docs/yaml/kubectl/kubectl_set.yaml docs/yaml/kubectl/kubectl_set.yaml
docs/yaml/kubectl/kubectl_stop.yaml
docs/yaml/kubectl/kubectl_taint.yaml docs/yaml/kubectl/kubectl_taint.yaml
docs/yaml/kubectl/kubectl_top.yaml docs/yaml/kubectl/kubectl_top.yaml
docs/yaml/kubectl/kubectl_uncordon.yaml docs/yaml/kubectl/kubectl_uncordon.yaml
......
This file is autogenerated, but we've stopped checking such files into the
repository to reduce the need for rebases. Please run hack/generate-docs.sh to
populate this file.
This file is autogenerated, but we've stopped checking such files into the
repository to reduce the need for rebases. Please run hack/generate-docs.sh to
populate this file.
...@@ -56,7 +56,6 @@ go_library( ...@@ -56,7 +56,6 @@ go_library(
"rollingupdate.go", "rollingupdate.go",
"run.go", "run.go",
"scale.go", "scale.go",
"stop.go",
"taint.go", "taint.go",
"top.go", "top.go",
"top_node.go", "top_node.go",
......
...@@ -161,7 +161,7 @@ __kubectl_require_pod_and_container() ...@@ -161,7 +161,7 @@ __kubectl_require_pod_and_container()
__custom_func() { __custom_func() {
case ${last_command} in case ${last_command} in
kubectl_get | kubectl_describe | kubectl_delete | kubectl_label | kubectl_stop | kubectl_edit | kubectl_patch |\ kubectl_get | kubectl_describe | kubectl_delete | kubectl_label | kubectl_edit | kubectl_patch |\
kubectl_annotate | kubectl_expose | kubectl_scale | kubectl_autoscale | kubectl_taint | kubectl_rollout_*) kubectl_annotate | kubectl_expose | kubectl_scale | kubectl_autoscale | kubectl_taint | kubectl_rollout_*)
__kubectl_get_resource __kubectl_get_resource
return return
...@@ -356,10 +356,7 @@ func NewKubectlCommand(f cmdutil.Factory, in io.Reader, out, err io.Writer) *cob ...@@ -356,10 +356,7 @@ func NewKubectlCommand(f cmdutil.Factory, in io.Reader, out, err io.Writer) *cob
} }
groups.Add(cmds) groups.Add(cmds)
filters := []string{ filters := []string{"options"}
"options",
deprecated("kubectl", "delete", cmds, NewCmdStop(f, out)),
}
// Hide the "alpha" subcommand if there are no alpha commands in this build. // Hide the "alpha" subcommand if there are no alpha commands in this build.
alpha := NewCmdAlpha(f, in, out, err) alpha := NewCmdAlpha(f, in, out, err)
......
/*
Copyright 2014 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package cmd
import (
"fmt"
"io"
"github.com/spf13/cobra"
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
"k8s.io/kubernetes/pkg/kubectl/resource"
"k8s.io/kubernetes/pkg/util/i18n"
)
var (
stopLong = templates.LongDesc(i18n.T(`
Deprecated: Gracefully shut down a resource by name or filename.
The stop command is deprecated, all its functionalities are covered by delete command.
See 'kubectl delete --help' for more details.
Attempts to shut down and delete a resource that supports graceful termination.
If the resource is scalable it will be scaled to 0 before deletion.`))
stopExample = templates.Examples(i18n.T(`
# Shut down foo.
kubectl stop replicationcontroller foo
# Stop pods and services with label name=myLabel.
kubectl stop pods,services -l name=myLabel
# Shut down the service defined in service.json
kubectl stop -f service.json
# Shut down all resources in the path/to/resources directory
kubectl stop -f path/to/resources`))
)
func NewCmdStop(f cmdutil.Factory, out io.Writer) *cobra.Command {
options := &resource.FilenameOptions{}
cmd := &cobra.Command{
Use: "stop (-f FILENAME | TYPE (NAME | -l label | --all))",
Short: i18n.T("Deprecated: Gracefully shut down a resource by name or filename"),
Long: stopLong,
Example: stopExample,
Deprecated: fmt.Sprintf("use %q instead.", "delete"),
Run: func(cmd *cobra.Command, args []string) {
cmdutil.CheckErr(cmdutil.ValidateOutputArgs(cmd))
cmdutil.CheckErr(RunStop(f, cmd, args, out, options))
},
}
usage := "of resource(s) to be stopped."
cmdutil.AddFilenameOptionFlags(cmd, options, usage)
cmd.Flags().StringP("selector", "l", "", "Selector (label query) to filter on.")
cmd.Flags().Bool("all", false, "Select all resources in the namespace of the specified resource types.")
cmd.Flags().Bool("ignore-not-found", false, "Treat \"resource not found\" as a successful stop.")
cmd.Flags().Int("grace-period", -1, "Period of time in seconds given to the resource to terminate gracefully. Ignored if negative.")
cmd.Flags().Duration("timeout", 0, "The length of time to wait before giving up on a delete, zero means determine a timeout from the size of the object")
cmdutil.AddOutputFlagsForMutation(cmd)
cmdutil.AddInclude3rdPartyFlags(cmd)
return cmd
}
func RunStop(f cmdutil.Factory, cmd *cobra.Command, args []string, out io.Writer, options *resource.FilenameOptions) error {
cmdNamespace, enforceNamespace, err := f.DefaultNamespace()
if err != nil {
return err
}
mapper, _ := f.Object()
r := f.NewBuilder(true).
ContinueOnError().
NamespaceParam(cmdNamespace).DefaultNamespace().
ResourceTypeOrNameArgs(false, args...).
FilenameParam(enforceNamespace, options).
SelectorParam(cmdutil.GetFlagString(cmd, "selector")).
SelectAllParam(cmdutil.GetFlagBool(cmd, "all")).
Flatten().
Do()
if r.Err() != nil {
return r.Err()
}
shortOutput := cmdutil.GetFlagString(cmd, "output") == "name"
gracePeriod := cmdutil.GetFlagInt(cmd, "grace-period")
waitForDeletion := false
if gracePeriod == 0 {
// To preserve backwards compatibility, but prevent accidental data loss, we convert --grace-period=0
// into --grace-period=1 and wait until the object is successfully deleted.
gracePeriod = 1
waitForDeletion = true
}
return ReapResult(r, f, out, false, cmdutil.GetFlagBool(cmd, "ignore-not-found"), cmdutil.GetFlagDuration(cmd, "timeout"), gracePeriod, waitForDeletion, shortOutput, mapper, false)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment