// TestLogsFlagParity makes sure that our copied flags don't slip during rebases func TestLogsFlagParity(t *testing.T) { kubeCmd := kcmd.NewCmdLogs(nil, ioutil.Discard) f := clientcmd.NewFactory(nil) originCmd := NewCmdLogs("oc", "logs", f, 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(name, parent string, f *clientcmd.Factory, out io.Writer) *cobra.Command { o := OpenShiftLogsOptions{ KubeLogOptions: &kcmd.LogsOptions{}, } cmd := kcmd.NewCmdLogs(f.Factory, out) cmd.Short = "Print the logs for a resource." cmd.Long = logsLong cmd.Example = fmt.Sprintf(logsExample, parent+" "+name) cmd.SuggestFor = []string{"builds", "deployments"} cmd.Run = func(cmd *cobra.Command, args []string) { kcmdutil.CheckErr(o.Complete(f, out, cmd, args)) if err := o.Validate(); err != nil { kcmdutil.CheckErr(kcmdutil.UsageError(cmd, err.Error())) } kcmdutil.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 }