rollout.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. Copyright 2016 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package rollout
  14. import (
  15. "github.com/lithammer/dedent"
  16. "github.com/spf13/cobra"
  17. "k8s.io/cli-runtime/pkg/genericclioptions"
  18. cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
  19. "k8s.io/kubernetes/pkg/kubectl/util/i18n"
  20. "k8s.io/kubernetes/pkg/kubectl/util/templates"
  21. )
  22. var (
  23. rolloutLong = templates.LongDesc(`
  24. Manage the rollout of a resource.` + rolloutValidResources)
  25. rolloutExample = templates.Examples(`
  26. # Rollback to the previous deployment
  27. kubectl rollout undo deployment/abc
  28. # Check the rollout status of a daemonset
  29. kubectl rollout status daemonset/foo`)
  30. rolloutValidResources = dedent.Dedent(`
  31. Valid resource types include:
  32. * deployments
  33. * daemonsets
  34. * statefulsets
  35. `)
  36. )
  37. // NewCmdRollout returns a Command instance for 'rollout' sub command
  38. func NewCmdRollout(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command {
  39. cmd := &cobra.Command{
  40. Use: "rollout SUBCOMMAND",
  41. DisableFlagsInUseLine: true,
  42. Short: i18n.T("Manage the rollout of a resource"),
  43. Long: rolloutLong,
  44. Example: rolloutExample,
  45. Run: cmdutil.DefaultSubCommandRun(streams.Out),
  46. }
  47. // subcommands
  48. cmd.AddCommand(NewCmdRolloutHistory(f, streams))
  49. cmd.AddCommand(NewCmdRolloutPause(f, streams))
  50. cmd.AddCommand(NewCmdRolloutResume(f, streams))
  51. cmd.AddCommand(NewCmdRolloutUndo(f, streams))
  52. cmd.AddCommand(NewCmdRolloutStatus(f, streams))
  53. cmd.AddCommand(NewCmdRolloutRestart(f, streams))
  54. return cmd
  55. }