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
134d44cf
Commit
134d44cf
authored
Feb 15, 2016
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #20409 from AdoHe/kubectl_ingress_labels
Auto commit by PR queue bot
parents
acb16073
f6b5eca1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
0 deletions
+39
-0
resource_printer.go
pkg/kubectl/resource_printer.go
+3
-0
resource_printer_test.go
pkg/kubectl/resource_printer_test.go
+36
-0
No files found.
pkg/kubectl/resource_printer.go
View file @
134d44cf
...
...
@@ -990,6 +990,9 @@ func printIngress(ingress *extensions.Ingress, w io.Writer, options PrintOptions
loadBalancerStatusStringer
(
ingress
.
Status
.
LoadBalancer
));
err
!=
nil
{
return
err
}
if
_
,
err
:=
fmt
.
Fprint
(
w
,
appendLabels
(
ingress
.
Labels
,
options
.
ColumnLabels
));
err
!=
nil
{
return
err
}
if
_
,
err
:=
fmt
.
Fprint
(
w
,
appendAllLabels
(
options
.
ShowLabels
,
ingress
.
Labels
));
err
!=
nil
{
return
err
...
...
pkg/kubectl/resource_printer_test.go
View file @
134d44cf
...
...
@@ -35,6 +35,7 @@ import (
"k8s.io/kubernetes/pkg/runtime"
yamlserializer
"k8s.io/kubernetes/pkg/runtime/serializer/yaml"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/util/intstr"
"k8s.io/kubernetes/pkg/util/sets"
"github.com/ghodss/yaml"
...
...
@@ -641,6 +642,41 @@ func contains(fields []string, field string) bool {
return
false
}
func
TestPrintHunmanReadableIngressWithColumnLabels
(
t
*
testing
.
T
)
{
ingress
:=
extensions
.
Ingress
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"test1"
,
CreationTimestamp
:
unversioned
.
Time
{
Time
:
time
.
Now
()
.
AddDate
(
-
10
,
0
,
0
)},
Labels
:
map
[
string
]
string
{
"app_name"
:
"kubectl_test_ingress"
,
},
},
Spec
:
extensions
.
IngressSpec
{
Backend
:
&
extensions
.
IngressBackend
{
ServiceName
:
"svc"
,
ServicePort
:
intstr
.
FromInt
(
93
),
},
},
Status
:
extensions
.
IngressStatus
{
LoadBalancer
:
api
.
LoadBalancerStatus
{
Ingress
:
[]
api
.
LoadBalancerIngress
{
{
IP
:
"2.3.4.5"
,
Hostname
:
"localhost.localdomain"
,
},
},
},
},
}
buff
:=
bytes
.
Buffer
{}
printIngress
(
&
ingress
,
&
buff
,
PrintOptions
{
false
,
false
,
false
,
false
,
false
,
false
,
[]
string
{
"app_name"
}})
output
:=
string
(
buff
.
Bytes
())
appName
:=
ingress
.
ObjectMeta
.
Labels
[
"app_name"
]
if
!
strings
.
Contains
(
output
,
appName
)
{
t
.
Errorf
(
"expected to container app_name label value %s, but doesn't %s"
,
appName
,
output
)
}
}
func
TestPrintHumanReadableService
(
t
*
testing
.
T
)
{
tests
:=
[]
api
.
Service
{
{
...
...
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