@@ -40,6 +40,20 @@ type logOptions struct {
4040 runName string
4141}
4242
43+ func nameArg (args []string , p cli.Params ) error {
44+ if len (args ) == 1 {
45+ c , err := p .Clients ()
46+ if err != nil {
47+ return err
48+ }
49+ name , ns := args [0 ], p .Namespace ()
50+ if _ , err = c .Tekton .TektonV1alpha1 ().Pipelines (ns ).Get (name , metav1.GetOptions {}); err != nil {
51+ return err
52+ }
53+ }
54+ return nil
55+ }
56+
4357func logCommand (p cli.Params ) * cobra.Command {
4458 opts := & logOptions {params : p ,
4559 askOpts : func (opt * survey.AskOptions ) error {
@@ -72,6 +86,9 @@ func logCommand(p cli.Params) *cobra.Command {
7286 Short : "Show pipeline logs" ,
7387 Example : eg ,
7488 SilenceUsage : true ,
89+ Args : func (cmd * cobra.Command , args []string ) error {
90+ return nameArg (args , p )
91+ },
7592 RunE : func (cmd * cobra.Command , args []string ) error {
7693 opts .stream = & cli.Stream {
7794 Out : cmd .OutOrStdout (),
@@ -100,6 +117,8 @@ func (opts *logOptions) run(args []string) error {
100117 PipelineRunName : opts .runName ,
101118 Stream : opts .stream ,
102119 Params : opts .params ,
120+ Follow : opts .follow ,
121+ AllSteps : opts .allSteps ,
103122 }
104123
105124 return runLogOpts .Run ()
@@ -117,10 +136,6 @@ func (opts *logOptions) init(args []string) error {
117136
118137 case 1 : // pipeline name provided
119138 opts .pipelineName = args [0 ]
120- err := verify (opts .pipelineName , opts .params )
121- if err != nil {
122- return err
123- }
124139 if opts .last {
125140 return opts .initLastRunName ()
126141 }
@@ -142,7 +157,7 @@ func (opts *logOptions) getAllInputs() error {
142157 return err
143158 }
144159
145- if len (ps ) < 1 {
160+ if len (ps ) == 0 {
146161 fmt .Fprintln (opts .stream .Err , "No pipelines found in namespace:" , opts .params .Namespace ())
147162 return nil
148163 }
@@ -171,7 +186,7 @@ func (opts *logOptions) askRunName() error {
171186 if err != nil {
172187 return err
173188 }
174- if len (prs ) < 1 {
189+ if len (prs ) == 0 {
175190 fmt .Fprintln (opts .stream .Err , "No pipelineruns found for pipeline:" , opts .pipelineName )
176191 return nil
177192 }
@@ -194,19 +209,6 @@ func (opts *logOptions) askRunName() error {
194209 return nil
195210}
196211
197- func verify (pname string , params cli.Params ) error {
198- cs , err := params .Clients ()
199- if err != nil {
200- return err
201- }
202-
203- tkn := cs .Tekton .TektonV1alpha1 ()
204- if _ , err = tkn .Pipelines (params .Namespace ()).Get (pname , metav1.GetOptions {}); err != nil {
205- return err
206- }
207- return nil
208- }
209-
210212func (opts * logOptions ) initLastRunName () error {
211213 cs , err := opts .params .Clients ()
212214 if err != nil {
0 commit comments