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
2b1a2d36
Commit
2b1a2d36
authored
Dec 28, 2018
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use tabwriter with remembered column widths
parent
096186af
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
30 additions
and
19 deletions
+30
-19
BUILD
pkg/kubectl/cmd/config/BUILD
+1
-0
get_contexts.go
pkg/kubectl/cmd/config/get_contexts.go
+1
-1
BUILD
pkg/kubectl/cmd/get/BUILD
+1
-0
customcolumn.go
pkg/kubectl/cmd/get/customcolumn.go
+2
-1
get.go
pkg/kubectl/cmd/get/get.go
+5
-2
get_test.go
pkg/kubectl/cmd/get/get_test.go
+10
-10
BUILD
pkg/kubectl/util/printers/BUILD
+1
-0
tabwriter.go
pkg/kubectl/util/printers/tabwriter.go
+3
-2
BUILD
pkg/printers/BUILD
+1
-0
humanreadable.go
pkg/printers/humanreadable.go
+2
-1
tabwriter.go
pkg/printers/tabwriter.go
+3
-2
No files found.
pkg/kubectl/cmd/config/BUILD
View file @
2b1a2d36
...
@@ -41,6 +41,7 @@ go_library(
...
@@ -41,6 +41,7 @@ go_library(
"//staging/src/k8s.io/client-go/tools/clientcmd:go_default_library",
"//staging/src/k8s.io/client-go/tools/clientcmd:go_default_library",
"//staging/src/k8s.io/client-go/tools/clientcmd/api:go_default_library",
"//staging/src/k8s.io/client-go/tools/clientcmd/api:go_default_library",
"//staging/src/k8s.io/client-go/tools/clientcmd/api/latest:go_default_library",
"//staging/src/k8s.io/client-go/tools/clientcmd/api/latest:go_default_library",
"//vendor/github.com/liggitt/tabwriter:go_default_library",
"//vendor/github.com/spf13/cobra:go_default_library",
"//vendor/github.com/spf13/cobra:go_default_library",
],
],
)
)
...
...
pkg/kubectl/cmd/config/get_contexts.go
View file @
2b1a2d36
...
@@ -21,8 +21,8 @@ import (
...
@@ -21,8 +21,8 @@ import (
"io"
"io"
"sort"
"sort"
"strings"
"strings"
"text/tabwriter"
"github.com/liggitt/tabwriter"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
utilerrors
"k8s.io/apimachinery/pkg/util/errors"
utilerrors
"k8s.io/apimachinery/pkg/util/errors"
...
...
pkg/kubectl/cmd/get/BUILD
View file @
2b1a2d36
...
@@ -55,6 +55,7 @@ go_library(
...
@@ -55,6 +55,7 @@ go_library(
"//staging/src/k8s.io/client-go/tools/watch:go_default_library",
"//staging/src/k8s.io/client-go/tools/watch:go_default_library",
"//staging/src/k8s.io/client-go/util/integer:go_default_library",
"//staging/src/k8s.io/client-go/util/integer:go_default_library",
"//staging/src/k8s.io/client-go/util/jsonpath:go_default_library",
"//staging/src/k8s.io/client-go/util/jsonpath:go_default_library",
"//vendor/github.com/liggitt/tabwriter:go_default_library",
"//vendor/github.com/spf13/cobra:go_default_library",
"//vendor/github.com/spf13/cobra:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
"//vendor/vbom.ml/util/sortorder:go_default_library",
"//vendor/vbom.ml/util/sortorder:go_default_library",
...
...
pkg/kubectl/cmd/get/customcolumn.go
View file @
2b1a2d36
...
@@ -24,7 +24,8 @@ import (
...
@@ -24,7 +24,8 @@ import (
"reflect"
"reflect"
"regexp"
"regexp"
"strings"
"strings"
"text/tabwriter"
"github.com/liggitt/tabwriter"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime"
...
...
pkg/kubectl/cmd/get/get.go
View file @
2b1a2d36
...
@@ -537,6 +537,7 @@ func (o *GetOptions) Run(f cmdutil.Factory, cmd *cobra.Command, args []string) e
...
@@ -537,6 +537,7 @@ func (o *GetOptions) Run(f cmdutil.Factory, cmd *cobra.Command, args []string) e
if
shouldGetNewPrinterForMapping
(
printer
,
lastMapping
,
mapping
)
{
if
shouldGetNewPrinterForMapping
(
printer
,
lastMapping
,
mapping
)
{
w
.
Flush
()
w
.
Flush
()
w
.
SetRememberedWidths
(
nil
)
// TODO: this doesn't belong here
// TODO: this doesn't belong here
// add linebreak between resource groups (if there is more than one)
// add linebreak between resource groups (if there is more than one)
...
@@ -654,10 +655,11 @@ func (o *GetOptions) watch(f cmdutil.Factory, cmd *cobra.Command, args []string)
...
@@ -654,10 +655,11 @@ func (o *GetOptions) watch(f cmdutil.Factory, cmd *cobra.Command, args []string)
}
}
}
}
writer
:=
utilprinters
.
GetNewTabWriter
(
o
.
Out
)
// print the current object
// print the current object
if
!
o
.
WatchOnly
{
if
!
o
.
WatchOnly
{
var
objsToPrint
[]
runtime
.
Object
var
objsToPrint
[]
runtime
.
Object
writer
:=
utilprinters
.
GetNewTabWriter
(
o
.
Out
)
if
isList
{
if
isList
{
objsToPrint
,
_
=
meta
.
ExtractList
(
obj
)
objsToPrint
,
_
=
meta
.
ExtractList
(
obj
)
...
@@ -702,9 +704,10 @@ func (o *GetOptions) watch(f cmdutil.Factory, cmd *cobra.Command, args []string)
...
@@ -702,9 +704,10 @@ func (o *GetOptions) watch(f cmdutil.Factory, cmd *cobra.Command, args []string)
internalGV
:=
mapping
.
GroupVersionKind
.
GroupKind
()
.
WithVersion
(
runtime
.
APIVersionInternal
)
.
GroupVersion
()
internalGV
:=
mapping
.
GroupVersionKind
.
GroupKind
()
.
WithVersion
(
runtime
.
APIVersionInternal
)
.
GroupVersion
()
objToPrint
=
attemptToConvertToInternal
(
e
.
Object
,
legacyscheme
.
Scheme
,
internalGV
)
objToPrint
=
attemptToConvertToInternal
(
e
.
Object
,
legacyscheme
.
Scheme
,
internalGV
)
}
}
if
err
:=
printer
.
PrintObj
(
objToPrint
,
o
.
Out
);
err
!=
nil
{
if
err
:=
printer
.
PrintObj
(
objToPrint
,
writer
);
err
!=
nil
{
return
false
,
err
return
false
,
err
}
}
writer
.
Flush
()
return
false
,
nil
return
false
,
nil
})
})
return
err
return
err
...
...
pkg/kubectl/cmd/get/get_test.go
View file @
2b1a2d36
...
@@ -1211,8 +1211,8 @@ func TestWatchLabelSelector(t *testing.T) {
...
@@ -1211,8 +1211,8 @@ func TestWatchLabelSelector(t *testing.T) {
expected
:=
`NAME READY STATUS RESTARTS AGE
expected
:=
`NAME READY STATUS RESTARTS AGE
bar 0/0 0 <unknown>
bar 0/0 0 <unknown>
foo 0/0 0 <unknown>
foo 0/0 0 <unknown>
foo
0/0 0
<unknown>
foo
0/0 0
<unknown>
foo
0/0 0
<unknown>
foo
0/0 0
<unknown>
`
`
if
e
,
a
:=
expected
,
buf
.
String
();
e
!=
a
{
if
e
,
a
:=
expected
,
buf
.
String
();
e
!=
a
{
t
.
Errorf
(
"expected
\n
%v
\n
got
\n
%v"
,
e
,
a
)
t
.
Errorf
(
"expected
\n
%v
\n
got
\n
%v"
,
e
,
a
)
...
@@ -1262,8 +1262,8 @@ func TestWatchFieldSelector(t *testing.T) {
...
@@ -1262,8 +1262,8 @@ func TestWatchFieldSelector(t *testing.T) {
expected
:=
`NAME READY STATUS RESTARTS AGE
expected
:=
`NAME READY STATUS RESTARTS AGE
bar 0/0 0 <unknown>
bar 0/0 0 <unknown>
foo 0/0 0 <unknown>
foo 0/0 0 <unknown>
foo
0/0 0
<unknown>
foo
0/0 0
<unknown>
foo
0/0 0
<unknown>
foo
0/0 0
<unknown>
`
`
if
e
,
a
:=
expected
,
buf
.
String
();
e
!=
a
{
if
e
,
a
:=
expected
,
buf
.
String
();
e
!=
a
{
t
.
Errorf
(
"expected
\n
%v
\n
got
\n
%v"
,
e
,
a
)
t
.
Errorf
(
"expected
\n
%v
\n
got
\n
%v"
,
e
,
a
)
...
@@ -1305,8 +1305,8 @@ func TestWatchResource(t *testing.T) {
...
@@ -1305,8 +1305,8 @@ func TestWatchResource(t *testing.T) {
expected
:=
`NAME READY STATUS RESTARTS AGE
expected
:=
`NAME READY STATUS RESTARTS AGE
foo 0/0 0 <unknown>
foo 0/0 0 <unknown>
foo
0/0 0
<unknown>
foo
0/0 0
<unknown>
foo
0/0 0
<unknown>
foo
0/0 0
<unknown>
`
`
if
e
,
a
:=
expected
,
buf
.
String
();
e
!=
a
{
if
e
,
a
:=
expected
,
buf
.
String
();
e
!=
a
{
t
.
Errorf
(
"expected
\n
%v
\n
got
\n
%v"
,
e
,
a
)
t
.
Errorf
(
"expected
\n
%v
\n
got
\n
%v"
,
e
,
a
)
...
@@ -1349,8 +1349,8 @@ func TestWatchResourceIdentifiedByFile(t *testing.T) {
...
@@ -1349,8 +1349,8 @@ func TestWatchResourceIdentifiedByFile(t *testing.T) {
expected
:=
`NAME READY STATUS RESTARTS AGE
expected
:=
`NAME READY STATUS RESTARTS AGE
foo 0/0 0 <unknown>
foo 0/0 0 <unknown>
foo
0/0 0
<unknown>
foo
0/0 0
<unknown>
foo
0/0 0
<unknown>
foo
0/0 0
<unknown>
`
`
if
e
,
a
:=
expected
,
buf
.
String
();
e
!=
a
{
if
e
,
a
:=
expected
,
buf
.
String
();
e
!=
a
{
t
.
Errorf
(
"expected
\n
%v
\n
got
\n
%v"
,
e
,
a
)
t
.
Errorf
(
"expected
\n
%v
\n
got
\n
%v"
,
e
,
a
)
...
@@ -1392,7 +1392,7 @@ func TestWatchOnlyResource(t *testing.T) {
...
@@ -1392,7 +1392,7 @@ func TestWatchOnlyResource(t *testing.T) {
expected
:=
`NAME READY STATUS RESTARTS AGE
expected
:=
`NAME READY STATUS RESTARTS AGE
foo 0/0 0 <unknown>
foo 0/0 0 <unknown>
foo
0/0 0
<unknown>
foo
0/0 0
<unknown>
`
`
if
e
,
a
:=
expected
,
buf
.
String
();
e
!=
a
{
if
e
,
a
:=
expected
,
buf
.
String
();
e
!=
a
{
t
.
Errorf
(
"expected
\n
%v
\n
got
\n
%v"
,
e
,
a
)
t
.
Errorf
(
"expected
\n
%v
\n
got
\n
%v"
,
e
,
a
)
...
@@ -1437,7 +1437,7 @@ func TestWatchOnlyList(t *testing.T) {
...
@@ -1437,7 +1437,7 @@ func TestWatchOnlyList(t *testing.T) {
expected
:=
`NAME READY STATUS RESTARTS AGE
expected
:=
`NAME READY STATUS RESTARTS AGE
foo 0/0 0 <unknown>
foo 0/0 0 <unknown>
foo
0/0 0
<unknown>
foo
0/0 0
<unknown>
`
`
if
e
,
a
:=
expected
,
buf
.
String
();
e
!=
a
{
if
e
,
a
:=
expected
,
buf
.
String
();
e
!=
a
{
t
.
Errorf
(
"expected
\n
%v
\n
got
\n
%v"
,
e
,
a
)
t
.
Errorf
(
"expected
\n
%v
\n
got
\n
%v"
,
e
,
a
)
...
...
pkg/kubectl/util/printers/BUILD
View file @
2b1a2d36
...
@@ -5,6 +5,7 @@ go_library(
...
@@ -5,6 +5,7 @@ go_library(
srcs = ["tabwriter.go"],
srcs = ["tabwriter.go"],
importpath = "k8s.io/kubernetes/pkg/kubectl/util/printers",
importpath = "k8s.io/kubernetes/pkg/kubectl/util/printers",
visibility = ["//visibility:public"],
visibility = ["//visibility:public"],
deps = ["//vendor/github.com/liggitt/tabwriter:go_default_library"],
)
)
filegroup(
filegroup(
...
...
pkg/kubectl/util/printers/tabwriter.go
View file @
2b1a2d36
...
@@ -18,7 +18,8 @@ package printers
...
@@ -18,7 +18,8 @@ package printers
import
(
import
(
"io"
"io"
"text/tabwriter"
"github.com/liggitt/tabwriter"
)
)
const
(
const
(
...
@@ -26,7 +27,7 @@ const (
...
@@ -26,7 +27,7 @@ const (
tabwriterWidth
=
4
tabwriterWidth
=
4
tabwriterPadding
=
3
tabwriterPadding
=
3
tabwriterPadChar
=
' '
tabwriterPadChar
=
' '
tabwriterFlags
=
0
tabwriterFlags
=
tabwriter
.
RememberWidths
)
)
// GetNewTabWriter returns a tabwriter that translates tabbed columns in input into properly aligned text.
// GetNewTabWriter returns a tabwriter that translates tabbed columns in input into properly aligned text.
...
...
pkg/printers/BUILD
View file @
2b1a2d36
...
@@ -23,6 +23,7 @@ go_library(
...
@@ -23,6 +23,7 @@ go_library(
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
"//vendor/github.com/liggitt/tabwriter:go_default_library",
],
],
)
)
...
...
pkg/printers/humanreadable.go
View file @
2b1a2d36
...
@@ -22,7 +22,8 @@ import (
...
@@ -22,7 +22,8 @@ import (
"io"
"io"
"reflect"
"reflect"
"strings"
"strings"
"text/tabwriter"
"github.com/liggitt/tabwriter"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/api/meta"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
...
...
pkg/printers/tabwriter.go
View file @
2b1a2d36
...
@@ -18,7 +18,8 @@ package printers
...
@@ -18,7 +18,8 @@ package printers
import
(
import
(
"io"
"io"
"text/tabwriter"
"github.com/liggitt/tabwriter"
)
)
const
(
const
(
...
@@ -26,7 +27,7 @@ const (
...
@@ -26,7 +27,7 @@ const (
tabwriterWidth
=
4
tabwriterWidth
=
4
tabwriterPadding
=
3
tabwriterPadding
=
3
tabwriterPadChar
=
' '
tabwriterPadChar
=
' '
tabwriterFlags
=
0
tabwriterFlags
=
tabwriter
.
RememberWidths
)
)
// GetNewTabWriter returns a tabwriter that translates tabbed columns in input into properly aligned text.
// GetNewTabWriter returns a tabwriter that translates tabbed columns in input into properly aligned text.
...
...
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