NewLogsCmd creates a new login command
(f factory.Factory, globalFlags *flags.GlobalFlags)
| 41 | |
| 42 | // NewLogsCmd creates a new login command |
| 43 | func NewLogsCmd(f factory.Factory, globalFlags *flags.GlobalFlags) *cobra.Command { |
| 44 | cmd := &LogsCmd{GlobalFlags: globalFlags} |
| 45 | |
| 46 | logsCmd := &cobra.Command{ |
| 47 | Use: "logs", |
| 48 | Short: "Prints the logs of a pod and attaches to it", |
| 49 | Long: ` |
| 50 | ####################################################### |
| 51 | #################### devspace logs #################### |
| 52 | ####################################################### |
| 53 | Prints the last log of a pod container and attachs |
| 54 | to it |
| 55 | |
| 56 | Example: |
| 57 | devspace logs |
| 58 | devspace logs --namespace=mynamespace |
| 59 | ####################################################### |
| 60 | `, |
| 61 | Args: cobra.NoArgs, |
| 62 | RunE: func(cobraCmd *cobra.Command, args []string) error { |
| 63 | plugin.SetPluginCommand(cobraCmd, args) |
| 64 | return cmd.RunLogs(f) |
| 65 | }, |
| 66 | } |
| 67 | |
| 68 | logsCmd.Flags().StringVarP(&cmd.Container, "container", "c", "", "Container name within pod where to execute command") |
| 69 | logsCmd.Flags().StringVar(&cmd.Pod, "pod", "", "Pod to print the logs of") |
| 70 | logsCmd.Flags().StringVarP(&cmd.LabelSelector, "label-selector", "l", "", "Comma separated key=value selector list (e.g. release=test)") |
| 71 | logsCmd.Flags().StringVar(&cmd.ImageSelector, "image-selector", "", "The image to search a pod for (e.g. nginx, nginx:latest, ${runtime.images.app}, nginx:${runtime.images.app.tag})") |
| 72 | logsCmd.Flags().BoolVar(&cmd.Pick, "pick", true, "Select a pod") |
| 73 | logsCmd.Flags().BoolVarP(&cmd.Follow, "follow", "f", false, "Attach to logs afterwards") |
| 74 | logsCmd.Flags().IntVar(&cmd.LastAmountOfLines, "lines", 200, "Max amount of lines to print from the last log") |
| 75 | logsCmd.Flags().BoolVar(&cmd.Wait, "wait", false, "Wait for the pod(s) to start if they are not running") |
| 76 | |
| 77 | return logsCmd |
| 78 | } |
| 79 | |
| 80 | // RunLogs executes the functionality devspace logs |
| 81 | func (cmd *LogsCmd) RunLogs(f factory.Factory) error { |
no test coverage detected