| 1 |
/* |
| 2 |
Copyright 2017 The Kubernetes Authors. |
| 3 |
|
| 4 |
Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
you may not use this file except in compliance with the License. |
| 6 |
You may obtain a copy of the License at |
| 7 |
|
| 8 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
|
| 10 |
Unless required by applicable law or agreed to in writing, software |
| 11 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
See the License for the specific language governing permissions and |
| 14 |
limitations under the License. |
| 15 |
*/ |
| 16 |
|
| 17 |
package generic |
| 18 |
|
| 19 |
import ( |
| 20 |
"k8s.io/apimachinery/pkg/runtime/schema" |
| 21 |
quota "k8s.io/apiserver/pkg/quota/v1" |
| 22 |
) |
| 23 |
|
| 24 |
// implements a basic configuration |
| 25 |
type simpleConfiguration struct { |
| 26 |
evaluators []quota.Evaluator |
| 27 |
ignoredResources map[schema.GroupResource]struct{} |
| 28 |
} |
| 29 |
|
| 30 |
// NewConfiguration creates a quota configuration |
| 31 |
func NewConfiguration(evaluators []quota.Evaluator, ignoredResources map[schema.GroupResource]struct{}) quota.Configuration { |
| 32 |
return &simpleConfiguration{ |
| 33 |
evaluators: evaluators, |
| 34 |
ignoredResources: ignoredResources, |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
func (c *simpleConfiguration) IgnoredResources() map[schema.GroupResource]struct{} { |
| 39 |
return c.ignoredResources |
| 40 |
} |
| 41 |
|
| 42 |
func (c *simpleConfiguration) Evaluators() []quota.Evaluator { |
| 43 |
return c.evaluators |
| 44 |
} |