1
0
mirror of https://github.com/rancher/types.git synced 2025-06-23 04:07:03 +00:00

Resoure quota refactor - no more template

This commit is contained in:
Alena Prokharchyk 2018-08-23 09:53:34 -07:00
parent 3c5fd8d134
commit eb18b360c0
5 changed files with 38 additions and 41 deletions

View File

@ -31,16 +31,14 @@ 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.AnnotationField{Field: "resourceQuota", Object: true},
&m.Drop{Field: "status"},
).
MustImport(&Version, NamespaceResourceQuota{}).
MustImport(&Version, v1.Namespace{}, struct {
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"`
Description string `json:"description"`
ProjectID string `norman:"type=reference[/v3/schemas/project]"`
ResourceQuota string `json:"resourceQuota,omitempty" norman:"type=namespaceResourceQuota"`
}{})
}

View File

@ -25,3 +25,23 @@ type KubernetesInfo struct {
KubeletVersion string
KubeProxyVersion string
}
type NamespaceResourceQuota struct {
Limit ResourceQuotaLimit `json:"limit,omitempty"`
}
type ResourceQuotaLimit 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"`
}

View File

@ -47,10 +47,11 @@ 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]"`
ResourceQuota *ProjectResourceQuota `json:"resourceQuota,omitempty"`
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"`
NamespaceDefaultResourceQuota *NamespaceResourceQuota `json:"namespaceDefaultResourceQuota,omitempty"`
}
type GlobalRole struct {

View File

@ -1,16 +1,15 @@
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"`
Limit ResourceQuotaLimit `json:"limit,omitempty"`
UsedLimit ResourceQuotaLimit `json:"usedLimit,omitempty"`
}
type ProjectResourceLimit struct {
type NamespaceResourceQuota struct {
Limit ResourceQuotaLimit `json:"limit,omitempty"`
}
type ResourceQuotaLimit struct {
Pods string `json:"pods,omitempty"`
Services string `json:"services,omitempty"`
ReplicationControllers string `json:"replicationControllers,omitempty"`
@ -25,16 +24,3 @@ type ProjectResourceLimit struct {
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

@ -34,8 +34,7 @@ var (
Init(globalTypes).
Init(rkeTypes).
Init(alertTypes).
Init(composeType).
Init(resourceQuotaTemplateTypes)
Init(composeType)
TokenSchemas = factory.Schemas(&Version).
Init(tokens)
@ -537,10 +536,3 @@ func alertTypes(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.
MustImportAndCustomize(&Version, v3.ResourceQuotaTemplate{}, func(schema *types.Schema) {
schema.ResourceMethods = []string{http.MethodGet, http.MethodDelete}
})
}