1
0
mirror of https://github.com/rancher/types.git synced 2025-09-17 15:29:10 +00:00

Resource quota

This commit is contained in:
Alena Prokharchyk
2018-06-26 16:01:42 -07:00
committed by Craig Jellick
parent 75cb49e5ed
commit 6ec1e0a018
5 changed files with 59 additions and 6 deletions

View File

@@ -31,11 +31,16 @@ func namespaceTypes(schemas *types.Schemas) *types.Schemas {
AddMapperForType(&Version, v1.Namespace{},
&m.AnnotationField{Field: "description"},
&m.AnnotationField{Field: "projectId"},
&m.AnnotationField{Field: "resourceQuotaTemplateId"},
&m.AnnotationField{Field: "resourceQuotaAppliedTemplateId"},
&m.Drop{Field: "status"},
).
MustImport(&Version, v1.Namespace{}, struct {
Description string `json:"description"`
ProjectID string `norman:"type=reference[/v3/schemas/project]"`
Description string `json:"description"`
ProjectID string `norman:"type=reference[/v3/schemas/project]"`
ResourceQuotaTemplateID string `json:"resourceQuotaTemplateId,omitempty" norman:"type=reference[/v3/schemas/resourceQuotaTemplate]"`
ResourceQuotaAppliedTemplateID string `json:"resourceQuotaAppliedTemplateId,omitempty" norman:"type=reference[/v3/schemas/resourceQuotaTemplate],nocreate,noupdate"`
}{})
}

View File

@@ -47,9 +47,10 @@ type ProjectCondition struct {
}
type ProjectSpec struct {
DisplayName string `json:"displayName,omitempty" norman:"required"`
Description string `json:"description"`
ClusterName string `json:"clusterName,omitempty" norman:"required,type=reference[cluster]"`
DisplayName string `json:"displayName,omitempty" norman:"required"`
Description string `json:"description"`
ClusterName string `json:"clusterName,omitempty" norman:"required,type=reference[cluster]"`
ResourceQuota *ProjectResourceQuota `json:"resourceQuota,omitempty"`
}
type GlobalRole struct {

View File

@@ -0,0 +1,40 @@
package v3
import (
"github.com/rancher/norman/types"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
type ProjectResourceQuota struct {
Limit ProjectResourceLimit `json:"limit,omitempty"`
UsedLimit ProjectResourceLimit `json:"usedLimit,omitempty"`
}
type ProjectResourceLimit struct {
Pods string `json:"pods,omitempty"`
Services string `json:"services,omitempty"`
ReplicationControllers string `json:"replicationControllers,omitempty"`
Secrets string `json:"secrets,omitempty"`
ConfigMaps string `json:"configMaps,omitempty"`
PersistentVolumeClaims string `json:"persistentVolumeClaims,omitempty"`
ServicesNodePorts string `json:"servicesNodePorts,omitempty"`
ServicesLoadBalancers string `json:"servicesLoadBalancers,omitempty"`
RequestsCPU string `json:"requestsCpu,omitempty"`
RequestsMemory string `json:"requestsMemory,omitempty"`
RequestsStorage string `json:"requestsStorage,omitempty"`
LimitsCPU string `json:"limitsCpu,omitempty"`
LimitsMemory string `json:"limitsMemory,omitempty"`
}
type ResourceQuotaTemplate struct {
types.Namespaced
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Description string `json:"description"`
IsDefault bool `json:"isDefault"`
ClusterName string `json:"clusterName,omitempty" norman:"required,type=reference[cluster]"`
ProjectResourceQuota
}

View File

@@ -35,7 +35,8 @@ var (
Init(rkeTypes).
Init(alertTypes).
Init(pipelineTypes).
Init(composeType)
Init(composeType).
Init(resourceQuotaTemplateTypes)
TokenSchemas = factory.Schemas(&Version).
Init(tokens)
@@ -583,3 +584,8 @@ func pipelineTypes(schema *types.Schemas) *types.Schemas {
func composeType(schemas *types.Schemas) *types.Schemas {
return schemas.MustImport(&Version, v3.ComposeConfig{})
}
func resourceQuotaTemplateTypes(schemas *types.Schemas) *types.Schemas {
return schemas.
MustImport(&Version, v3.ResourceQuotaTemplate{})
}

View File

@@ -35,6 +35,7 @@ func main() {
v1.ConfigMap{},
v1.ServiceAccount{},
v1.ReplicationController{},
v1.ResourceQuota{},
}, []interface{}{
v1.Node{},
v1.ComponentStatus{},