@@ -40,6 +40,20 @@ type logOptions struct {
40
40
runName string
41
41
}
42
42
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
+
43
57
func logCommand (p cli.Params ) * cobra.Command {
44
58
opts := & logOptions {params : p ,
45
59
askOpts : func (opt * survey.AskOptions ) error {
@@ -72,6 +86,9 @@ func logCommand(p cli.Params) *cobra.Command {
72
86
Short : "Show pipeline logs" ,
73
87
Example : eg ,
74
88
SilenceUsage : true ,
89
+ Args : func (cmd * cobra.Command , args []string ) error {
90
+ return nameArg (args , p )
91
+ },
75
92
RunE : func (cmd * cobra.Command , args []string ) error {
76
93
opts .stream = & cli.Stream {
77
94
Out : cmd .OutOrStdout (),
@@ -100,6 +117,8 @@ func (opts *logOptions) run(args []string) error {
100
117
PipelineRunName : opts .runName ,
101
118
Stream : opts .stream ,
102
119
Params : opts .params ,
120
+ Follow : opts .follow ,
121
+ AllSteps : opts .allSteps ,
103
122
}
104
123
105
124
return runLogOpts .Run ()
@@ -117,10 +136,6 @@ func (opts *logOptions) init(args []string) error {
117
136
118
137
case 1 : // pipeline name provided
119
138
opts .pipelineName = args [0 ]
120
- err := verify (opts .pipelineName , opts .params )
121
- if err != nil {
122
- return err
123
- }
124
139
if opts .last {
125
140
return opts .initLastRunName ()
126
141
}
@@ -142,7 +157,7 @@ func (opts *logOptions) getAllInputs() error {
142
157
return err
143
158
}
144
159
145
- if len (ps ) < 1 {
160
+ if len (ps ) == 0 {
146
161
fmt .Fprintln (opts .stream .Err , "No pipelines found in namespace:" , opts .params .Namespace ())
147
162
return nil
148
163
}
@@ -171,7 +186,7 @@ func (opts *logOptions) askRunName() error {
171
186
if err != nil {
172
187
return err
173
188
}
174
- if len (prs ) < 1 {
189
+ if len (prs ) == 0 {
175
190
fmt .Fprintln (opts .stream .Err , "No pipelineruns found for pipeline:" , opts .pipelineName )
176
191
return nil
177
192
}
@@ -194,19 +209,6 @@ func (opts *logOptions) askRunName() error {
194
209
return nil
195
210
}
196
211
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
-
210
212
func (opts * logOptions ) initLastRunName () error {
211
213
cs , err := opts .params .Clients ()
212
214
if err != nil {
0 commit comments