// TestFlagParity makes sure that our copied flags don't slip during rebases func TestFlagParity(t *testing.T) { kubeCmd := kcmd.NewCmdLog(nil, ioutil.Discard) originCmd := NewCmdLogs("", nil, ioutil.Discard) kubeCmd.LocalFlags().VisitAll(func(kubeFlag *pflag.Flag) { originFlag := originCmd.LocalFlags().Lookup(kubeFlag.Name) if originFlag == nil { t.Errorf("missing %v flag", kubeFlag.Name) return } if !reflect.DeepEqual(originFlag, kubeFlag) { t.Errorf("flag %v %v does not match %v", kubeFlag.Name, kubeFlag, originFlag) } }) }
// NewCmdLogs creates a new logs command that supports OpenShift resources. func NewCmdLogs(fullName string, f *clientcmd.Factory, out io.Writer) *cobra.Command { o := OpenShiftLogsOptions{ KubeLogOptions: &kcmd.LogsOptions{}, } cmd := kcmd.NewCmdLog(f.Factory, out) cmd.Short = "Print the logs for a resource." cmd.Long = logsLong cmd.Example = fmt.Sprintf(logsExample, fullName) cmd.Run = func(cmd *cobra.Command, args []string) { cmdutil.CheckErr(o.Complete(f, out, cmd, args)) if err := o.Validate(); err != nil { cmdutil.CheckErr(cmdutil.UsageError(cmd, err.Error())) } cmdutil.CheckErr(o.RunLog()) } return cmd }
// NewCmdLogs creates a new logs command that supports OpenShift resources. func NewCmdLogs(name, parent string, f *clientcmd.Factory, out io.Writer) *cobra.Command { o := OpenShiftLogsOptions{ KubeLogOptions: &kcmd.LogsOptions{}, } cmd := kcmd.NewCmdLog(f.Factory, out) cmd.Short = "Print the logs for a resource." cmd.Long = logsLong cmd.Example = fmt.Sprintf(logsExample, name+" "+parent) cmd.SuggestFor = []string{"builds", "deployments"} cmd.Run = func(cmd *cobra.Command, args []string) { cmdutil.CheckErr(o.Complete(f, out, cmd, args)) if err := o.Validate(); err != nil { cmdutil.CheckErr(cmdutil.UsageError(cmd, err.Error())) } cmdutil.CheckErr(o.RunLog()) } cmd.Flags().Int64("version", 0, "View the logs of a particular build or deployment by version if greater than zero") return cmd }
// NewCmdLogs is a wrapper for the Kubernetes cli logs command func NewCmdLogs(fullName string, f *clientcmd.Factory, out io.Writer) *cobra.Command { cmd := kcmd.NewCmdLog(f.Factory, out) cmd.Long = logsLong cmd.Example = fmt.Sprintf(logsExample, fullName) return cmd }