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
ac97e9fb
Commit
ac97e9fb
authored
Apr 23, 2015
by
derekwaynecarr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
normalize to lower resource names
parent
f7831dcd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
admission.go
plugin/pkg/admission/resourcequota/admission.go
+7
-4
No files found.
plugin/pkg/admission/resourcequota/admission.go
View file @
ac97e9fb
...
@@ -19,6 +19,7 @@ package resourcequota
...
@@ -19,6 +19,7 @@ package resourcequota
import
(
import
(
"fmt"
"fmt"
"io"
"io"
"strings"
"github.com/GoogleCloudPlatform/kubernetes/pkg/admission"
"github.com/GoogleCloudPlatform/kubernetes/pkg/admission"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
...
@@ -60,10 +61,10 @@ func NewResourceQuota(client client.Interface) admission.Interface {
...
@@ -60,10 +61,10 @@ func NewResourceQuota(client client.Interface) admission.Interface {
var
resourceToResourceName
=
map
[
string
]
api
.
ResourceName
{
var
resourceToResourceName
=
map
[
string
]
api
.
ResourceName
{
"pods"
:
api
.
ResourcePods
,
"pods"
:
api
.
ResourcePods
,
"services"
:
api
.
ResourceServices
,
"services"
:
api
.
ResourceServices
,
"replication
C
ontrollers"
:
api
.
ResourceReplicationControllers
,
"replication
c
ontrollers"
:
api
.
ResourceReplicationControllers
,
"resource
Q
uotas"
:
api
.
ResourceQuotas
,
"resource
q
uotas"
:
api
.
ResourceQuotas
,
"secrets"
:
api
.
ResourceSecrets
,
"secrets"
:
api
.
ResourceSecrets
,
"persistent
VolumeC
laims"
:
api
.
ResourcePersistentVolumeClaims
,
"persistent
volumec
laims"
:
api
.
ResourcePersistentVolumeClaims
,
}
}
func
(
q
*
quota
)
Admit
(
a
admission
.
Attributes
)
(
err
error
)
{
func
(
q
*
quota
)
Admit
(
a
admission
.
Attributes
)
(
err
error
)
{
...
@@ -137,7 +138,9 @@ func IncrementUsage(a admission.Attributes, status *api.ResourceQuotaStatus, cli
...
@@ -137,7 +138,9 @@ func IncrementUsage(a admission.Attributes, status *api.ResourceQuotaStatus, cli
obj
:=
a
.
GetObject
()
obj
:=
a
.
GetObject
()
// handle max counts for each kind of resource (pods, services, replicationControllers, etc.)
// handle max counts for each kind of resource (pods, services, replicationControllers, etc.)
if
a
.
GetOperation
()
==
"CREATE"
{
if
a
.
GetOperation
()
==
"CREATE"
{
resourceName
:=
resourceToResourceName
[
a
.
GetResource
()]
// TODO v1beta1 had camel case, v1beta3 went to all lower, we can remove this line when we deprecate v1beta1
resourceNormalized
:=
strings
.
ToLower
(
a
.
GetResource
())
resourceName
:=
resourceToResourceName
[
resourceNormalized
]
hard
,
hardFound
:=
status
.
Hard
[
resourceName
]
hard
,
hardFound
:=
status
.
Hard
[
resourceName
]
if
hardFound
{
if
hardFound
{
used
,
usedFound
:=
status
.
Used
[
resourceName
]
used
,
usedFound
:=
status
.
Used
[
resourceName
]
...
...
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