github.com/alibaba/sealer@v0.8.6-0.20220430115802-37a2bdaa8173/sealer/cmd/debug.go (about) 1 // Copyright © 2021 Alibaba Group Holding Ltd. 2 // 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 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package cmd 16 17 import ( 18 "github.com/spf13/cobra" 19 20 "github.com/alibaba/sealer/pkg/debug" 21 ) 22 23 var debugOptions = debug.NewDebugOptions() 24 25 var debugCommand = &cobra.Command{ 26 Use: "debug", 27 Short: "Create debugging sessions for pods and nodes", 28 } 29 30 func init() { 31 rootCmd.AddCommand(debugCommand) 32 33 debugCommand.AddCommand(debug.CleanCMD) 34 debugCommand.AddCommand(debug.ShowImagesCMD) 35 debugCommand.AddCommand(debug.NewDebugPodCommand(debugOptions)) 36 debugCommand.AddCommand(debug.NewDebugNodeCommand(debugOptions)) 37 38 debugCommand.PersistentFlags().StringVar(&debugOptions.Image, "image", debugOptions.Image, "Container image to use for debug container.") 39 debugCommand.PersistentFlags().StringVar(&debugOptions.DebugContainerName, "name", debugOptions.DebugContainerName, "Container name to use for debug container.") 40 debugCommand.PersistentFlags().StringVar(&debugOptions.PullPolicy, "image-pull-policy", "IfNotPresent", "Container image pull policy, default policy is IfNotPresent.") 41 debugCommand.PersistentFlags().StringSliceVar(&debugOptions.CheckList, "check-list", debugOptions.CheckList, "Check items, such as network、volume.") 42 debugCommand.PersistentFlags().StringVarP(&debugOptions.Namespace, "namespace", "n", "default", "Namespace of Pod.") 43 debugCommand.PersistentFlags().BoolVarP(&debugOptions.Interactive, "stdin", "i", debugOptions.Interactive, "Keep stdin open on the container, even if nothing is attached.") 44 debugCommand.PersistentFlags().BoolVarP(&debugOptions.TTY, "tty", "t", debugOptions.TTY, "Allocate a TTY for the debugging container.") 45 debugCommand.PersistentFlags().StringToStringP("env", "e", nil, "Environment variables to set in the container.") 46 }