Skip to content

Commit b8482af

Browse files
divyansh42tekton-robot
authored andcommitted
Fix endpoints for the all-namespaces flag
Move parent for the all-namespace flag to a constant and also moved initialization of params to PreRun to maintain consitency Signed-off-by: divyansh42 <diagrawa@redhat.com>
1 parent a288bea commit b8482af

File tree

13 files changed

+31
-55
lines changed

13 files changed

+31
-55
lines changed

docs/cli/tkn-results_pipelinerun_logs.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ Get logs for a PipelineRun in a specific namespace:
2626
Get logs for a PipelineRun by UID if there are multiple PipelineRuns with the same name:
2727
tkn-results pipelinerun logs --uid 12345678-1234-1234-1234-1234567890ab
2828
29-
Get logs for a PipelineRun from all namespaces:
30-
tkn-results pipelinerun logs foo -A
31-
3229
```
3330

3431
### Options

docs/cli/tkn-results_taskrun_logs.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ Get logs for a TaskRun in a specific namespace:
2525
Get logs for a TaskRun by UID if there are multiple TaskRun with the same name:
2626
tkn-results taskrun logs --uid 12345678-1234-1234-1234-1234567890ab
2727
28-
Get logs for a TaskRun from all namespaces:
29-
tkn-results taskrun logs foo -A
30-
3128
```
3229

3330
### Options

docs/man/man1/tkn-results-pipelinerun-logs.1

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,6 @@ Get logs for a PipelineRun in a specific namespace:
9595
Get logs for a PipelineRun by UID if there are multiple PipelineRuns with the same name:
9696
tkn-results pipelinerun logs --uid 12345678-1234-1234-1234-1234567890ab
9797
98-
Get logs for a PipelineRun from all namespaces:
99-
tkn-results pipelinerun logs foo -A
100-
10198
.EE
10299

103100

docs/man/man1/tkn-results-taskrun-logs.1

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ Get logs for a TaskRun in a specific namespace:
9494
Get logs for a TaskRun by UID if there are multiple TaskRun with the same name:
9595
tkn-results taskrun logs --uid 12345678-1234-1234-1234-1234567890ab
9696
97-
Get logs for a TaskRun from all namespaces:
98-
tkn-results taskrun logs foo -A
99-
10097
.EE
10198

10299

