Update console to use latest operator (#476)
Main changes Rename everything from Zone->Pool
This commit is contained in:
@@ -115,13 +115,13 @@ func registerTenantHandlers(api *operations.ConsoleAPI) {
|
||||
return admin_api.NewUpdateTenantCreated()
|
||||
})
|
||||
|
||||
// Add Tenant Zones
|
||||
api.AdminAPITenantAddZoneHandler = admin_api.TenantAddZoneHandlerFunc(func(params admin_api.TenantAddZoneParams, session *models.Principal) middleware.Responder {
|
||||
err := getTenantAddZoneResponse(session, params)
|
||||
// Add Tenant Pools
|
||||
api.AdminAPITenantAddPoolHandler = admin_api.TenantAddPoolHandlerFunc(func(params admin_api.TenantAddPoolParams, session *models.Principal) middleware.Responder {
|
||||
err := getTenantAddPoolResponse(session, params)
|
||||
if err != nil {
|
||||
return admin_api.NewTenantAddZoneDefault(int(err.Code)).WithPayload(err)
|
||||
return admin_api.NewTenantAddPoolDefault(int(err.Code)).WithPayload(err)
|
||||
}
|
||||
return admin_api.NewTenantAddZoneCreated()
|
||||
return admin_api.NewTenantAddPoolCreated()
|
||||
})
|
||||
|
||||
// Get Tenant Usage
|
||||
@@ -133,13 +133,13 @@ func registerTenantHandlers(api *operations.ConsoleAPI) {
|
||||
return admin_api.NewGetTenantUsageOK().WithPayload(payload)
|
||||
})
|
||||
|
||||
// Update Tenant Zones
|
||||
api.AdminAPITenantUpdateZonesHandler = admin_api.TenantUpdateZonesHandlerFunc(func(params admin_api.TenantUpdateZonesParams, session *models.Principal) middleware.Responder {
|
||||
resp, err := getTenantUpdateZoneResponse(session, params)
|
||||
// Update Tenant Pools
|
||||
api.AdminAPITenantUpdatePoolsHandler = admin_api.TenantUpdatePoolsHandlerFunc(func(params admin_api.TenantUpdatePoolsParams, session *models.Principal) middleware.Responder {
|
||||
resp, err := getTenantUpdatePoolResponse(session, params)
|
||||
if err != nil {
|
||||
return admin_api.NewTenantUpdateZonesDefault(int(err.Code)).WithPayload(err)
|
||||
return admin_api.NewTenantUpdatePoolsDefault(int(err.Code)).WithPayload(err)
|
||||
}
|
||||
return admin_api.NewTenantUpdateZonesOK().WithPayload(resp)
|
||||
return admin_api.NewTenantUpdatePoolsOK().WithPayload(resp)
|
||||
})
|
||||
|
||||
// Update Tenant Certificates
|
||||
@@ -300,13 +300,13 @@ func isPrometheusEnabled(annotations map[string]string) bool {
|
||||
}
|
||||
|
||||
func getTenantInfo(tenant *operator.Tenant) *models.Tenant {
|
||||
var zones []*models.Zone
|
||||
var pools []*models.Pool
|
||||
consoleImage := ""
|
||||
var totalSize int64
|
||||
for _, z := range tenant.Spec.Zones {
|
||||
zones = append(zones, parseTenantZone(&z))
|
||||
zoneSize := int64(z.Servers) * int64(z.VolumesPerServer) * z.VolumeClaimTemplate.Spec.Resources.Requests.Storage().Value()
|
||||
totalSize = totalSize + zoneSize
|
||||
for _, p := range tenant.Spec.Pools {
|
||||
pools = append(pools, parseTenantPool(&p))
|
||||
poolSize := int64(p.Servers) * int64(p.VolumesPerServer) * p.VolumeClaimTemplate.Spec.Resources.Requests.Storage().Value()
|
||||
totalSize = totalSize + poolSize
|
||||
}
|
||||
var deletion string
|
||||
if tenant.ObjectMeta.DeletionTimestamp != nil {
|
||||
@@ -323,7 +323,7 @@ func getTenantInfo(tenant *operator.Tenant) *models.Tenant {
|
||||
Name: tenant.Name,
|
||||
TotalSize: totalSize,
|
||||
CurrentState: tenant.Status.CurrentState,
|
||||
Zones: zones,
|
||||
Pools: pools,
|
||||
Namespace: tenant.ObjectMeta.Namespace,
|
||||
Image: tenant.Spec.Image,
|
||||
ConsoleImage: consoleImage,
|
||||
@@ -374,12 +374,12 @@ func listTenants(ctx context.Context, operatorClient OperatorClientI, namespace
|
||||
var totalSize int64
|
||||
var instanceCount int64
|
||||
var volumeCount int64
|
||||
for _, zone := range tenant.Spec.Zones {
|
||||
instanceCount = instanceCount + int64(zone.Servers)
|
||||
volumeCount = volumeCount + int64(zone.Servers*zone.VolumesPerServer)
|
||||
if zone.VolumeClaimTemplate != nil {
|
||||
zoneSize := int64(zone.VolumesPerServer) * int64(zone.Servers) * zone.VolumeClaimTemplate.Spec.Resources.Requests.Storage().Value()
|
||||
totalSize = totalSize + zoneSize
|
||||
for _, pool := range tenant.Spec.Pools {
|
||||
instanceCount = instanceCount + int64(pool.Servers)
|
||||
volumeCount = volumeCount + int64(pool.Servers*pool.VolumesPerServer)
|
||||
if pool.VolumeClaimTemplate != nil {
|
||||
poolSize := int64(pool.VolumesPerServer) * int64(pool.Servers) * pool.VolumeClaimTemplate.Spec.Resources.Requests.Storage().Value()
|
||||
totalSize = totalSize + poolSize
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,7 +392,7 @@ func listTenants(ctx context.Context, operatorClient OperatorClientI, namespace
|
||||
CreationDate: tenant.ObjectMeta.CreationTimestamp.String(),
|
||||
DeletionDate: deletion,
|
||||
Name: tenant.ObjectMeta.Name,
|
||||
ZoneCount: int64(len(tenant.Spec.Zones)),
|
||||
PoolCount: int64(len(tenant.Spec.Pools)),
|
||||
InstanceCount: instanceCount,
|
||||
VolumeCount: volumeCount,
|
||||
CurrentState: tenant.Status.CurrentState,
|
||||
@@ -737,13 +737,14 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
|
||||
annotations = tenantReq.Annotations
|
||||
minInst.Annotations = annotations
|
||||
}
|
||||
// set the zones if they are provided
|
||||
for _, zone := range tenantReq.Zones {
|
||||
zone, err := parseTenantZoneRequest(zone)
|
||||
// set the pools if they are provided
|
||||
for _, pool := range tenantReq.Pools {
|
||||
pool, err := parseTenantPoolRequest(pool)
|
||||
if err != nil {
|
||||
log.Println("parseTenantPoolRequest", err)
|
||||
return nil, prepareError(err)
|
||||
}
|
||||
minInst.Spec.Zones = append(minInst.Spec.Zones, *zone)
|
||||
minInst.Spec.Pools = append(minInst.Spec.Pools, *pool)
|
||||
}
|
||||
|
||||
// Set Mount Path if provided
|
||||
@@ -785,6 +786,7 @@ func getTenantCreatedResponse(session *models.Principal, params admin_api.Create
|
||||
|
||||
_, err = opClient.MinioV1().Tenants(ns).Create(context.Background(), &minInst, metav1.CreateOptions{})
|
||||
if err != nil {
|
||||
log.Println("Create", err)
|
||||
return nil, prepareError(err)
|
||||
}
|
||||
|
||||
@@ -911,21 +913,21 @@ func updateTenantAction(ctx context.Context, operatorClient OperatorClientI, cli
|
||||
if params.Body.EnablePrometheus && currentAnnotations != nil {
|
||||
// add prometheus annotations to the tenant
|
||||
minInst.Annotations = addAnnotations(currentAnnotations, prometheusAnnotations)
|
||||
// add prometheus annotations to the each zone
|
||||
if minInst.Spec.Zones != nil {
|
||||
for _, zone := range minInst.Spec.Zones {
|
||||
zoneAnnotations := zone.VolumeClaimTemplate.GetObjectMeta().GetAnnotations()
|
||||
zone.VolumeClaimTemplate.GetObjectMeta().SetAnnotations(addAnnotations(zoneAnnotations, prometheusAnnotations))
|
||||
// add prometheus annotations to the each pool
|
||||
if minInst.Spec.Pools != nil {
|
||||
for _, pool := range minInst.Spec.Pools {
|
||||
poolAnnotations := pool.VolumeClaimTemplate.GetObjectMeta().GetAnnotations()
|
||||
pool.VolumeClaimTemplate.GetObjectMeta().SetAnnotations(addAnnotations(poolAnnotations, prometheusAnnotations))
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// remove prometheus annotations to the tenant
|
||||
minInst.Annotations = removeAnnotations(currentAnnotations, prometheusAnnotations)
|
||||
// add prometheus annotations from each zone
|
||||
if minInst.Spec.Zones != nil {
|
||||
for _, zone := range minInst.Spec.Zones {
|
||||
zoneAnnotations := zone.VolumeClaimTemplate.GetObjectMeta().GetAnnotations()
|
||||
zone.VolumeClaimTemplate.GetObjectMeta().SetAnnotations(removeAnnotations(zoneAnnotations, prometheusAnnotations))
|
||||
// add prometheus annotations from each pool
|
||||
if minInst.Spec.Pools != nil {
|
||||
for _, pool := range minInst.Spec.Pools {
|
||||
poolAnnotations := pool.VolumeClaimTemplate.GetObjectMeta().GetAnnotations()
|
||||
pool.VolumeClaimTemplate.GetObjectMeta().SetAnnotations(removeAnnotations(poolAnnotations, prometheusAnnotations))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -988,19 +990,19 @@ func getUpdateTenantResponse(session *models.Principal, params admin_api.UpdateT
|
||||
return nil
|
||||
}
|
||||
|
||||
// addTenantZone creates a zone to a defined tenant
|
||||
func addTenantZone(ctx context.Context, operatorClient OperatorClientI, params admin_api.TenantAddZoneParams) error {
|
||||
// addTenantPool creates a pool to a defined tenant
|
||||
func addTenantPool(ctx context.Context, operatorClient OperatorClientI, params admin_api.TenantAddPoolParams) error {
|
||||
tenant, err := operatorClient.TenantGet(ctx, params.Namespace, params.Tenant, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
zoneParams := params.Body
|
||||
zone, err := parseTenantZoneRequest(zoneParams)
|
||||
poolParams := params.Body
|
||||
pool, err := parseTenantPoolRequest(poolParams)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
tenant.Spec.Zones = append(tenant.Spec.Zones, *zone)
|
||||
tenant.Spec.Pools = append(tenant.Spec.Pools, *pool)
|
||||
payloadBytes, err := json.Marshal(tenant)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -1013,7 +1015,7 @@ func addTenantZone(ctx context.Context, operatorClient OperatorClientI, params a
|
||||
return nil
|
||||
}
|
||||
|
||||
func getTenantAddZoneResponse(session *models.Principal, params admin_api.TenantAddZoneParams) *models.Error {
|
||||
func getTenantAddPoolResponse(session *models.Principal, params admin_api.TenantAddPoolParams) *models.Error {
|
||||
ctx := context.Background()
|
||||
opClientClientSet, err := cluster.OperatorClient(session.SessionToken)
|
||||
if err != nil {
|
||||
@@ -1022,8 +1024,8 @@ func getTenantAddZoneResponse(session *models.Principal, params admin_api.Tenant
|
||||
opClient := &operatorClient{
|
||||
client: opClientClientSet,
|
||||
}
|
||||
if err := addTenantZone(ctx, opClient, params); err != nil {
|
||||
return prepareError(err, errors.New("unable to add zone"))
|
||||
if err := addTenantPool(ctx, opClient, params); err != nil {
|
||||
return prepareError(err, errors.New("unable to add pool"))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1080,26 +1082,26 @@ func getTenantUsageResponse(session *models.Principal, params admin_api.GetTenan
|
||||
return info, nil
|
||||
}
|
||||
|
||||
// parseTenantZoneRequest parse zone request and returns the equivalent
|
||||
// operator.Zone object
|
||||
func parseTenantZoneRequest(zoneParams *models.Zone) (*operator.Zone, error) {
|
||||
if zoneParams.VolumeConfiguration == nil {
|
||||
// parseTenantPoolRequest parse pool request and returns the equivalent
|
||||
// operator.Pool object
|
||||
func parseTenantPoolRequest(poolParams *models.Pool) (*operator.Pool, error) {
|
||||
if poolParams.VolumeConfiguration == nil {
|
||||
return nil, errors.New("a volume configuration must be specified")
|
||||
}
|
||||
|
||||
if zoneParams.VolumeConfiguration.Size == nil || *zoneParams.VolumeConfiguration.Size <= int64(0) {
|
||||
if poolParams.VolumeConfiguration.Size == nil || *poolParams.VolumeConfiguration.Size <= int64(0) {
|
||||
return nil, errors.New("volume size must be greater than 0")
|
||||
}
|
||||
|
||||
if zoneParams.Servers == nil || *zoneParams.Servers <= 0 {
|
||||
if poolParams.Servers == nil || *poolParams.Servers <= 0 {
|
||||
return nil, errors.New("number of servers must be greater than 0")
|
||||
}
|
||||
|
||||
if zoneParams.VolumesPerServer == nil || *zoneParams.VolumesPerServer <= 0 {
|
||||
if poolParams.VolumesPerServer == nil || *poolParams.VolumesPerServer <= 0 {
|
||||
return nil, errors.New("number of volumes per server must be greater than 0")
|
||||
}
|
||||
|
||||
volumeSize := resource.NewQuantity(*zoneParams.VolumeConfiguration.Size, resource.DecimalExponent)
|
||||
volumeSize := resource.NewQuantity(*poolParams.VolumeConfiguration.Size, resource.DecimalExponent)
|
||||
volTemp := corev1.PersistentVolumeClaimSpec{
|
||||
AccessModes: []corev1.PersistentVolumeAccessMode{
|
||||
corev1.ReadWriteOnce,
|
||||
@@ -1110,18 +1112,18 @@ func parseTenantZoneRequest(zoneParams *models.Zone) (*operator.Zone, error) {
|
||||
},
|
||||
},
|
||||
}
|
||||
if zoneParams.VolumeConfiguration.StorageClassName != "" {
|
||||
volTemp.StorageClassName = &zoneParams.VolumeConfiguration.StorageClassName
|
||||
if poolParams.VolumeConfiguration.StorageClassName != "" {
|
||||
volTemp.StorageClassName = &poolParams.VolumeConfiguration.StorageClassName
|
||||
}
|
||||
|
||||
// parse resources' requests
|
||||
resourcesRequests := make(corev1.ResourceList)
|
||||
resourcesLimits := make(corev1.ResourceList)
|
||||
if zoneParams.Resources != nil {
|
||||
for key, val := range zoneParams.Resources.Requests {
|
||||
if poolParams.Resources != nil {
|
||||
for key, val := range poolParams.Resources.Requests {
|
||||
resourcesRequests[corev1.ResourceName(key)] = *resource.NewQuantity(val, resource.BinarySI)
|
||||
}
|
||||
for key, val := range zoneParams.Resources.Limits {
|
||||
for key, val := range poolParams.Resources.Limits {
|
||||
resourcesLimits[corev1.ResourceName(key)] = *resource.NewQuantity(val, resource.BinarySI)
|
||||
}
|
||||
}
|
||||
@@ -1129,14 +1131,14 @@ func parseTenantZoneRequest(zoneParams *models.Zone) (*operator.Zone, error) {
|
||||
// parse Node Affinity
|
||||
nodeSelectorTerms := []corev1.NodeSelectorTerm{}
|
||||
preferredSchedulingTerm := []corev1.PreferredSchedulingTerm{}
|
||||
if zoneParams.Affinity != nil && zoneParams.Affinity.NodeAffinity != nil {
|
||||
if zoneParams.Affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution != nil {
|
||||
for _, elem := range zoneParams.Affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms {
|
||||
if poolParams.Affinity != nil && poolParams.Affinity.NodeAffinity != nil {
|
||||
if poolParams.Affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution != nil {
|
||||
for _, elem := range poolParams.Affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms {
|
||||
term := parseModelsNodeSelectorTerm(elem)
|
||||
nodeSelectorTerms = append(nodeSelectorTerms, term)
|
||||
}
|
||||
}
|
||||
for _, elem := range zoneParams.Affinity.NodeAffinity.PreferredDuringSchedulingIgnoredDuringExecution {
|
||||
for _, elem := range poolParams.Affinity.NodeAffinity.PreferredDuringSchedulingIgnoredDuringExecution {
|
||||
pst := corev1.PreferredSchedulingTerm{
|
||||
Weight: *elem.Weight,
|
||||
Preference: parseModelsNodeSelectorTerm(elem.Preference),
|
||||
@@ -1157,11 +1159,11 @@ func parseTenantZoneRequest(zoneParams *models.Zone) (*operator.Zone, error) {
|
||||
// parse Pod Affinity
|
||||
podAffinityTerms := []corev1.PodAffinityTerm{}
|
||||
weightedPodAffinityTerms := []corev1.WeightedPodAffinityTerm{}
|
||||
if zoneParams.Affinity != nil && zoneParams.Affinity.PodAffinity != nil {
|
||||
for _, elem := range zoneParams.Affinity.PodAffinity.RequiredDuringSchedulingIgnoredDuringExecution {
|
||||
if poolParams.Affinity != nil && poolParams.Affinity.PodAffinity != nil {
|
||||
for _, elem := range poolParams.Affinity.PodAffinity.RequiredDuringSchedulingIgnoredDuringExecution {
|
||||
podAffinityTerms = append(podAffinityTerms, parseModelPodAffinityTerm(elem))
|
||||
}
|
||||
for _, elem := range zoneParams.Affinity.PodAffinity.PreferredDuringSchedulingIgnoredDuringExecution {
|
||||
for _, elem := range poolParams.Affinity.PodAffinity.PreferredDuringSchedulingIgnoredDuringExecution {
|
||||
wAffinityTerm := corev1.WeightedPodAffinityTerm{
|
||||
Weight: *elem.Weight,
|
||||
PodAffinityTerm: parseModelPodAffinityTerm(elem.PodAffinityTerm),
|
||||
@@ -1180,11 +1182,11 @@ func parseTenantZoneRequest(zoneParams *models.Zone) (*operator.Zone, error) {
|
||||
// parse Pod Anti Affinity
|
||||
podAntiAffinityTerms := []corev1.PodAffinityTerm{}
|
||||
weightedPodAntiAffinityTerms := []corev1.WeightedPodAffinityTerm{}
|
||||
if zoneParams.Affinity != nil && zoneParams.Affinity.PodAntiAffinity != nil {
|
||||
for _, elem := range zoneParams.Affinity.PodAntiAffinity.RequiredDuringSchedulingIgnoredDuringExecution {
|
||||
if poolParams.Affinity != nil && poolParams.Affinity.PodAntiAffinity != nil {
|
||||
for _, elem := range poolParams.Affinity.PodAntiAffinity.RequiredDuringSchedulingIgnoredDuringExecution {
|
||||
podAntiAffinityTerms = append(podAntiAffinityTerms, parseModelPodAffinityTerm(elem))
|
||||
}
|
||||
for _, elem := range zoneParams.Affinity.PodAntiAffinity.PreferredDuringSchedulingIgnoredDuringExecution {
|
||||
for _, elem := range poolParams.Affinity.PodAntiAffinity.PreferredDuringSchedulingIgnoredDuringExecution {
|
||||
wAffinityTerm := corev1.WeightedPodAffinityTerm{
|
||||
Weight: *elem.Weight,
|
||||
PodAffinityTerm: parseModelPodAffinityTerm(elem.PodAffinityTerm),
|
||||
@@ -1211,7 +1213,7 @@ func parseTenantZoneRequest(zoneParams *models.Zone) (*operator.Zone, error) {
|
||||
|
||||
// parse tolerations
|
||||
tolerations := []corev1.Toleration{}
|
||||
for _, elem := range zoneParams.Tolerations {
|
||||
for _, elem := range poolParams.Tolerations {
|
||||
var tolerationSeconds *int64
|
||||
if elem.TolerationSeconds != nil {
|
||||
// elem.TolerationSeconds.Seconds is allowed to be nil
|
||||
@@ -1232,26 +1234,26 @@ func parseTenantZoneRequest(zoneParams *models.Zone) (*operator.Zone, error) {
|
||||
vct := &corev1.PersistentVolumeClaim{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "data",
|
||||
Labels: zoneParams.VolumeConfiguration.Labels,
|
||||
Annotations: zoneParams.VolumeConfiguration.Annotations,
|
||||
Labels: poolParams.VolumeConfiguration.Labels,
|
||||
Annotations: poolParams.VolumeConfiguration.Annotations,
|
||||
},
|
||||
Spec: volTemp,
|
||||
}
|
||||
|
||||
zone := &operator.Zone{
|
||||
Name: zoneParams.Name,
|
||||
Servers: int32(*zoneParams.Servers),
|
||||
VolumesPerServer: *zoneParams.VolumesPerServer,
|
||||
pool := &operator.Pool{
|
||||
Name: poolParams.Name,
|
||||
Servers: int32(*poolParams.Servers),
|
||||
VolumesPerServer: *poolParams.VolumesPerServer,
|
||||
VolumeClaimTemplate: vct,
|
||||
Resources: corev1.ResourceRequirements{
|
||||
Requests: resourcesRequests,
|
||||
Limits: resourcesLimits,
|
||||
},
|
||||
NodeSelector: zoneParams.NodeSelector,
|
||||
NodeSelector: poolParams.NodeSelector,
|
||||
Affinity: affinity,
|
||||
Tolerations: tolerations,
|
||||
}
|
||||
return zone, nil
|
||||
return pool, nil
|
||||
}
|
||||
|
||||
func parseModelPodAffinityTerm(term *models.PodAffinityTerm) corev1.PodAffinityTerm {
|
||||
@@ -1297,30 +1299,30 @@ func parseModelsNodeSelectorTerm(elem *models.NodeSelectorTerm) corev1.NodeSelec
|
||||
return term
|
||||
}
|
||||
|
||||
// parseTenantZone operator Zone object and returns the equivalent
|
||||
// models.Zone object
|
||||
func parseTenantZone(zone *operator.Zone) *models.Zone {
|
||||
// parseTenantPool operator pool object and returns the equivalent
|
||||
// models.Pool object
|
||||
func parseTenantPool(pool *operator.Pool) *models.Pool {
|
||||
var size *int64
|
||||
var storageClassName string
|
||||
if zone.VolumeClaimTemplate != nil {
|
||||
size = swag.Int64(zone.VolumeClaimTemplate.Spec.Resources.Requests.Storage().Value())
|
||||
if zone.VolumeClaimTemplate.Spec.StorageClassName != nil {
|
||||
storageClassName = *zone.VolumeClaimTemplate.Spec.StorageClassName
|
||||
if pool.VolumeClaimTemplate != nil {
|
||||
size = swag.Int64(pool.VolumeClaimTemplate.Spec.Resources.Requests.Storage().Value())
|
||||
if pool.VolumeClaimTemplate.Spec.StorageClassName != nil {
|
||||
storageClassName = *pool.VolumeClaimTemplate.Spec.StorageClassName
|
||||
}
|
||||
}
|
||||
|
||||
// parse resources' requests
|
||||
var resources *models.ZoneResources
|
||||
var resources *models.PoolResources
|
||||
resourcesRequests := make(map[string]int64)
|
||||
resourcesLimits := make(map[string]int64)
|
||||
for key, val := range zone.Resources.Requests {
|
||||
for key, val := range pool.Resources.Requests {
|
||||
resourcesRequests[key.String()] = val.Value()
|
||||
}
|
||||
for key, val := range zone.Resources.Limits {
|
||||
for key, val := range pool.Resources.Limits {
|
||||
resourcesLimits[key.String()] = val.Value()
|
||||
}
|
||||
if len(resourcesRequests) > 0 || len(resourcesLimits) > 0 {
|
||||
resources = &models.ZoneResources{
|
||||
resources = &models.PoolResources{
|
||||
Limits: resourcesLimits,
|
||||
Requests: resourcesRequests,
|
||||
}
|
||||
@@ -1328,17 +1330,17 @@ func parseTenantZone(zone *operator.Zone) *models.Zone {
|
||||
|
||||
// parse Node Affinity
|
||||
nodeSelectorTerms := []*models.NodeSelectorTerm{}
|
||||
preferredSchedulingTerm := []*models.ZoneAffinityNodeAffinityPreferredDuringSchedulingIgnoredDuringExecutionItems0{}
|
||||
preferredSchedulingTerm := []*models.PoolAffinityNodeAffinityPreferredDuringSchedulingIgnoredDuringExecutionItems0{}
|
||||
|
||||
if zone.Affinity != nil && zone.Affinity.NodeAffinity != nil {
|
||||
if zone.Affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution != nil {
|
||||
for _, elem := range zone.Affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms {
|
||||
if pool.Affinity != nil && pool.Affinity.NodeAffinity != nil {
|
||||
if pool.Affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution != nil {
|
||||
for _, elem := range pool.Affinity.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms {
|
||||
term := parseNodeSelectorTerm(&elem)
|
||||
nodeSelectorTerms = append(nodeSelectorTerms, term)
|
||||
}
|
||||
}
|
||||
for _, elem := range zone.Affinity.NodeAffinity.PreferredDuringSchedulingIgnoredDuringExecution {
|
||||
pst := &models.ZoneAffinityNodeAffinityPreferredDuringSchedulingIgnoredDuringExecutionItems0{
|
||||
for _, elem := range pool.Affinity.NodeAffinity.PreferredDuringSchedulingIgnoredDuringExecution {
|
||||
pst := &models.PoolAffinityNodeAffinityPreferredDuringSchedulingIgnoredDuringExecutionItems0{
|
||||
Weight: swag.Int32(elem.Weight),
|
||||
Preference: parseNodeSelectorTerm(&elem.Preference),
|
||||
}
|
||||
@@ -1346,10 +1348,10 @@ func parseTenantZone(zone *operator.Zone) *models.Zone {
|
||||
}
|
||||
}
|
||||
|
||||
var nodeAffinity *models.ZoneAffinityNodeAffinity
|
||||
var nodeAffinity *models.PoolAffinityNodeAffinity
|
||||
if len(nodeSelectorTerms) > 0 || len(preferredSchedulingTerm) > 0 {
|
||||
nodeAffinity = &models.ZoneAffinityNodeAffinity{
|
||||
RequiredDuringSchedulingIgnoredDuringExecution: &models.ZoneAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecution{
|
||||
nodeAffinity = &models.PoolAffinityNodeAffinity{
|
||||
RequiredDuringSchedulingIgnoredDuringExecution: &models.PoolAffinityNodeAffinityRequiredDuringSchedulingIgnoredDuringExecution{
|
||||
NodeSelectorTerms: nodeSelectorTerms,
|
||||
},
|
||||
PreferredDuringSchedulingIgnoredDuringExecution: preferredSchedulingTerm,
|
||||
@@ -1358,23 +1360,23 @@ func parseTenantZone(zone *operator.Zone) *models.Zone {
|
||||
|
||||
// parse Pod Affinity
|
||||
podAffinityTerms := []*models.PodAffinityTerm{}
|
||||
weightedPodAffinityTerms := []*models.ZoneAffinityPodAffinityPreferredDuringSchedulingIgnoredDuringExecutionItems0{}
|
||||
weightedPodAffinityTerms := []*models.PoolAffinityPodAffinityPreferredDuringSchedulingIgnoredDuringExecutionItems0{}
|
||||
|
||||
if zone.Affinity != nil && zone.Affinity.PodAffinity != nil {
|
||||
for _, elem := range zone.Affinity.PodAffinity.RequiredDuringSchedulingIgnoredDuringExecution {
|
||||
if pool.Affinity != nil && pool.Affinity.PodAffinity != nil {
|
||||
for _, elem := range pool.Affinity.PodAffinity.RequiredDuringSchedulingIgnoredDuringExecution {
|
||||
podAffinityTerms = append(podAffinityTerms, parsePodAffinityTerm(&elem))
|
||||
}
|
||||
for _, elem := range zone.Affinity.PodAffinity.PreferredDuringSchedulingIgnoredDuringExecution {
|
||||
wAffinityTerm := &models.ZoneAffinityPodAffinityPreferredDuringSchedulingIgnoredDuringExecutionItems0{
|
||||
for _, elem := range pool.Affinity.PodAffinity.PreferredDuringSchedulingIgnoredDuringExecution {
|
||||
wAffinityTerm := &models.PoolAffinityPodAffinityPreferredDuringSchedulingIgnoredDuringExecutionItems0{
|
||||
Weight: swag.Int32(elem.Weight),
|
||||
PodAffinityTerm: parsePodAffinityTerm(&elem.PodAffinityTerm),
|
||||
}
|
||||
weightedPodAffinityTerms = append(weightedPodAffinityTerms, wAffinityTerm)
|
||||
}
|
||||
}
|
||||
var podAffinity *models.ZoneAffinityPodAffinity
|
||||
var podAffinity *models.PoolAffinityPodAffinity
|
||||
if len(podAffinityTerms) > 0 || len(weightedPodAffinityTerms) > 0 {
|
||||
podAffinity = &models.ZoneAffinityPodAffinity{
|
||||
podAffinity = &models.PoolAffinityPodAffinity{
|
||||
RequiredDuringSchedulingIgnoredDuringExecution: podAffinityTerms,
|
||||
PreferredDuringSchedulingIgnoredDuringExecution: weightedPodAffinityTerms,
|
||||
}
|
||||
@@ -1382,14 +1384,14 @@ func parseTenantZone(zone *operator.Zone) *models.Zone {
|
||||
|
||||
// parse Pod Anti Affinity
|
||||
podAntiAffinityTerms := []*models.PodAffinityTerm{}
|
||||
weightedPodAntiAffinityTerms := []*models.ZoneAffinityPodAntiAffinityPreferredDuringSchedulingIgnoredDuringExecutionItems0{}
|
||||
weightedPodAntiAffinityTerms := []*models.PoolAffinityPodAntiAffinityPreferredDuringSchedulingIgnoredDuringExecutionItems0{}
|
||||
|
||||
if zone.Affinity != nil && zone.Affinity.PodAntiAffinity != nil {
|
||||
for _, elem := range zone.Affinity.PodAntiAffinity.RequiredDuringSchedulingIgnoredDuringExecution {
|
||||
if pool.Affinity != nil && pool.Affinity.PodAntiAffinity != nil {
|
||||
for _, elem := range pool.Affinity.PodAntiAffinity.RequiredDuringSchedulingIgnoredDuringExecution {
|
||||
podAntiAffinityTerms = append(podAntiAffinityTerms, parsePodAffinityTerm(&elem))
|
||||
}
|
||||
for _, elem := range zone.Affinity.PodAntiAffinity.PreferredDuringSchedulingIgnoredDuringExecution {
|
||||
wAffinityTerm := &models.ZoneAffinityPodAntiAffinityPreferredDuringSchedulingIgnoredDuringExecutionItems0{
|
||||
for _, elem := range pool.Affinity.PodAntiAffinity.PreferredDuringSchedulingIgnoredDuringExecution {
|
||||
wAffinityTerm := &models.PoolAffinityPodAntiAffinityPreferredDuringSchedulingIgnoredDuringExecutionItems0{
|
||||
Weight: swag.Int32(elem.Weight),
|
||||
PodAffinityTerm: parsePodAffinityTerm(&elem.PodAffinityTerm),
|
||||
}
|
||||
@@ -1397,18 +1399,18 @@ func parseTenantZone(zone *operator.Zone) *models.Zone {
|
||||
}
|
||||
}
|
||||
|
||||
var podAntiAffinity *models.ZoneAffinityPodAntiAffinity
|
||||
var podAntiAffinity *models.PoolAffinityPodAntiAffinity
|
||||
if len(podAntiAffinityTerms) > 0 || len(weightedPodAntiAffinityTerms) > 0 {
|
||||
podAntiAffinity = &models.ZoneAffinityPodAntiAffinity{
|
||||
podAntiAffinity = &models.PoolAffinityPodAntiAffinity{
|
||||
RequiredDuringSchedulingIgnoredDuringExecution: podAntiAffinityTerms,
|
||||
PreferredDuringSchedulingIgnoredDuringExecution: weightedPodAntiAffinityTerms,
|
||||
}
|
||||
}
|
||||
|
||||
// build affinity object
|
||||
var affinity *models.ZoneAffinity
|
||||
var affinity *models.PoolAffinity
|
||||
if nodeAffinity != nil || podAffinity != nil || podAntiAffinity != nil {
|
||||
affinity = &models.ZoneAffinity{
|
||||
affinity = &models.PoolAffinity{
|
||||
NodeAffinity: nodeAffinity,
|
||||
PodAffinity: podAffinity,
|
||||
PodAntiAffinity: podAntiAffinity,
|
||||
@@ -1416,15 +1418,15 @@ func parseTenantZone(zone *operator.Zone) *models.Zone {
|
||||
}
|
||||
|
||||
// parse tolerations
|
||||
var tolerations models.ZoneTolerations
|
||||
for _, elem := range zone.Tolerations {
|
||||
var tolerationSecs *models.ZoneTolerationSeconds
|
||||
var tolerations models.PoolTolerations
|
||||
for _, elem := range pool.Tolerations {
|
||||
var tolerationSecs *models.PoolTolerationSeconds
|
||||
if elem.TolerationSeconds != nil {
|
||||
tolerationSecs = &models.ZoneTolerationSeconds{
|
||||
tolerationSecs = &models.PoolTolerationSeconds{
|
||||
Seconds: elem.TolerationSeconds,
|
||||
}
|
||||
}
|
||||
toleration := &models.ZoneTolerationsItems0{
|
||||
toleration := &models.PoolTolerationsItems0{
|
||||
Key: elem.Key,
|
||||
Operator: string(elem.Operator),
|
||||
Value: elem.Value,
|
||||
@@ -1434,20 +1436,20 @@ func parseTenantZone(zone *operator.Zone) *models.Zone {
|
||||
tolerations = append(tolerations, toleration)
|
||||
}
|
||||
|
||||
zoneModel := &models.Zone{
|
||||
Name: zone.Name,
|
||||
Servers: swag.Int64(int64(zone.Servers)),
|
||||
VolumesPerServer: swag.Int32(zone.VolumesPerServer),
|
||||
VolumeConfiguration: &models.ZoneVolumeConfiguration{
|
||||
poolModel := &models.Pool{
|
||||
Name: pool.Name,
|
||||
Servers: swag.Int64(int64(pool.Servers)),
|
||||
VolumesPerServer: swag.Int32(pool.VolumesPerServer),
|
||||
VolumeConfiguration: &models.PoolVolumeConfiguration{
|
||||
Size: size,
|
||||
StorageClassName: storageClassName,
|
||||
},
|
||||
NodeSelector: zone.NodeSelector,
|
||||
NodeSelector: pool.NodeSelector,
|
||||
Resources: resources,
|
||||
Affinity: affinity,
|
||||
Tolerations: tolerations,
|
||||
}
|
||||
return zoneModel
|
||||
return poolModel
|
||||
}
|
||||
|
||||
func parsePodAffinityTerm(term *corev1.PodAffinityTerm) *models.PodAffinityTerm {
|
||||
@@ -1493,7 +1495,7 @@ func parseNodeSelectorTerm(term *corev1.NodeSelectorTerm) *models.NodeSelectorTe
|
||||
return &t
|
||||
}
|
||||
|
||||
func getTenantUpdateZoneResponse(session *models.Principal, params admin_api.TenantUpdateZonesParams) (*models.Tenant, *models.Error) {
|
||||
func getTenantUpdatePoolResponse(session *models.Principal, params admin_api.TenantUpdatePoolsParams) (*models.Tenant, *models.Error) {
|
||||
ctx := context.Background()
|
||||
opClientClientSet, err := cluster.OperatorClient(session.SessionToken)
|
||||
if err != nil {
|
||||
@@ -1504,9 +1506,9 @@ func getTenantUpdateZoneResponse(session *models.Principal, params admin_api.Ten
|
||||
client: opClientClientSet,
|
||||
}
|
||||
|
||||
t, err := updateTenantZones(ctx, opClient, params.Namespace, params.Tenant, params.Body.Zones)
|
||||
t, err := updateTenantPools(ctx, opClient, params.Namespace, params.Tenant, params.Body.Pools)
|
||||
if err != nil {
|
||||
log.Println("error updating Tenant's zones:", err)
|
||||
log.Println("error updating Tenant's pools:", err)
|
||||
return nil, prepareError(err)
|
||||
}
|
||||
|
||||
@@ -1515,33 +1517,33 @@ func getTenantUpdateZoneResponse(session *models.Principal, params admin_api.Ten
|
||||
return tenant, nil
|
||||
}
|
||||
|
||||
// updateTenantZones Sets the Tenant's zones to the ones provided by the request
|
||||
// updateTenantPools Sets the Tenant's pools to the ones provided by the request
|
||||
//
|
||||
// It does the equivalent to a PUT request on Tenant's zones
|
||||
func updateTenantZones(
|
||||
// It does the equivalent to a PUT request on Tenant's pools
|
||||
func updateTenantPools(
|
||||
ctx context.Context,
|
||||
operatorClient OperatorClientI,
|
||||
namespace string,
|
||||
tenantName string,
|
||||
zonesReq []*models.Zone) (*operator.Tenant, error) {
|
||||
poolsReq []*models.Pool) (*operator.Tenant, error) {
|
||||
|
||||
minInst, err := operatorClient.TenantGet(ctx, namespace, tenantName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// set the zones if they are provided
|
||||
var newZoneArray []operator.Zone
|
||||
for _, zone := range zonesReq {
|
||||
zone, err := parseTenantZoneRequest(zone)
|
||||
// set the pools if they are provided
|
||||
var newPoolArray []operator.Pool
|
||||
for _, pool := range poolsReq {
|
||||
pool, err := parseTenantPoolRequest(pool)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
newZoneArray = append(newZoneArray, *zone)
|
||||
newPoolArray = append(newPoolArray, *pool)
|
||||
}
|
||||
|
||||
// replace zones array
|
||||
minInst.Spec.Zones = newZoneArray
|
||||
// replace pools array
|
||||
minInst.Spec.Pools = newPoolArray
|
||||
|
||||
minInst = minInst.DeepCopy()
|
||||
minInst.EnsureDefaults()
|
||||
|
||||
@@ -287,9 +287,9 @@ func Test_TenantInfo(t *testing.T) {
|
||||
Namespace: "minio-ns",
|
||||
},
|
||||
Spec: operator.TenantSpec{
|
||||
Zones: []operator.Zone{
|
||||
Pools: []operator.Pool{
|
||||
{
|
||||
Name: "zone1",
|
||||
Name: "pool1",
|
||||
Servers: int32(2),
|
||||
VolumesPerServer: 4,
|
||||
VolumeClaimTemplate: &corev1.PersistentVolumeClaim{
|
||||
@@ -317,12 +317,12 @@ func Test_TenantInfo(t *testing.T) {
|
||||
Name: "tenant1",
|
||||
TotalSize: int64(8388608),
|
||||
CurrentState: "ready",
|
||||
Zones: []*models.Zone{
|
||||
Pools: []*models.Pool{
|
||||
{
|
||||
Name: "zone1",
|
||||
Name: "pool1",
|
||||
Servers: swag.Int64(int64(2)),
|
||||
VolumesPerServer: swag.Int32(4),
|
||||
VolumeConfiguration: &models.ZoneVolumeConfiguration{
|
||||
VolumeConfiguration: &models.PoolVolumeConfiguration{
|
||||
StorageClassName: "standard",
|
||||
Size: swag.Int64(1024 * 1024),
|
||||
},
|
||||
@@ -352,9 +352,9 @@ func Test_TenantInfo(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Spec: operator.TenantSpec{
|
||||
Zones: []operator.Zone{
|
||||
Pools: []operator.Pool{
|
||||
{
|
||||
Name: "zone1",
|
||||
Name: "pool1",
|
||||
Servers: int32(2),
|
||||
VolumesPerServer: 4,
|
||||
VolumeClaimTemplate: &corev1.PersistentVolumeClaim{
|
||||
@@ -382,12 +382,12 @@ func Test_TenantInfo(t *testing.T) {
|
||||
Name: "tenant1",
|
||||
TotalSize: int64(8388608),
|
||||
CurrentState: "ready",
|
||||
Zones: []*models.Zone{
|
||||
Pools: []*models.Pool{
|
||||
{
|
||||
Name: "zone1",
|
||||
Name: "pool1",
|
||||
Servers: swag.Int64(int64(2)),
|
||||
VolumesPerServer: swag.Int32(4),
|
||||
VolumeConfiguration: &models.ZoneVolumeConfiguration{
|
||||
VolumeConfiguration: &models.PoolVolumeConfiguration{
|
||||
StorageClassName: "standard",
|
||||
Size: swag.Int64(1024 * 1024),
|
||||
},
|
||||
@@ -414,7 +414,7 @@ func Test_TenantInfo(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Spec: operator.TenantSpec{
|
||||
Zones: []operator.Zone{},
|
||||
Pools: []operator.Pool{},
|
||||
Image: "minio/minio:RELEASE.2020-06-14T18-32-17Z",
|
||||
},
|
||||
Status: operator.TenantStatus{
|
||||
@@ -446,7 +446,7 @@ func Test_TenantInfo(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Spec: operator.TenantSpec{
|
||||
Zones: []operator.Zone{},
|
||||
Pools: []operator.Pool{},
|
||||
Image: "minio/minio:RELEASE.2020-06-14T18-32-17Z",
|
||||
Console: &operator.ConsoleConfiguration{
|
||||
Image: "minio/console:master",
|
||||
@@ -540,7 +540,7 @@ func Test_deleteTenantAction(t *testing.T) {
|
||||
Namespace: "minio-tenant",
|
||||
Labels: map[string]string{
|
||||
operator.TenantLabel: "tenant1",
|
||||
operator.ZoneLabel: "zone-1",
|
||||
operator.PoolLabel: "pool-1",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -567,7 +567,7 @@ func Test_deleteTenantAction(t *testing.T) {
|
||||
Namespace: "minio-tenant",
|
||||
Labels: map[string]string{
|
||||
operator.TenantLabel: "tenant1",
|
||||
operator.ZoneLabel: "zone-1",
|
||||
operator.PoolLabel: "pool-1",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -594,7 +594,7 @@ func Test_deleteTenantAction(t *testing.T) {
|
||||
Namespace: "minio-tenant",
|
||||
Labels: map[string]string{
|
||||
operator.TenantLabel: "tenant1",
|
||||
operator.ZoneLabel: "zone-1",
|
||||
operator.PoolLabel: "pool-1",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -621,7 +621,7 @@ func Test_deleteTenantAction(t *testing.T) {
|
||||
Namespace: "minio-tenant",
|
||||
Labels: map[string]string{
|
||||
operator.TenantLabel: "tenant1",
|
||||
operator.ZoneLabel: "zone-1",
|
||||
operator.PoolLabel: "pool-1",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -649,7 +649,7 @@ func Test_deleteTenantAction(t *testing.T) {
|
||||
Namespace: "minio-tenant",
|
||||
Labels: map[string]string{
|
||||
operator.TenantLabel: "tenant1",
|
||||
operator.ZoneLabel: "zone-1",
|
||||
operator.PoolLabel: "pool-1",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -672,7 +672,7 @@ func Test_deleteTenantAction(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func Test_TenantAddZone(t *testing.T) {
|
||||
func Test_TenantAddPool(t *testing.T) {
|
||||
opClient := opClientMock{}
|
||||
|
||||
type args struct {
|
||||
@@ -681,7 +681,7 @@ func Test_TenantAddZone(t *testing.T) {
|
||||
nameSpace string
|
||||
mockTenantPatch func(ctx context.Context, namespace string, tenantName string, pt types.PatchType, data []byte, options metav1.PatchOptions) (*v1.Tenant, error)
|
||||
mockTenantGet func(ctx context.Context, namespace string, tenantName string, options metav1.GetOptions) (*v1.Tenant, error)
|
||||
params admin_api.TenantAddZoneParams
|
||||
params admin_api.TenantAddPoolParams
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -689,7 +689,7 @@ func Test_TenantAddZone(t *testing.T) {
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "Add zone, no errors",
|
||||
name: "Add pool, no errors",
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
operatorClient: opClient,
|
||||
@@ -700,11 +700,11 @@ func Test_TenantAddZone(t *testing.T) {
|
||||
mockTenantGet: func(ctx context.Context, namespace string, tenantName string, options metav1.GetOptions) (*v1.Tenant, error) {
|
||||
return &v1.Tenant{}, nil
|
||||
},
|
||||
params: admin_api.TenantAddZoneParams{
|
||||
Body: &models.Zone{
|
||||
Name: "zone-1",
|
||||
params: admin_api.TenantAddPoolParams{
|
||||
Body: &models.Pool{
|
||||
Name: "pool-1",
|
||||
Servers: swag.Int64(int64(4)),
|
||||
VolumeConfiguration: &models.ZoneVolumeConfiguration{
|
||||
VolumeConfiguration: &models.PoolVolumeConfiguration{
|
||||
Size: swag.Int64(2147483648),
|
||||
StorageClassName: "standard",
|
||||
},
|
||||
@@ -714,7 +714,7 @@ func Test_TenantAddZone(t *testing.T) {
|
||||
},
|
||||
wantErr: false,
|
||||
}, {
|
||||
name: "Add zone, error size",
|
||||
name: "Add pool, error size",
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
operatorClient: opClient,
|
||||
@@ -725,11 +725,11 @@ func Test_TenantAddZone(t *testing.T) {
|
||||
mockTenantGet: func(ctx context.Context, namespace string, tenantName string, options metav1.GetOptions) (*v1.Tenant, error) {
|
||||
return &v1.Tenant{}, nil
|
||||
},
|
||||
params: admin_api.TenantAddZoneParams{
|
||||
Body: &models.Zone{
|
||||
Name: "zone-1",
|
||||
params: admin_api.TenantAddPoolParams{
|
||||
Body: &models.Pool{
|
||||
Name: "pool-1",
|
||||
Servers: swag.Int64(int64(4)),
|
||||
VolumeConfiguration: &models.ZoneVolumeConfiguration{
|
||||
VolumeConfiguration: &models.PoolVolumeConfiguration{
|
||||
Size: swag.Int64(0),
|
||||
StorageClassName: "standard",
|
||||
},
|
||||
@@ -740,7 +740,7 @@ func Test_TenantAddZone(t *testing.T) {
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "Add zone, error servers negative",
|
||||
name: "Add pool, error servers negative",
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
operatorClient: opClient,
|
||||
@@ -751,11 +751,11 @@ func Test_TenantAddZone(t *testing.T) {
|
||||
mockTenantGet: func(ctx context.Context, namespace string, tenantName string, options metav1.GetOptions) (*v1.Tenant, error) {
|
||||
return &v1.Tenant{}, nil
|
||||
},
|
||||
params: admin_api.TenantAddZoneParams{
|
||||
Body: &models.Zone{
|
||||
Name: "zone-1",
|
||||
params: admin_api.TenantAddPoolParams{
|
||||
Body: &models.Pool{
|
||||
Name: "pool-1",
|
||||
Servers: swag.Int64(int64(-1)),
|
||||
VolumeConfiguration: &models.ZoneVolumeConfiguration{
|
||||
VolumeConfiguration: &models.PoolVolumeConfiguration{
|
||||
Size: swag.Int64(2147483648),
|
||||
StorageClassName: "standard",
|
||||
},
|
||||
@@ -766,7 +766,7 @@ func Test_TenantAddZone(t *testing.T) {
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "Add zone, error volumes per server negative",
|
||||
name: "Add pool, error volumes per server negative",
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
operatorClient: opClient,
|
||||
@@ -777,11 +777,11 @@ func Test_TenantAddZone(t *testing.T) {
|
||||
mockTenantGet: func(ctx context.Context, namespace string, tenantName string, options metav1.GetOptions) (*v1.Tenant, error) {
|
||||
return &v1.Tenant{}, nil
|
||||
},
|
||||
params: admin_api.TenantAddZoneParams{
|
||||
Body: &models.Zone{
|
||||
Name: "zone-1",
|
||||
params: admin_api.TenantAddPoolParams{
|
||||
Body: &models.Pool{
|
||||
Name: "pool-1",
|
||||
Servers: swag.Int64(int64(4)),
|
||||
VolumeConfiguration: &models.ZoneVolumeConfiguration{
|
||||
VolumeConfiguration: &models.PoolVolumeConfiguration{
|
||||
Size: swag.Int64(2147483648),
|
||||
StorageClassName: "standard",
|
||||
},
|
||||
@@ -803,9 +803,9 @@ func Test_TenantAddZone(t *testing.T) {
|
||||
mockTenantGet: func(ctx context.Context, namespace string, tenantName string, options metav1.GetOptions) (*v1.Tenant, error) {
|
||||
return &v1.Tenant{}, nil
|
||||
},
|
||||
params: admin_api.TenantAddZoneParams{
|
||||
Body: &models.Zone{
|
||||
Name: "zone-1",
|
||||
params: admin_api.TenantAddPoolParams{
|
||||
Body: &models.Pool{
|
||||
Name: "pool-1",
|
||||
Servers: swag.Int64(int64(4)),
|
||||
},
|
||||
},
|
||||
@@ -824,9 +824,9 @@ func Test_TenantAddZone(t *testing.T) {
|
||||
mockTenantGet: func(ctx context.Context, namespace string, tenantName string, options metav1.GetOptions) (*v1.Tenant, error) {
|
||||
return nil, errors.New("errors")
|
||||
},
|
||||
params: admin_api.TenantAddZoneParams{
|
||||
Body: &models.Zone{
|
||||
Name: "zone-1",
|
||||
params: admin_api.TenantAddPoolParams{
|
||||
Body: &models.Pool{
|
||||
Name: "pool-1",
|
||||
Servers: swag.Int64(int64(4)),
|
||||
},
|
||||
},
|
||||
@@ -838,8 +838,8 @@ func Test_TenantAddZone(t *testing.T) {
|
||||
opClientTenantGetMock = tt.args.mockTenantGet
|
||||
opClientTenantPatchMock = tt.args.mockTenantPatch
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if err := addTenantZone(tt.args.ctx, tt.args.operatorClient, tt.args.params); (err != nil) != tt.wantErr {
|
||||
t.Errorf("addTenantZone() error = %v, wantErr %v", err, tt.wantErr)
|
||||
if err := addTenantPool(tt.args.ctx, tt.args.operatorClient, tt.args.params); (err != nil) != tt.wantErr {
|
||||
t.Errorf("addTenantPool() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -30,40 +30,40 @@ import (
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// TenantAddZoneHandlerFunc turns a function with the right signature into a tenant add zone handler
|
||||
type TenantAddZoneHandlerFunc func(TenantAddZoneParams, *models.Principal) middleware.Responder
|
||||
// TenantAddPoolHandlerFunc turns a function with the right signature into a tenant add pool handler
|
||||
type TenantAddPoolHandlerFunc func(TenantAddPoolParams, *models.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn TenantAddZoneHandlerFunc) Handle(params TenantAddZoneParams, principal *models.Principal) middleware.Responder {
|
||||
func (fn TenantAddPoolHandlerFunc) Handle(params TenantAddPoolParams, principal *models.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// TenantAddZoneHandler interface for that can handle valid tenant add zone params
|
||||
type TenantAddZoneHandler interface {
|
||||
Handle(TenantAddZoneParams, *models.Principal) middleware.Responder
|
||||
// TenantAddPoolHandler interface for that can handle valid tenant add pool params
|
||||
type TenantAddPoolHandler interface {
|
||||
Handle(TenantAddPoolParams, *models.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewTenantAddZone creates a new http.Handler for the tenant add zone operation
|
||||
func NewTenantAddZone(ctx *middleware.Context, handler TenantAddZoneHandler) *TenantAddZone {
|
||||
return &TenantAddZone{Context: ctx, Handler: handler}
|
||||
// NewTenantAddPool creates a new http.Handler for the tenant add pool operation
|
||||
func NewTenantAddPool(ctx *middleware.Context, handler TenantAddPoolHandler) *TenantAddPool {
|
||||
return &TenantAddPool{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*TenantAddZone swagger:route POST /namespaces/{namespace}/tenants/{tenant}/zones AdminAPI tenantAddZone
|
||||
/*TenantAddPool swagger:route POST /namespaces/{namespace}/tenants/{tenant}/pools AdminAPI tenantAddPool
|
||||
|
||||
Tenant Add Zone
|
||||
Tenant Add Pool
|
||||
|
||||
*/
|
||||
type TenantAddZone struct {
|
||||
type TenantAddPool struct {
|
||||
Context *middleware.Context
|
||||
Handler TenantAddZoneHandler
|
||||
Handler TenantAddPoolHandler
|
||||
}
|
||||
|
||||
func (o *TenantAddZone) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
func (o *TenantAddPool) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
r = rCtx
|
||||
}
|
||||
var Params = NewTenantAddZoneParams()
|
||||
var Params = NewTenantAddPoolParams()
|
||||
|
||||
uprinc, aCtx, err := o.Context.Authorize(r, route)
|
||||
if err != nil {
|
||||
@@ -34,18 +34,18 @@ import (
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// NewTenantAddZoneParams creates a new TenantAddZoneParams object
|
||||
// NewTenantAddPoolParams creates a new TenantAddPoolParams object
|
||||
// no default values defined in spec.
|
||||
func NewTenantAddZoneParams() TenantAddZoneParams {
|
||||
func NewTenantAddPoolParams() TenantAddPoolParams {
|
||||
|
||||
return TenantAddZoneParams{}
|
||||
return TenantAddPoolParams{}
|
||||
}
|
||||
|
||||
// TenantAddZoneParams contains all the bound params for the tenant add zone operation
|
||||
// TenantAddPoolParams contains all the bound params for the tenant add pool operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters TenantAddZone
|
||||
type TenantAddZoneParams struct {
|
||||
// swagger:parameters TenantAddPool
|
||||
type TenantAddPoolParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
@@ -54,7 +54,7 @@ type TenantAddZoneParams struct {
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Body *models.Zone
|
||||
Body *models.Pool
|
||||
/*
|
||||
Required: true
|
||||
In: path
|
||||
@@ -70,15 +70,15 @@ type TenantAddZoneParams struct {
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls.
|
||||
//
|
||||
// To ensure default values, the struct must have been initialized with NewTenantAddZoneParams() beforehand.
|
||||
func (o *TenantAddZoneParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
// To ensure default values, the struct must have been initialized with NewTenantAddPoolParams() beforehand.
|
||||
func (o *TenantAddPoolParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
if runtime.HasBody(r) {
|
||||
defer r.Body.Close()
|
||||
var body models.Zone
|
||||
var body models.Pool
|
||||
if err := route.Consumer.Consume(r.Body, &body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("body", "body", ""))
|
||||
@@ -115,7 +115,7 @@ func (o *TenantAddZoneParams) BindRequest(r *http.Request, route *middleware.Mat
|
||||
}
|
||||
|
||||
// bindNamespace binds and validates parameter Namespace from path.
|
||||
func (o *TenantAddZoneParams) bindNamespace(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
func (o *TenantAddPoolParams) bindNamespace(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
@@ -130,7 +130,7 @@ func (o *TenantAddZoneParams) bindNamespace(rawData []string, hasKey bool, forma
|
||||
}
|
||||
|
||||
// bindTenant binds and validates parameter Tenant from path.
|
||||
func (o *TenantAddZoneParams) bindTenant(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
func (o *TenantAddPoolParams) bindTenant(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
@@ -30,35 +30,35 @@ import (
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// TenantAddZoneCreatedCode is the HTTP code returned for type TenantAddZoneCreated
|
||||
const TenantAddZoneCreatedCode int = 201
|
||||
// TenantAddPoolCreatedCode is the HTTP code returned for type TenantAddPoolCreated
|
||||
const TenantAddPoolCreatedCode int = 201
|
||||
|
||||
/*TenantAddZoneCreated A successful response.
|
||||
/*TenantAddPoolCreated A successful response.
|
||||
|
||||
swagger:response tenantAddZoneCreated
|
||||
swagger:response tenantAddPoolCreated
|
||||
*/
|
||||
type TenantAddZoneCreated struct {
|
||||
type TenantAddPoolCreated struct {
|
||||
}
|
||||
|
||||
// NewTenantAddZoneCreated creates TenantAddZoneCreated with default headers values
|
||||
func NewTenantAddZoneCreated() *TenantAddZoneCreated {
|
||||
// NewTenantAddPoolCreated creates TenantAddPoolCreated with default headers values
|
||||
func NewTenantAddPoolCreated() *TenantAddPoolCreated {
|
||||
|
||||
return &TenantAddZoneCreated{}
|
||||
return &TenantAddPoolCreated{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *TenantAddZoneCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
func (o *TenantAddPoolCreated) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(201)
|
||||
}
|
||||
|
||||
/*TenantAddZoneDefault Generic error response.
|
||||
/*TenantAddPoolDefault Generic error response.
|
||||
|
||||
swagger:response tenantAddZoneDefault
|
||||
swagger:response tenantAddPoolDefault
|
||||
*/
|
||||
type TenantAddZoneDefault struct {
|
||||
type TenantAddPoolDefault struct {
|
||||
_statusCode int
|
||||
|
||||
/*
|
||||
@@ -67,41 +67,41 @@ type TenantAddZoneDefault struct {
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewTenantAddZoneDefault creates TenantAddZoneDefault with default headers values
|
||||
func NewTenantAddZoneDefault(code int) *TenantAddZoneDefault {
|
||||
// NewTenantAddPoolDefault creates TenantAddPoolDefault with default headers values
|
||||
func NewTenantAddPoolDefault(code int) *TenantAddPoolDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &TenantAddZoneDefault{
|
||||
return &TenantAddPoolDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the tenant add zone default response
|
||||
func (o *TenantAddZoneDefault) WithStatusCode(code int) *TenantAddZoneDefault {
|
||||
// WithStatusCode adds the status to the tenant add pool default response
|
||||
func (o *TenantAddPoolDefault) WithStatusCode(code int) *TenantAddPoolDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the tenant add zone default response
|
||||
func (o *TenantAddZoneDefault) SetStatusCode(code int) {
|
||||
// SetStatusCode sets the status to the tenant add pool default response
|
||||
func (o *TenantAddPoolDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the tenant add zone default response
|
||||
func (o *TenantAddZoneDefault) WithPayload(payload *models.Error) *TenantAddZoneDefault {
|
||||
// WithPayload adds the payload to the tenant add pool default response
|
||||
func (o *TenantAddPoolDefault) WithPayload(payload *models.Error) *TenantAddPoolDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the tenant add zone default response
|
||||
func (o *TenantAddZoneDefault) SetPayload(payload *models.Error) {
|
||||
// SetPayload sets the payload to the tenant add pool default response
|
||||
func (o *TenantAddPoolDefault) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *TenantAddZoneDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
func (o *TenantAddPoolDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(o._statusCode)
|
||||
if o.Payload != nil {
|
||||
@@ -29,8 +29,8 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// TenantAddZoneURL generates an URL for the tenant add zone operation
|
||||
type TenantAddZoneURL struct {
|
||||
// TenantAddPoolURL generates an URL for the tenant add pool operation
|
||||
type TenantAddPoolURL struct {
|
||||
Namespace string
|
||||
Tenant string
|
||||
|
||||
@@ -42,7 +42,7 @@ type TenantAddZoneURL struct {
|
||||
// WithBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *TenantAddZoneURL) WithBasePath(bp string) *TenantAddZoneURL {
|
||||
func (o *TenantAddPoolURL) WithBasePath(bp string) *TenantAddPoolURL {
|
||||
o.SetBasePath(bp)
|
||||
return o
|
||||
}
|
||||
@@ -50,28 +50,28 @@ func (o *TenantAddZoneURL) WithBasePath(bp string) *TenantAddZoneURL {
|
||||
// SetBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *TenantAddZoneURL) SetBasePath(bp string) {
|
||||
func (o *TenantAddPoolURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *TenantAddZoneURL) Build() (*url.URL, error) {
|
||||
func (o *TenantAddPoolURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/namespaces/{namespace}/tenants/{tenant}/zones"
|
||||
var _path = "/namespaces/{namespace}/tenants/{tenant}/pools"
|
||||
|
||||
namespace := o.Namespace
|
||||
if namespace != "" {
|
||||
_path = strings.Replace(_path, "{namespace}", namespace, -1)
|
||||
} else {
|
||||
return nil, errors.New("namespace is required on TenantAddZoneURL")
|
||||
return nil, errors.New("namespace is required on TenantAddPoolURL")
|
||||
}
|
||||
|
||||
tenant := o.Tenant
|
||||
if tenant != "" {
|
||||
_path = strings.Replace(_path, "{tenant}", tenant, -1)
|
||||
} else {
|
||||
return nil, errors.New("tenant is required on TenantAddZoneURL")
|
||||
return nil, errors.New("tenant is required on TenantAddPoolURL")
|
||||
}
|
||||
|
||||
_basePath := o._basePath
|
||||
@@ -84,7 +84,7 @@ func (o *TenantAddZoneURL) Build() (*url.URL, error) {
|
||||
}
|
||||
|
||||
// Must is a helper function to panic when the url builder returns an error
|
||||
func (o *TenantAddZoneURL) Must(u *url.URL, err error) *url.URL {
|
||||
func (o *TenantAddPoolURL) Must(u *url.URL, err error) *url.URL {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -95,17 +95,17 @@ func (o *TenantAddZoneURL) Must(u *url.URL, err error) *url.URL {
|
||||
}
|
||||
|
||||
// String returns the string representation of the path with query string
|
||||
func (o *TenantAddZoneURL) String() string {
|
||||
func (o *TenantAddPoolURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *TenantAddZoneURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
func (o *TenantAddPoolURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on TenantAddZoneURL")
|
||||
return nil, errors.New("scheme is required for a full url on TenantAddPoolURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on TenantAddZoneURL")
|
||||
return nil, errors.New("host is required for a full url on TenantAddPoolURL")
|
||||
}
|
||||
|
||||
base, err := o.Build()
|
||||
@@ -119,6 +119,6 @@ func (o *TenantAddZoneURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
}
|
||||
|
||||
// StringFull returns the string representation of a complete url
|
||||
func (o *TenantAddZoneURL) StringFull(scheme, host string) string {
|
||||
func (o *TenantAddPoolURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
||||
@@ -30,40 +30,40 @@ import (
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// TenantUpdateZonesHandlerFunc turns a function with the right signature into a tenant update zones handler
|
||||
type TenantUpdateZonesHandlerFunc func(TenantUpdateZonesParams, *models.Principal) middleware.Responder
|
||||
// TenantUpdatePoolsHandlerFunc turns a function with the right signature into a tenant update pools handler
|
||||
type TenantUpdatePoolsHandlerFunc func(TenantUpdatePoolsParams, *models.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn TenantUpdateZonesHandlerFunc) Handle(params TenantUpdateZonesParams, principal *models.Principal) middleware.Responder {
|
||||
func (fn TenantUpdatePoolsHandlerFunc) Handle(params TenantUpdatePoolsParams, principal *models.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// TenantUpdateZonesHandler interface for that can handle valid tenant update zones params
|
||||
type TenantUpdateZonesHandler interface {
|
||||
Handle(TenantUpdateZonesParams, *models.Principal) middleware.Responder
|
||||
// TenantUpdatePoolsHandler interface for that can handle valid tenant update pools params
|
||||
type TenantUpdatePoolsHandler interface {
|
||||
Handle(TenantUpdatePoolsParams, *models.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewTenantUpdateZones creates a new http.Handler for the tenant update zones operation
|
||||
func NewTenantUpdateZones(ctx *middleware.Context, handler TenantUpdateZonesHandler) *TenantUpdateZones {
|
||||
return &TenantUpdateZones{Context: ctx, Handler: handler}
|
||||
// NewTenantUpdatePools creates a new http.Handler for the tenant update pools operation
|
||||
func NewTenantUpdatePools(ctx *middleware.Context, handler TenantUpdatePoolsHandler) *TenantUpdatePools {
|
||||
return &TenantUpdatePools{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*TenantUpdateZones swagger:route PUT /namespaces/{namespace}/tenants/{tenant}/zones AdminAPI tenantUpdateZones
|
||||
/*TenantUpdatePools swagger:route PUT /namespaces/{namespace}/tenants/{tenant}/pools AdminAPI tenantUpdatePools
|
||||
|
||||
Tenant Update Zones
|
||||
Tenant Update Pools
|
||||
|
||||
*/
|
||||
type TenantUpdateZones struct {
|
||||
type TenantUpdatePools struct {
|
||||
Context *middleware.Context
|
||||
Handler TenantUpdateZonesHandler
|
||||
Handler TenantUpdatePoolsHandler
|
||||
}
|
||||
|
||||
func (o *TenantUpdateZones) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
func (o *TenantUpdatePools) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
r = rCtx
|
||||
}
|
||||
var Params = NewTenantUpdateZonesParams()
|
||||
var Params = NewTenantUpdatePoolsParams()
|
||||
|
||||
uprinc, aCtx, err := o.Context.Authorize(r, route)
|
||||
if err != nil {
|
||||
@@ -34,18 +34,18 @@ import (
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// NewTenantUpdateZonesParams creates a new TenantUpdateZonesParams object
|
||||
// NewTenantUpdatePoolsParams creates a new TenantUpdatePoolsParams object
|
||||
// no default values defined in spec.
|
||||
func NewTenantUpdateZonesParams() TenantUpdateZonesParams {
|
||||
func NewTenantUpdatePoolsParams() TenantUpdatePoolsParams {
|
||||
|
||||
return TenantUpdateZonesParams{}
|
||||
return TenantUpdatePoolsParams{}
|
||||
}
|
||||
|
||||
// TenantUpdateZonesParams contains all the bound params for the tenant update zones operation
|
||||
// TenantUpdatePoolsParams contains all the bound params for the tenant update pools operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters TenantUpdateZones
|
||||
type TenantUpdateZonesParams struct {
|
||||
// swagger:parameters TenantUpdatePools
|
||||
type TenantUpdatePoolsParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
@@ -54,7 +54,7 @@ type TenantUpdateZonesParams struct {
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Body *models.ZoneUpdateRequest
|
||||
Body *models.PoolUpdateRequest
|
||||
/*
|
||||
Required: true
|
||||
In: path
|
||||
@@ -70,15 +70,15 @@ type TenantUpdateZonesParams struct {
|
||||
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
|
||||
// for simple values it will use straight method calls.
|
||||
//
|
||||
// To ensure default values, the struct must have been initialized with NewTenantUpdateZonesParams() beforehand.
|
||||
func (o *TenantUpdateZonesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
// To ensure default values, the struct must have been initialized with NewTenantUpdatePoolsParams() beforehand.
|
||||
func (o *TenantUpdatePoolsParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
if runtime.HasBody(r) {
|
||||
defer r.Body.Close()
|
||||
var body models.ZoneUpdateRequest
|
||||
var body models.PoolUpdateRequest
|
||||
if err := route.Consumer.Consume(r.Body, &body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("body", "body", ""))
|
||||
@@ -115,7 +115,7 @@ func (o *TenantUpdateZonesParams) BindRequest(r *http.Request, route *middleware
|
||||
}
|
||||
|
||||
// bindNamespace binds and validates parameter Namespace from path.
|
||||
func (o *TenantUpdateZonesParams) bindNamespace(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
func (o *TenantUpdatePoolsParams) bindNamespace(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
@@ -130,7 +130,7 @@ func (o *TenantUpdateZonesParams) bindNamespace(rawData []string, hasKey bool, f
|
||||
}
|
||||
|
||||
// bindTenant binds and validates parameter Tenant from path.
|
||||
func (o *TenantUpdateZonesParams) bindTenant(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
func (o *TenantUpdatePoolsParams) bindTenant(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
@@ -30,14 +30,14 @@ import (
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// TenantUpdateZonesOKCode is the HTTP code returned for type TenantUpdateZonesOK
|
||||
const TenantUpdateZonesOKCode int = 200
|
||||
// TenantUpdatePoolsOKCode is the HTTP code returned for type TenantUpdatePoolsOK
|
||||
const TenantUpdatePoolsOKCode int = 200
|
||||
|
||||
/*TenantUpdateZonesOK A successful response.
|
||||
/*TenantUpdatePoolsOK A successful response.
|
||||
|
||||
swagger:response tenantUpdateZonesOK
|
||||
swagger:response tenantUpdatePoolsOK
|
||||
*/
|
||||
type TenantUpdateZonesOK struct {
|
||||
type TenantUpdatePoolsOK struct {
|
||||
|
||||
/*
|
||||
In: Body
|
||||
@@ -45,25 +45,25 @@ type TenantUpdateZonesOK struct {
|
||||
Payload *models.Tenant `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewTenantUpdateZonesOK creates TenantUpdateZonesOK with default headers values
|
||||
func NewTenantUpdateZonesOK() *TenantUpdateZonesOK {
|
||||
// NewTenantUpdatePoolsOK creates TenantUpdatePoolsOK with default headers values
|
||||
func NewTenantUpdatePoolsOK() *TenantUpdatePoolsOK {
|
||||
|
||||
return &TenantUpdateZonesOK{}
|
||||
return &TenantUpdatePoolsOK{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the tenant update zones o k response
|
||||
func (o *TenantUpdateZonesOK) WithPayload(payload *models.Tenant) *TenantUpdateZonesOK {
|
||||
// WithPayload adds the payload to the tenant update pools o k response
|
||||
func (o *TenantUpdatePoolsOK) WithPayload(payload *models.Tenant) *TenantUpdatePoolsOK {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the tenant update zones o k response
|
||||
func (o *TenantUpdateZonesOK) SetPayload(payload *models.Tenant) {
|
||||
// SetPayload sets the payload to the tenant update pools o k response
|
||||
func (o *TenantUpdatePoolsOK) SetPayload(payload *models.Tenant) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *TenantUpdateZonesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
func (o *TenantUpdatePoolsOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(200)
|
||||
if o.Payload != nil {
|
||||
@@ -74,11 +74,11 @@ func (o *TenantUpdateZonesOK) WriteResponse(rw http.ResponseWriter, producer run
|
||||
}
|
||||
}
|
||||
|
||||
/*TenantUpdateZonesDefault Generic error response.
|
||||
/*TenantUpdatePoolsDefault Generic error response.
|
||||
|
||||
swagger:response tenantUpdateZonesDefault
|
||||
swagger:response tenantUpdatePoolsDefault
|
||||
*/
|
||||
type TenantUpdateZonesDefault struct {
|
||||
type TenantUpdatePoolsDefault struct {
|
||||
_statusCode int
|
||||
|
||||
/*
|
||||
@@ -87,41 +87,41 @@ type TenantUpdateZonesDefault struct {
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewTenantUpdateZonesDefault creates TenantUpdateZonesDefault with default headers values
|
||||
func NewTenantUpdateZonesDefault(code int) *TenantUpdateZonesDefault {
|
||||
// NewTenantUpdatePoolsDefault creates TenantUpdatePoolsDefault with default headers values
|
||||
func NewTenantUpdatePoolsDefault(code int) *TenantUpdatePoolsDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &TenantUpdateZonesDefault{
|
||||
return &TenantUpdatePoolsDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the tenant update zones default response
|
||||
func (o *TenantUpdateZonesDefault) WithStatusCode(code int) *TenantUpdateZonesDefault {
|
||||
// WithStatusCode adds the status to the tenant update pools default response
|
||||
func (o *TenantUpdatePoolsDefault) WithStatusCode(code int) *TenantUpdatePoolsDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the tenant update zones default response
|
||||
func (o *TenantUpdateZonesDefault) SetStatusCode(code int) {
|
||||
// SetStatusCode sets the status to the tenant update pools default response
|
||||
func (o *TenantUpdatePoolsDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the tenant update zones default response
|
||||
func (o *TenantUpdateZonesDefault) WithPayload(payload *models.Error) *TenantUpdateZonesDefault {
|
||||
// WithPayload adds the payload to the tenant update pools default response
|
||||
func (o *TenantUpdatePoolsDefault) WithPayload(payload *models.Error) *TenantUpdatePoolsDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the tenant update zones default response
|
||||
func (o *TenantUpdateZonesDefault) SetPayload(payload *models.Error) {
|
||||
// SetPayload sets the payload to the tenant update pools default response
|
||||
func (o *TenantUpdatePoolsDefault) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *TenantUpdateZonesDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
func (o *TenantUpdatePoolsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(o._statusCode)
|
||||
if o.Payload != nil {
|
||||
@@ -29,8 +29,8 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// TenantUpdateZonesURL generates an URL for the tenant update zones operation
|
||||
type TenantUpdateZonesURL struct {
|
||||
// TenantUpdatePoolsURL generates an URL for the tenant update pools operation
|
||||
type TenantUpdatePoolsURL struct {
|
||||
Namespace string
|
||||
Tenant string
|
||||
|
||||
@@ -42,7 +42,7 @@ type TenantUpdateZonesURL struct {
|
||||
// WithBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *TenantUpdateZonesURL) WithBasePath(bp string) *TenantUpdateZonesURL {
|
||||
func (o *TenantUpdatePoolsURL) WithBasePath(bp string) *TenantUpdatePoolsURL {
|
||||
o.SetBasePath(bp)
|
||||
return o
|
||||
}
|
||||
@@ -50,28 +50,28 @@ func (o *TenantUpdateZonesURL) WithBasePath(bp string) *TenantUpdateZonesURL {
|
||||
// SetBasePath sets the base path for this url builder, only required when it's different from the
|
||||
// base path specified in the swagger spec.
|
||||
// When the value of the base path is an empty string
|
||||
func (o *TenantUpdateZonesURL) SetBasePath(bp string) {
|
||||
func (o *TenantUpdatePoolsURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *TenantUpdateZonesURL) Build() (*url.URL, error) {
|
||||
func (o *TenantUpdatePoolsURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/namespaces/{namespace}/tenants/{tenant}/zones"
|
||||
var _path = "/namespaces/{namespace}/tenants/{tenant}/pools"
|
||||
|
||||
namespace := o.Namespace
|
||||
if namespace != "" {
|
||||
_path = strings.Replace(_path, "{namespace}", namespace, -1)
|
||||
} else {
|
||||
return nil, errors.New("namespace is required on TenantUpdateZonesURL")
|
||||
return nil, errors.New("namespace is required on TenantUpdatePoolsURL")
|
||||
}
|
||||
|
||||
tenant := o.Tenant
|
||||
if tenant != "" {
|
||||
_path = strings.Replace(_path, "{tenant}", tenant, -1)
|
||||
} else {
|
||||
return nil, errors.New("tenant is required on TenantUpdateZonesURL")
|
||||
return nil, errors.New("tenant is required on TenantUpdatePoolsURL")
|
||||
}
|
||||
|
||||
_basePath := o._basePath
|
||||
@@ -84,7 +84,7 @@ func (o *TenantUpdateZonesURL) Build() (*url.URL, error) {
|
||||
}
|
||||
|
||||
// Must is a helper function to panic when the url builder returns an error
|
||||
func (o *TenantUpdateZonesURL) Must(u *url.URL, err error) *url.URL {
|
||||
func (o *TenantUpdatePoolsURL) Must(u *url.URL, err error) *url.URL {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -95,17 +95,17 @@ func (o *TenantUpdateZonesURL) Must(u *url.URL, err error) *url.URL {
|
||||
}
|
||||
|
||||
// String returns the string representation of the path with query string
|
||||
func (o *TenantUpdateZonesURL) String() string {
|
||||
func (o *TenantUpdatePoolsURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *TenantUpdateZonesURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
func (o *TenantUpdatePoolsURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on TenantUpdateZonesURL")
|
||||
return nil, errors.New("scheme is required for a full url on TenantUpdatePoolsURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on TenantUpdateZonesURL")
|
||||
return nil, errors.New("host is required for a full url on TenantUpdatePoolsURL")
|
||||
}
|
||||
|
||||
base, err := o.Build()
|
||||
@@ -119,6 +119,6 @@ func (o *TenantUpdateZonesURL) BuildFull(scheme, host string) (*url.URL, error)
|
||||
}
|
||||
|
||||
// StringFull returns the string representation of a complete url
|
||||
func (o *TenantUpdateZonesURL) StringFull(scheme, host string) string {
|
||||
func (o *TenantUpdatePoolsURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
||||
@@ -287,8 +287,8 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI {
|
||||
UserAPIShareObjectHandler: user_api.ShareObjectHandlerFunc(func(params user_api.ShareObjectParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation user_api.ShareObject has not yet been implemented")
|
||||
}),
|
||||
AdminAPITenantAddZoneHandler: admin_api.TenantAddZoneHandlerFunc(func(params admin_api.TenantAddZoneParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation admin_api.TenantAddZone has not yet been implemented")
|
||||
AdminAPITenantAddPoolHandler: admin_api.TenantAddPoolHandlerFunc(func(params admin_api.TenantAddPoolParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation admin_api.TenantAddPool has not yet been implemented")
|
||||
}),
|
||||
AdminAPITenantInfoHandler: admin_api.TenantInfoHandlerFunc(func(params admin_api.TenantInfoParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation admin_api.TenantInfo has not yet been implemented")
|
||||
@@ -299,8 +299,8 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI {
|
||||
AdminAPITenantUpdateEncryptionHandler: admin_api.TenantUpdateEncryptionHandlerFunc(func(params admin_api.TenantUpdateEncryptionParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation admin_api.TenantUpdateEncryption has not yet been implemented")
|
||||
}),
|
||||
AdminAPITenantUpdateZonesHandler: admin_api.TenantUpdateZonesHandlerFunc(func(params admin_api.TenantUpdateZonesParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation admin_api.TenantUpdateZones has not yet been implemented")
|
||||
AdminAPITenantUpdatePoolsHandler: admin_api.TenantUpdatePoolsHandlerFunc(func(params admin_api.TenantUpdatePoolsParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation admin_api.TenantUpdatePools has not yet been implemented")
|
||||
}),
|
||||
AdminAPIUpdateGroupHandler: admin_api.UpdateGroupHandlerFunc(func(params admin_api.UpdateGroupParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation admin_api.UpdateGroup has not yet been implemented")
|
||||
@@ -514,16 +514,16 @@ type ConsoleAPI struct {
|
||||
AdminAPISetPolicyMultipleHandler admin_api.SetPolicyMultipleHandler
|
||||
// UserAPIShareObjectHandler sets the operation handler for the share object operation
|
||||
UserAPIShareObjectHandler user_api.ShareObjectHandler
|
||||
// AdminAPITenantAddZoneHandler sets the operation handler for the tenant add zone operation
|
||||
AdminAPITenantAddZoneHandler admin_api.TenantAddZoneHandler
|
||||
// AdminAPITenantAddPoolHandler sets the operation handler for the tenant add pool operation
|
||||
AdminAPITenantAddPoolHandler admin_api.TenantAddPoolHandler
|
||||
// AdminAPITenantInfoHandler sets the operation handler for the tenant info operation
|
||||
AdminAPITenantInfoHandler admin_api.TenantInfoHandler
|
||||
// AdminAPITenantUpdateCertificateHandler sets the operation handler for the tenant update certificate operation
|
||||
AdminAPITenantUpdateCertificateHandler admin_api.TenantUpdateCertificateHandler
|
||||
// AdminAPITenantUpdateEncryptionHandler sets the operation handler for the tenant update encryption operation
|
||||
AdminAPITenantUpdateEncryptionHandler admin_api.TenantUpdateEncryptionHandler
|
||||
// AdminAPITenantUpdateZonesHandler sets the operation handler for the tenant update zones operation
|
||||
AdminAPITenantUpdateZonesHandler admin_api.TenantUpdateZonesHandler
|
||||
// AdminAPITenantUpdatePoolsHandler sets the operation handler for the tenant update pools operation
|
||||
AdminAPITenantUpdatePoolsHandler admin_api.TenantUpdatePoolsHandler
|
||||
// AdminAPIUpdateGroupHandler sets the operation handler for the update group operation
|
||||
AdminAPIUpdateGroupHandler admin_api.UpdateGroupHandler
|
||||
// AdminAPIUpdateTenantHandler sets the operation handler for the update tenant operation
|
||||
@@ -830,8 +830,8 @@ func (o *ConsoleAPI) Validate() error {
|
||||
if o.UserAPIShareObjectHandler == nil {
|
||||
unregistered = append(unregistered, "user_api.ShareObjectHandler")
|
||||
}
|
||||
if o.AdminAPITenantAddZoneHandler == nil {
|
||||
unregistered = append(unregistered, "admin_api.TenantAddZoneHandler")
|
||||
if o.AdminAPITenantAddPoolHandler == nil {
|
||||
unregistered = append(unregistered, "admin_api.TenantAddPoolHandler")
|
||||
}
|
||||
if o.AdminAPITenantInfoHandler == nil {
|
||||
unregistered = append(unregistered, "admin_api.TenantInfoHandler")
|
||||
@@ -842,8 +842,8 @@ func (o *ConsoleAPI) Validate() error {
|
||||
if o.AdminAPITenantUpdateEncryptionHandler == nil {
|
||||
unregistered = append(unregistered, "admin_api.TenantUpdateEncryptionHandler")
|
||||
}
|
||||
if o.AdminAPITenantUpdateZonesHandler == nil {
|
||||
unregistered = append(unregistered, "admin_api.TenantUpdateZonesHandler")
|
||||
if o.AdminAPITenantUpdatePoolsHandler == nil {
|
||||
unregistered = append(unregistered, "admin_api.TenantUpdatePoolsHandler")
|
||||
}
|
||||
if o.AdminAPIUpdateGroupHandler == nil {
|
||||
unregistered = append(unregistered, "admin_api.UpdateGroupHandler")
|
||||
@@ -1258,7 +1258,7 @@ func (o *ConsoleAPI) initHandlerCache() {
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["POST"]["/namespaces/{namespace}/tenants/{tenant}/zones"] = admin_api.NewTenantAddZone(o.context, o.AdminAPITenantAddZoneHandler)
|
||||
o.handlers["POST"]["/namespaces/{namespace}/tenants/{tenant}/pools"] = admin_api.NewTenantAddPool(o.context, o.AdminAPITenantAddPoolHandler)
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
@@ -1274,7 +1274,7 @@ func (o *ConsoleAPI) initHandlerCache() {
|
||||
if o.handlers["PUT"] == nil {
|
||||
o.handlers["PUT"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["PUT"]["/namespaces/{namespace}/tenants/{tenant}/zones"] = admin_api.NewTenantUpdateZones(o.context, o.AdminAPITenantUpdateZonesHandler)
|
||||
o.handlers["PUT"]["/namespaces/{namespace}/tenants/{tenant}/pools"] = admin_api.NewTenantUpdatePools(o.context, o.AdminAPITenantUpdatePoolsHandler)
|
||||
if o.handlers["PUT"] == nil {
|
||||
o.handlers["PUT"] = make(map[string]http.Handler)
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ func (s *Server) Serve() (err error) {
|
||||
caCertPool := x509.NewCertPool()
|
||||
ok := caCertPool.AppendCertsFromPEM(caCert)
|
||||
if !ok {
|
||||
return fmt.Errorf("unable to parse CA certificate %s", s.TLSCACertificate)
|
||||
return fmt.Errorf("cannot parse CA certificate")
|
||||
}
|
||||
httpsServer.TLSConfig.ClientCAs = caCertPool
|
||||
httpsServer.TLSConfig.ClientAuth = tls.RequireAndVerifyClientCert
|
||||
|
||||
Reference in New Issue
Block a user