Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
b040513a
Commit
b040513a
authored
May 10, 2017
by
Kubernetes Submit Queue
Committed by
GitHub
May 10, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #43067 from xilabao/dedup-in-printer
Automatic merge from submit-queue De-duplication in printer
parents
35837d80
697efd1b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
11 deletions
+8
-11
humanreadable.go
pkg/printers/humanreadable.go
+7
-10
printers.go
pkg/printers/internalversion/printers.go
+0
-0
printers_test.go
pkg/printers/internalversion/printers_test.go
+1
-1
No files found.
pkg/printers/humanreadable.go
View file @
b040513a
...
...
@@ -300,7 +300,7 @@ func printUnstructured(unstructured runtime.Unstructured, w io.Writer, additiona
}
}
name
:=
f
ormatResourceName
(
options
.
Kind
,
metadata
.
GetName
(),
options
.
WithKind
)
name
:=
F
ormatResourceName
(
options
.
Kind
,
metadata
.
GetName
(),
options
.
WithKind
)
if
_
,
err
:=
fmt
.
Fprintf
(
w
,
"%s
\t
%s"
,
name
,
kind
);
err
!=
nil
{
return
err
...
...
@@ -319,10 +319,10 @@ func printUnstructured(unstructured runtime.Unstructured, w io.Writer, additiona
}
}
}
if
_
,
err
:=
fmt
.
Fprint
(
w
,
a
ppendLabels
(
metadata
.
GetLabels
(),
options
.
ColumnLabels
));
err
!=
nil
{
if
_
,
err
:=
fmt
.
Fprint
(
w
,
A
ppendLabels
(
metadata
.
GetLabels
(),
options
.
ColumnLabels
));
err
!=
nil
{
return
err
}
if
_
,
err
:=
fmt
.
Fprint
(
w
,
a
ppendAllLabels
(
options
.
ShowLabels
,
metadata
.
GetLabels
()));
err
!=
nil
{
if
_
,
err
:=
fmt
.
Fprint
(
w
,
A
ppendAllLabels
(
options
.
ShowLabels
,
metadata
.
GetLabels
()));
err
!=
nil
{
return
err
}
...
...
@@ -349,10 +349,9 @@ func formatShowLabelsHeader(showLabels bool, t reflect.Type) []string {
return
nil
}
//
f
ormatResourceName receives a resource kind, name, and boolean specifying
//
F
ormatResourceName receives a resource kind, name, and boolean specifying
// whether or not to update the current name to "kind/name"
// TODO: dedup this with printers/internalversions
func
formatResourceName
(
kind
,
name
string
,
withKind
bool
)
string
{
func
FormatResourceName
(
kind
,
name
string
,
withKind
bool
)
string
{
if
!
withKind
||
kind
==
""
{
return
name
}
...
...
@@ -360,8 +359,7 @@ func formatResourceName(kind, name string, withKind bool) string {
return
kind
+
"/"
+
name
}
// TODO: dedup this with printers/internalversions
func
appendLabels
(
itemLabels
map
[
string
]
string
,
columnLabels
[]
string
)
string
{
func
AppendLabels
(
itemLabels
map
[
string
]
string
,
columnLabels
[]
string
)
string
{
var
buffer
bytes
.
Buffer
for
_
,
cl
:=
range
columnLabels
{
...
...
@@ -378,8 +376,7 @@ func appendLabels(itemLabels map[string]string, columnLabels []string) string {
// Append all labels to a single column. We need this even when show-labels flag* is
// false, since this adds newline delimiter to the end of each row.
// TODO: dedup this with printers/internalversions
func
appendAllLabels
(
showLabels
bool
,
itemLabels
map
[
string
]
string
)
string
{
func
AppendAllLabels
(
showLabels
bool
,
itemLabels
map
[
string
]
string
)
string
{
var
buffer
bytes
.
Buffer
if
showLabels
{
...
...
pkg/printers/internalversion/printers.go
View file @
b040513a
This diff is collapsed.
Click to expand it.
pkg/printers/internalversion/printers_test.go
View file @
b040513a
...
...
@@ -236,7 +236,7 @@ func TestFormatResourceName(t *testing.T) {
{
"kind"
,
"name"
,
"kind/name"
},
}
for
_
,
tt
:=
range
tests
{
if
got
:=
f
ormatResourceName
(
tt
.
kind
,
tt
.
name
,
true
);
got
!=
tt
.
want
{
if
got
:=
printers
.
F
ormatResourceName
(
tt
.
kind
,
tt
.
name
,
true
);
got
!=
tt
.
want
{
t
.
Errorf
(
"formatResourceName(%q, %q) = %q, want %q"
,
tt
.
kind
,
tt
.
name
,
got
,
tt
.
want
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment