MCPcopy Index your code
hub / github.com/devspace-sh/devspace / NewLogsCmd

Function NewLogsCmd

cmd/logs.go:43–78  ·  view source on GitHub ↗

NewLogsCmd creates a new login command

(f factory.Factory, globalFlags *flags.GlobalFlags)

Source from the content-addressed store, hash-verified

41
42// NewLogsCmd creates a new login command
43func 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#######################################################
53Prints the last log of a pod container and attachs
54to it
55
56Example:
57devspace logs
58devspace 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
81func (cmd *LogsCmd) RunLogs(f factory.Factory) error {

Callers 1

BuildRootFunction · 0.85

Calls 2

RunLogsMethod · 0.95
SetPluginCommandFunction · 0.92

Tested by

no test coverage detected