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
936bb64a
Commit
936bb64a
authored
Oct 15, 2016
by
Kubernetes Submit Queue
Committed by
GitHub
Oct 15, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #34808 from ivan4th/remove-duplicate-code-from-kubectl-describe
Automatic merge from submit-queue Remove duplicate code from kubectl describe
parents
864a7bac
27d51f09
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
75 deletions
+18
-75
describe.go
pkg/kubectl/describe.go
+18
-75
No files found.
pkg/kubectl/describe.go
View file @
936bb64a
...
@@ -212,17 +212,9 @@ func describeNamespace(namespace *api.Namespace, resourceQuotaList *api.Resource
...
@@ -212,17 +212,9 @@ func describeNamespace(namespace *api.Namespace, resourceQuotaList *api.Resource
})
})
}
}
// DescribeLimitRanges merges a set of limit range items into a single tabular description
func
describeLimitRangeSpec
(
spec
api
.
LimitRangeSpec
,
prefix
string
,
w
io
.
Writer
)
{
func
DescribeLimitRanges
(
limitRanges
*
api
.
LimitRangeList
,
w
io
.
Writer
)
{
for
i
:=
range
spec
.
Limits
{
if
len
(
limitRanges
.
Items
)
==
0
{
item
:=
spec
.
Limits
[
i
]
fmt
.
Fprint
(
w
,
"No resource limits.
\n
"
)
return
}
fmt
.
Fprintf
(
w
,
"Resource Limits
\n
Type
\t
Resource
\t
Min
\t
Max
\t
Default Request
\t
Default Limit
\t
Max Limit/Request Ratio
\n
"
)
fmt
.
Fprintf
(
w
,
" ----
\t
--------
\t
---
\t
---
\t
---------------
\t
-------------
\t
-----------------------
\n
"
)
for
_
,
limitRange
:=
range
limitRanges
.
Items
{
for
i
:=
range
limitRange
.
Spec
.
Limits
{
item
:=
limitRange
.
Spec
.
Limits
[
i
]
maxResources
:=
item
.
Max
maxResources
:=
item
.
Max
minResources
:=
item
.
Min
minResources
:=
item
.
Min
defaultLimitResources
:=
item
.
Default
defaultLimitResources
:=
item
.
Default
...
@@ -279,10 +271,22 @@ func DescribeLimitRanges(limitRanges *api.LimitRangeList, w io.Writer) {
...
@@ -279,10 +271,22 @@ func DescribeLimitRanges(limitRanges *api.LimitRangeList, w io.Writer) {
ratioValue
=
ratioQuantity
.
String
()
ratioValue
=
ratioQuantity
.
String
()
}
}
msg
:=
" %s
\t
%v
\t
%v
\t
%v
\t
%v
\t
%v
\t
%v
\n
"
msg
:=
"%s%s
\t
%v
\t
%v
\t
%v
\t
%v
\t
%v
\t
%v
\n
"
fmt
.
Fprintf
(
w
,
msg
,
item
.
Type
,
k
,
minValue
,
maxValue
,
defaultRequestValue
,
defaultLimitValue
,
ratioValue
)
fmt
.
Fprintf
(
w
,
msg
,
prefix
,
item
.
Type
,
k
,
minValue
,
maxValue
,
defaultRequestValue
,
defaultLimitValue
,
ratioValue
)
}
}
}
}
// DescribeLimitRanges merges a set of limit range items into a single tabular description
func
DescribeLimitRanges
(
limitRanges
*
api
.
LimitRangeList
,
w
io
.
Writer
)
{
if
len
(
limitRanges
.
Items
)
==
0
{
fmt
.
Fprint
(
w
,
"No resource limits.
\n
"
)
return
}
}
fmt
.
Fprintf
(
w
,
"Resource Limits
\n
Type
\t
Resource
\t
Min
\t
Max
\t
Default Request
\t
Default Limit
\t
Max Limit/Request Ratio
\n
"
)
fmt
.
Fprintf
(
w
,
" ----
\t
--------
\t
---
\t
---
\t
---------------
\t
-------------
\t
-----------------------
\n
"
)
for
_
,
limitRange
:=
range
limitRanges
.
Items
{
describeLimitRangeSpec
(
limitRange
.
Spec
,
" "
,
w
)
}
}
}
}
...
@@ -350,68 +354,7 @@ func describeLimitRange(limitRange *api.LimitRange) (string, error) {
...
@@ -350,68 +354,7 @@ func describeLimitRange(limitRange *api.LimitRange) (string, error) {
fmt
.
Fprintf
(
out
,
"Namespace:
\t
%s
\n
"
,
limitRange
.
Namespace
)
fmt
.
Fprintf
(
out
,
"Namespace:
\t
%s
\n
"
,
limitRange
.
Namespace
)
fmt
.
Fprintf
(
out
,
"Type
\t
Resource
\t
Min
\t
Max
\t
Default Request
\t
Default Limit
\t
Max Limit/Request Ratio
\n
"
)
fmt
.
Fprintf
(
out
,
"Type
\t
Resource
\t
Min
\t
Max
\t
Default Request
\t
Default Limit
\t
Max Limit/Request Ratio
\n
"
)
fmt
.
Fprintf
(
out
,
"----
\t
--------
\t
---
\t
---
\t
---------------
\t
-------------
\t
-----------------------
\n
"
)
fmt
.
Fprintf
(
out
,
"----
\t
--------
\t
---
\t
---
\t
---------------
\t
-------------
\t
-----------------------
\n
"
)
for
i
:=
range
limitRange
.
Spec
.
Limits
{
describeLimitRangeSpec
(
limitRange
.
Spec
,
""
,
out
)
item
:=
limitRange
.
Spec
.
Limits
[
i
]
maxResources
:=
item
.
Max
minResources
:=
item
.
Min
defaultLimitResources
:=
item
.
Default
defaultRequestResources
:=
item
.
DefaultRequest
ratio
:=
item
.
MaxLimitRequestRatio
set
:=
map
[
api
.
ResourceName
]
bool
{}
for
k
:=
range
maxResources
{
set
[
k
]
=
true
}
for
k
:=
range
minResources
{
set
[
k
]
=
true
}
for
k
:=
range
defaultLimitResources
{
set
[
k
]
=
true
}
for
k
:=
range
defaultRequestResources
{
set
[
k
]
=
true
}
for
k
:=
range
ratio
{
set
[
k
]
=
true
}
for
k
:=
range
set
{
// if no value is set, we output -
maxValue
:=
"-"
minValue
:=
"-"
defaultLimitValue
:=
"-"
defaultRequestValue
:=
"-"
ratioValue
:=
"-"
maxQuantity
,
maxQuantityFound
:=
maxResources
[
k
]
if
maxQuantityFound
{
maxValue
=
maxQuantity
.
String
()
}
minQuantity
,
minQuantityFound
:=
minResources
[
k
]
if
minQuantityFound
{
minValue
=
minQuantity
.
String
()
}
defaultLimitQuantity
,
defaultLimitQuantityFound
:=
defaultLimitResources
[
k
]
if
defaultLimitQuantityFound
{
defaultLimitValue
=
defaultLimitQuantity
.
String
()
}
defaultRequestQuantity
,
defaultRequestQuantityFound
:=
defaultRequestResources
[
k
]
if
defaultRequestQuantityFound
{
defaultRequestValue
=
defaultRequestQuantity
.
String
()
}
ratioQuantity
,
ratioQuantityFound
:=
ratio
[
k
]
if
ratioQuantityFound
{
ratioValue
=
ratioQuantity
.
String
()
}
msg
:=
"%v
\t
%v
\t
%v
\t
%v
\t
%v
\t
%v
\t
%v
\n
"
fmt
.
Fprintf
(
out
,
msg
,
item
.
Type
,
k
,
minValue
,
maxValue
,
defaultRequestValue
,
defaultLimitValue
,
ratioValue
)
}
}
return
nil
return
nil
})
})
}
}
...
...
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