NewAnalyzeCmd creates a new analyze command
(f factory.Factory, globalFlags *flags.GlobalFlags)
| 24 | |
| 25 | // NewAnalyzeCmd creates a new analyze command |
| 26 | func NewAnalyzeCmd(f factory.Factory, globalFlags *flags.GlobalFlags) *cobra.Command { |
| 27 | cmd := &AnalyzeCmd{GlobalFlags: globalFlags} |
| 28 | |
| 29 | analyzeCmd := &cobra.Command{ |
| 30 | Use: "analyze", |
| 31 | Short: "Analyzes a kubernetes namespace and checks for potential problems", |
| 32 | Long: ` |
| 33 | ####################################################### |
| 34 | ################## devspace analyze ################### |
| 35 | ####################################################### |
| 36 | Analyze checks a namespaces events, replicasets, services |
| 37 | and pods for potential problems |
| 38 | |
| 39 | Example: |
| 40 | devspace analyze |
| 41 | devspace analyze --namespace=mynamespace |
| 42 | ####################################################### |
| 43 | `, |
| 44 | Args: cobra.NoArgs, |
| 45 | RunE: func(cobraCmd *cobra.Command, args []string) error { |
| 46 | plugin.SetPluginCommand(cobraCmd, args) |
| 47 | return cmd.RunAnalyze(f, cobraCmd, args) |
| 48 | }, |
| 49 | } |
| 50 | |
| 51 | analyzeCmd.Flags().BoolVar(&cmd.Wait, "wait", true, "Wait for pods to get ready if they are just starting") |
| 52 | analyzeCmd.Flags().IntVar(&cmd.Timeout, "timeout", 120, "Timeout until analyze should stop waiting") |
| 53 | analyzeCmd.Flags().BoolVar(&cmd.Patient, "patient", false, "If true, analyze will ignore failing pods and events until every deployment, statefulset, replicaset and pods are ready or the timeout is reached") |
| 54 | analyzeCmd.Flags().BoolVar(&cmd.IgnorePodRestarts, "ignore-pod-restarts", false, "If true, analyze will ignore the restart events of running pods") |
| 55 | |
| 56 | return analyzeCmd |
| 57 | } |
| 58 | |
| 59 | // RunAnalyze executes the functionality "devspace analyze" |
| 60 | func (cmd *AnalyzeCmd) RunAnalyze(f factory.Factory, cobraCmd *cobra.Command, args []string) error { |
no test coverage detected