pkg/cli/cmd/pipelinerun/describe.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,20 +147,20 @@ Describe a PipelineRun as json:
147147
}
148148
return nil
149149
},
150-
PreRunE: func(cmd *cobra.Command, _ []string) error {
150+
PreRunE: func(cmd *cobra.Command, args []string) error {
151151
// Initialize the client using the shared prerun function
152152
var err error
153153
opts.Client, err = prerun.InitClient(p, cmd)
154154
if err != nil {
155155
return err
156156
}
157-
return nil
158-
},
159-
RunE: func(cmd *cobra.Command, args []string) error {
160-
ctx := cmd.Context()
161157
if len(args) > 0 {
162158
opts.ResourceName = args[0]
163159
}
160+
return nil
161+
},
162+
RunE: func(cmd *cobra.Command, _ []string) error {
163+
ctx := cmd.Context()
164164

165165
// Build filter string to find the PipelineRun
166166
filter := common.BuildFilterString(opts)

pkg/cli/cmd/pipelinerun/list.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ NAME UID STARTED DURATION STATUS
3535
{{ end -}}
3636
{{- end -}}
3737
{{- range $_, $pr := .PipelineRuns.Items }}{{- if $pr }}{{- if $.AllNamespaces -}}
38-
{{ $pr.Namespace }} {{ $pr.Name }} {{ $pr.UID }} {{ formatAge $pr.Status.StartTime $.Time }} {{ formatDuration $pr.Status.StartTime $pr.Status.CompletionTime }} {{ formatCondition $pr.Status.Conditions }}
38+
{{ $pr.Namespace }} {{ $pr.Name }} {{ $pr.UID }} {{ formatAge $pr.Status.StartTime $.Time }} {{ formatDuration $pr.Status.StartTime $pr.Status.CompletionTime }} {{ formatCondition $pr.Status.Conditions }}
3939
{{ else -}}
4040
{{ $pr.Name }} {{ $pr.UID }} {{ formatAge $pr.Status.StartTime $.Time }} {{ formatDuration $pr.Status.StartTime $pr.Status.CompletionTime }} {{ formatCondition $pr.Status.Conditions }}
4141
{{ end -}}{{- end -}}{{- end -}}
@@ -85,27 +85,22 @@ List PipelineRuns with partial pipeline name match:
8585
if allNs && nsSet {
8686
return errors.New("cannot use --all-namespaces/-A and --namespace/-n together")
8787
}
88-
8988
// Initialize the client
9089
var err error
9190
opts.Client, err = prerun.InitClient(p, cmd)
9291
if err != nil {
9392
return err
9493
}
95-
9694
if opts.Limit < 5 || opts.Limit > 1000 {
9795
return errors.New("limit should be between 5 and 1000")
9896
}
99-
100-
if len(args) > 0 {
101-
opts.ResourceName = args[0]
102-
}
103-
10497
// Validate label format if provided
10598
if opts.Label != "" {
10699
return common.ValidateLabels(opts.Label)
107100
}
108-
101+
if len(args) > 0 {
102+
opts.ResourceName = args[0]
103+
}
109104
return nil
110105
},
111106
RunE: func(cmd *cobra.Command, _ []string) error {
@@ -115,7 +110,7 @@ List PipelineRuns with partial pipeline name match:
115110
// Handle all namespaces
116111
parent := fmt.Sprintf("%s/results/-", p.Namespace())
117112
if opts.AllNamespaces {
118-
parent = "*/results/-"
113+
parent = common.AllNamespacesResultsParent
119114
}
120115

121116
// Create initial request

pkg/cli/cmd/pipelinerun/list_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ func TestListCommand(t *testing.T) {
297297
// Handle all namespaces
298298
parent := fmt.Sprintf("%s/results/-", params.Namespace())
299299
if opts.AllNamespaces {
300-
parent = "*/results/-"
300+
parent = common.AllNamespacesResultsParent
301301
}
302302

303303
// Create initial request

pkg/cli/cmd/pipelinerun/logs.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ Get logs for a PipelineRun in a specific namespace:
3030
3131
Get logs for a PipelineRun by UID if there are multiple PipelineRuns with the same name:
3232
tkn-results pipelinerun logs --uid 12345678-1234-1234-1234-1234567890ab
33-
34-
Get logs for a PipelineRun from all namespaces:
35-
tkn-results pipelinerun logs foo -A
3633
`
3734

3835
cmd := &cobra.Command{
@@ -58,20 +55,20 @@ Additionally, PipelineRun logs are not supported for S3 log storage.`,
5855
}
5956
return nil
6057
},
61-
PreRunE: func(cmd *cobra.Command, _ []string) error {
58+
PreRunE: func(cmd *cobra.Command, args []string) error {
6259
// Initialize the client using the shared prerun function
6360
var err error
6461
opts.Client, err = prerun.InitClient(p, cmd)
6562
if err != nil {
6663
return err
6764
}
68-
return nil
69-
},
70-
RunE: func(cmd *cobra.Command, args []string) error {
71-
ctx := cmd.Context()
7265
if len(args) > 0 {
7366
opts.ResourceName = args[0]
7467
}
68+
return nil
69+
},
70+
RunE: func(cmd *cobra.Command, _ []string) error {
71+
ctx := cmd.Context()
7572

7673
// Build filter string to find the PipelineRun
7774
filter := common.BuildFilterString(opts)

pkg/cli/cmd/taskrun/describe.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,19 @@ Describe a TaskRun as json
108108
}
109109
return nil
110110
},
111-
PreRunE: func(cmd *cobra.Command, _ []string) error {
111+
PreRunE: func(cmd *cobra.Command, args []string) error {
112112
var err error
113113
opts.Client, err = prerun.InitClient(p, cmd)
114114
if err != nil {
115115
return err
116116
}
117-
return nil
118-
},
119-
RunE: func(cmd *cobra.Command, args []string) error {
120-
ctx := cmd.Context()
121117
if len(args) > 0 {
122118
opts.ResourceName = args[0]
123119
}
120+
return nil
121+
},
122+
RunE: func(cmd *cobra.Command, _ []string) error {
123+
ctx := cmd.Context()
124124

125125
filter := common.BuildFilterString(opts)
126126
parent := fmt.Sprintf("%s/results/-", p.Namespace())

pkg/cli/cmd/taskrun/list.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ NAME UID STARTED DURATION STATUS
3535
{{ end -}}
3636
{{- end -}}
3737
{{- range $_, $tr := .TaskRuns.Items }}{{- if $tr }}{{- if $.AllNamespaces -}}
38-
{{ $tr.Namespace }} {{ $tr.Name }} {{ $tr.UID }} {{ formatAge $tr.Status.StartTime $.Time }} {{ formatDuration $tr.Status.StartTime $tr.Status.CompletionTime }} {{ formatCondition $tr.Status.Conditions }}
38+
{{ $tr.Namespace }} {{ $tr.Name }} {{ $tr.UID }} {{ formatAge $tr.Status.StartTime $.Time }} {{ formatDuration $tr.Status.StartTime $tr.Status.CompletionTime }} {{ formatCondition $tr.Status.Conditions }}
3939
{{ else -}}
4040
{{ $tr.Name }} {{ $tr.UID }} {{ formatAge $tr.Status.StartTime $.Time }} {{ formatDuration $tr.Status.StartTime $tr.Status.CompletionTime }} {{ formatCondition $tr.Status.Conditions }}
4141
{{ end -}}{{- end -}}{{- end -}}
@@ -88,7 +88,6 @@ List TaskRuns for a specific PipelineRun:
8888
if allNs && nsSet {
8989
return errors.New("cannot use --all-namespaces/-A and --namespace/-n together")
9090
}
91-
9291
// Initialize the client using the shared prerun function
9392
var err error
9493
opts.Client, err = prerun.InitClient(p, cmd)
@@ -99,12 +98,10 @@ List TaskRuns for a specific PipelineRun:
9998
if opts.Limit < 5 || opts.Limit > 1000 {
10099
return errors.New("limit should be between 5 and 1000")
101100
}
102-
103101
// Validate label format if provided
104102
if opts.Label != "" {
105103
return common.ValidateLabels(opts.Label)
106104
}
107-
108105
if len(args) > 0 {
109106
opts.ResourceName = args[0]
110107
}
@@ -131,7 +128,7 @@ func listTaskRuns(ctx context.Context, p common.Params, opts *options.ListOption
131128
// Handle all namespaces
132129
parent := fmt.Sprintf("%s/results/-", p.Namespace())
133130
if opts.AllNamespaces {
134-
parent = "*/results/-"
131+
parent = common.AllNamespacesResultsParent
135132
}
136133

137134
// Create initial request

0 commit comments

Comments
 (0)