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
a3f4d8a5
Commit
a3f4d8a5
authored
Oct 24, 2016
by
markturansky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
loosened validation on pvc limitranger
parent
6bda989d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
19 deletions
+26
-19
validation.go
pkg/api/validation/validation.go
+2
-5
validation_test.go
pkg/api/validation/validation_test.go
+24
-14
No files found.
pkg/api/validation/validation.go
View file @
a3f4d8a5
...
...
@@ -3010,11 +3010,8 @@ func ValidateLimitRange(limitRange *api.LimitRange) field.ErrorList {
if
limit
.
Type
==
api
.
LimitTypePersistentVolumeClaim
{
_
,
minQuantityFound
:=
limit
.
Min
[
api
.
ResourceStorage
]
_
,
maxQuantityFound
:=
limit
.
Max
[
api
.
ResourceStorage
]
if
!
minQuantityFound
{
allErrs
=
append
(
allErrs
,
field
.
Required
(
idxPath
.
Child
(
"min"
),
"minimum storage value is required"
))
}
if
!
maxQuantityFound
{
allErrs
=
append
(
allErrs
,
field
.
Required
(
idxPath
.
Child
(
"max"
),
"maximum storage value is required"
))
if
!
minQuantityFound
&&
!
maxQuantityFound
{
allErrs
=
append
(
allErrs
,
field
.
Required
(
idxPath
.
Child
(
"limits"
),
"either minimum or maximum storage value is required, but neither was provided"
))
}
}
...
...
pkg/api/validation/validation_test.go
View file @
a3f4d8a5
...
...
@@ -6628,6 +6628,28 @@ func TestValidateLimitRange(t *testing.T) {
},
},
{
name
:
"pvc-min-only"
,
spec
:
api
.
LimitRangeSpec
{
Limits
:
[]
api
.
LimitRangeItem
{
{
Type
:
api
.
LimitTypePersistentVolumeClaim
,
Min
:
getStorageResourceList
(
"5Gi"
),
},
},
},
},
{
name
:
"pvc-max-only"
,
spec
:
api
.
LimitRangeSpec
{
Limits
:
[]
api
.
LimitRangeItem
{
{
Type
:
api
.
LimitTypePersistentVolumeClaim
,
Max
:
getStorageResourceList
(
"10Gi"
),
},
},
},
},
{
name
:
"all-fields-valid-big-numbers"
,
spec
:
api
.
LimitRangeSpec
{
Limits
:
[]
api
.
LimitRangeItem
{
...
...
@@ -6834,27 +6856,15 @@ func TestValidateLimitRange(t *testing.T) {
}},
"must be a standard limit type or fully qualified"
,
},
"invalid missing required min field"
:
{
api
.
LimitRange
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
"foo"
},
Spec
:
api
.
LimitRangeSpec
{
Limits
:
[]
api
.
LimitRangeItem
{
{
Type
:
api
.
LimitTypePersistentVolumeClaim
,
Max
:
getStorageResourceList
(
"10000T"
),
},
},
}},
"minimum storage value is required"
,
},
"invalid missing required max field"
:
{
"min and max values missing, one required"
:
{
api
.
LimitRange
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
"foo"
},
Spec
:
api
.
LimitRangeSpec
{
Limits
:
[]
api
.
LimitRangeItem
{
{
Type
:
api
.
LimitTypePersistentVolumeClaim
,
Min
:
getStorageResourceList
(
"10000T"
),
},
},
}},
"
maximum storage value is requir
ed"
,
"
either minimum or maximum storage value is required, but neither was provid
ed"
,
},
"invalid min greater than max"
:
{
api
.
LimitRange
{
ObjectMeta
:
api
.
ObjectMeta
{
Name
:
"abc"
,
Namespace
:
"foo"
},
Spec
:
api
.
LimitRangeSpec
{
...
...
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