NewCmdLogs creates a new pod logs command
(f cmdutil.Factory, streams genericiooptions.IOStreams)
| 171 | |
| 172 | // NewCmdLogs creates a new pod logs command |
| 173 | func NewCmdLogs(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command { |
| 174 | o := NewLogsOptions(streams) |
| 175 | |
| 176 | cmd := &cobra.Command{ |
| 177 | Use: logsUsageStr, |
| 178 | DisableFlagsInUseLine: true, |
| 179 | Short: i18n.T("Print the logs for a container in a pod"), |
| 180 | Long: logsLong, |
| 181 | Example: logsExample, |
| 182 | ValidArgsFunction: completion.PodResourceNameAndContainerCompletionFunc(f), |
| 183 | Run: func(cmd *cobra.Command, args []string) { |
| 184 | cmdutil.CheckErr(o.Complete(f, cmd, args)) |
| 185 | cmdutil.CheckErr(o.Validate()) |
| 186 | cmdutil.CheckErr(o.RunLogsContext(cmd.Context())) |
| 187 | }, |
| 188 | } |
| 189 | o.AddFlags(cmd) |
| 190 | return cmd |
| 191 | } |
| 192 | |
| 193 | func (o *LogsOptions) AddFlags(cmd *cobra.Command) { |
| 194 | cmd.Flags().BoolVar(&o.AllPods, "all-pods", o.AllPods, "Get logs from all pod(s). Sets prefix to true.") |
searching dependent graphs…