forked from tektoncd/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add flag to list PipelineRuns from all namespaces
Passing the --all-namespaces flag to the pipelinerun list subcommands enables users to view pipelineruns in all namespaces grouped by namespace and sorted by startime
- Loading branch information
1 parent
23c0c06
commit fad74a6
Showing
14 changed files
with
334 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
pkg/cmd/pipelinerun/testdata/TestListPipelineRuns-all_in_namespace.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
NAME STARTED DURATION STATUS | ||
pr0-1 --- --- --- | ||
pr3-1 --- --- --- | ||
pr1-1 59 minutes ago 1 minute Succeeded | ||
pr2-2 2 hours ago 1 minute Failed | ||
pr2-1 3 hours ago --- Succeeded(Running) | ||
NAME STARTED DURATION STATUS | ||
pr0-1 --- --- --- | ||
pr3-1 --- --- --- | ||
pr1-1 59 minutes ago 1 minute Succeeded | ||
pr2-2 2 hours ago 1 minute Failed | ||
pr2-1 3 hours ago --- Succeeded(Running) |
4 changes: 2 additions & 2 deletions
4
pkg/cmd/pipelinerun/testdata/TestListPipelineRuns-by_pipeline_name.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
NAME STARTED DURATION STATUS | ||
pr1-1 59 minutes ago 1 minute Succeeded | ||
NAME STARTED DURATION STATUS | ||
pr1-1 59 minutes ago 1 minute Succeeded |
4 changes: 2 additions & 2 deletions
4
pkg/cmd/pipelinerun/testdata/TestListPipelineRuns-filter_pipelineruns_by_label.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
NAME STARTED DURATION STATUS | ||
pr3-1 --- --- --- | ||
NAME STARTED DURATION STATUS | ||
pr3-1 --- --- --- |
6 changes: 3 additions & 3 deletions
6
...pelinerun/testdata/TestListPipelineRuns-filter_pipelineruns_by_label_with_in_query.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
NAME STARTED DURATION STATUS | ||
pr3-1 --- --- --- | ||
pr2-2 2 hours ago 1 minute Failed | ||
NAME STARTED DURATION STATUS | ||
pr3-1 --- --- --- | ||
pr2-2 2 hours ago 1 minute Failed |
12 changes: 6 additions & 6 deletions
12
...linerun/testdata/TestListPipelineRuns-limit_pipelineruns_greater_than_maximum_case.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
NAME STARTED DURATION STATUS | ||
pr0-1 --- --- --- | ||
pr3-1 --- --- --- | ||
pr1-1 59 minutes ago 1 minute Succeeded | ||
pr2-2 2 hours ago 1 minute Failed | ||
pr2-1 3 hours ago --- Succeeded(Running) | ||
NAME STARTED DURATION STATUS | ||
pr0-1 --- --- --- | ||
pr3-1 --- --- --- | ||
pr1-1 59 minutes ago 1 minute Succeeded | ||
pr2-2 2 hours ago 1 minute Failed | ||
pr2-1 3 hours ago --- Succeeded(Running) |
4 changes: 2 additions & 2 deletions
4
pkg/cmd/pipelinerun/testdata/TestListPipelineRuns-limit_pipelineruns_returned_to_1.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
NAME STARTED DURATION STATUS | ||
pr0-1 --- --- --- | ||
NAME STARTED DURATION STATUS | ||
pr0-1 --- --- --- |
12 changes: 6 additions & 6 deletions
12
pkg/cmd/pipelinerun/testdata/TestListPipelineRuns-print_in_reverse.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
NAME STARTED DURATION STATUS | ||
pr2-1 3 hours ago --- Succeeded(Running) | ||
pr2-2 2 hours ago 1 minute Failed | ||
pr1-1 59 minutes ago 1 minute Succeeded | ||
pr3-1 --- --- --- | ||
pr0-1 --- --- --- | ||
NAME STARTED DURATION STATUS | ||
pr2-1 3 hours ago --- Succeeded(Running) | ||
pr2-2 2 hours ago 1 minute Failed | ||
pr1-1 59 minutes ago 1 minute Succeeded | ||
pr3-1 --- --- --- | ||
pr0-1 --- --- --- |
3 changes: 3 additions & 0 deletions
3
...cmd/pipelinerun/testdata/TestListPipelineRuns-print_pipelineruns_in_all_namespaces.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
NAMESPACE NAME STARTED DURATION STATUS | ||
namespace-lacher pr4-2 --- --- --- | ||
namespace-tout pr4-1 --- --- --- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright © 2020 The Tekton Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package pipelinerun | ||
|
||
import ( | ||
"sort" | ||
|
||
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" | ||
) | ||
|
||
func SortByNamespace(prs []v1alpha1.PipelineRun) { | ||
sort.Sort(byNamespace(prs)) | ||
} | ||
|
||
type byNamespace []v1alpha1.PipelineRun | ||
|
||
func (prs byNamespace) compareNamespace(ins, jns string) (lt, eq bool) { | ||
lt, eq = ins < jns, ins == jns | ||
return lt, eq | ||
} | ||
|
||
func (prs byNamespace) Len() int { return len(prs) } | ||
func (prs byNamespace) Swap(i, j int) { prs[i], prs[j] = prs[j], prs[i] } | ||
func (prs byNamespace) Less(i, j int) bool { | ||
var lt, eq bool | ||
if lt, eq = prs.compareNamespace(prs[i].Namespace, prs[j].Namespace); eq { | ||
if prs[j].Status.StartTime == nil { | ||
return false | ||
} | ||
if prs[i].Status.StartTime == nil { | ||
return true | ||
} | ||
return prs[j].Status.StartTime.Before(prs[i].Status.StartTime) | ||
} | ||
return lt | ||
} |
Oops, something went wrong.