...

Source file src/k8s.io/kubectl/pkg/cmd/rollout/rollout.go

Documentation: k8s.io/kubectl/pkg/cmd/rollout

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

View as plain text