Added domains item in create tenant & get tenant requests (#1841)
This commit is contained in:
@@ -43,6 +43,9 @@ type CreateTenantRequest struct {
|
||||
// annotations
|
||||
Annotations map[string]string `json:"annotations,omitempty"`
|
||||
|
||||
// domains
|
||||
Domains *DomainsConfiguration `json:"domains,omitempty"`
|
||||
|
||||
// enable console
|
||||
EnableConsole *bool `json:"enable_console,omitempty"`
|
||||
|
||||
@@ -112,6 +115,10 @@ type CreateTenantRequest struct {
|
||||
func (m *CreateTenantRequest) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateDomains(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateEncryption(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
@@ -154,6 +161,25 @@ func (m *CreateTenantRequest) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *CreateTenantRequest) validateDomains(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.Domains) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if m.Domains != nil {
|
||||
if err := m.Domains.Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("domains")
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("domains")
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *CreateTenantRequest) validateEncryption(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.Encryption) { // not required
|
||||
return nil
|
||||
@@ -321,6 +347,10 @@ func (m *CreateTenantRequest) validateTLS(formats strfmt.Registry) error {
|
||||
func (m *CreateTenantRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.contextValidateDomains(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.contextValidateEncryption(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
@@ -355,6 +385,22 @@ func (m *CreateTenantRequest) ContextValidate(ctx context.Context, formats strfm
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *CreateTenantRequest) contextValidateDomains(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
if m.Domains != nil {
|
||||
if err := m.Domains.ContextValidate(ctx, formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("domains")
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("domains")
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *CreateTenantRequest) contextValidateEncryption(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
if m.Encryption != nil {
|
||||
|
||||
70
models/domains_configuration.go
Normal file
70
models/domains_configuration.go
Normal file
@@ -0,0 +1,70 @@
|
||||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
// This file is part of MinIO Console Server
|
||||
// Copyright (c) 2022 MinIO, Inc.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
|
||||
package models
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// DomainsConfiguration domains configuration
|
||||
//
|
||||
// swagger:model domainsConfiguration
|
||||
type DomainsConfiguration struct {
|
||||
|
||||
// console
|
||||
Console string `json:"console,omitempty"`
|
||||
|
||||
// minio
|
||||
Minio []string `json:"minio"`
|
||||
}
|
||||
|
||||
// Validate validates this domains configuration
|
||||
func (m *DomainsConfiguration) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ContextValidate validates this domains configuration based on context it is used
|
||||
func (m *DomainsConfiguration) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *DomainsConfiguration) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *DomainsConfiguration) UnmarshalBinary(b []byte) error {
|
||||
var res DomainsConfiguration
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
@@ -45,6 +45,9 @@ type Tenant struct {
|
||||
// deletion date
|
||||
DeletionDate string `json:"deletion_date,omitempty"`
|
||||
|
||||
// domains
|
||||
Domains *DomainsConfiguration `json:"domains,omitempty"`
|
||||
|
||||
// enable prometheus
|
||||
EnablePrometheus bool `json:"enable_prometheus,omitempty"`
|
||||
|
||||
@@ -95,6 +98,10 @@ type Tenant struct {
|
||||
func (m *Tenant) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateDomains(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateEndpoints(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
@@ -117,6 +124,25 @@ func (m *Tenant) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Tenant) validateDomains(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.Domains) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if m.Domains != nil {
|
||||
if err := m.Domains.Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("domains")
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("domains")
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Tenant) validateEndpoints(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.Endpoints) { // not required
|
||||
return nil
|
||||
@@ -204,6 +230,10 @@ func (m *Tenant) validateSubnetLicense(formats strfmt.Registry) error {
|
||||
func (m *Tenant) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.contextValidateDomains(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.contextValidateEndpoints(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
@@ -226,6 +256,22 @@ func (m *Tenant) ContextValidate(ctx context.Context, formats strfmt.Registry) e
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Tenant) contextValidateDomains(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
if m.Domains != nil {
|
||||
if err := m.Domains.ContextValidate(ctx, formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("domains")
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("domains")
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Tenant) contextValidateEndpoints(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
if m.Endpoints != nil {
|
||||
|
||||
@@ -57,6 +57,9 @@ type TenantList struct {
|
||||
// deletion date
|
||||
DeletionDate string `json:"deletion_date,omitempty"`
|
||||
|
||||
// domains
|
||||
Domains *DomainsConfiguration `json:"domains,omitempty"`
|
||||
|
||||
// health status
|
||||
HealthStatus string `json:"health_status,omitempty"`
|
||||
|
||||
@@ -86,6 +89,10 @@ type TenantList struct {
|
||||
func (m *TenantList) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateDomains(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.validateTiers(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
@@ -96,6 +103,25 @@ func (m *TenantList) Validate(formats strfmt.Registry) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *TenantList) validateDomains(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.Domains) { // not required
|
||||
return nil
|
||||
}
|
||||
|
||||
if m.Domains != nil {
|
||||
if err := m.Domains.Validate(formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("domains")
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("domains")
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *TenantList) validateTiers(formats strfmt.Registry) error {
|
||||
if swag.IsZero(m.Tiers) { // not required
|
||||
return nil
|
||||
@@ -126,6 +152,10 @@ func (m *TenantList) validateTiers(formats strfmt.Registry) error {
|
||||
func (m *TenantList) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.contextValidateDomains(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if err := m.contextValidateTiers(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
@@ -136,6 +166,22 @@ func (m *TenantList) ContextValidate(ctx context.Context, formats strfmt.Registr
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *TenantList) contextValidateDomains(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
if m.Domains != nil {
|
||||
if err := m.Domains.ContextValidate(ctx, formats); err != nil {
|
||||
if ve, ok := err.(*errors.Validation); ok {
|
||||
return ve.ValidateName("domains")
|
||||
} else if ce, ok := err.(*errors.CompositeError); ok {
|
||||
return ce.ValidateName("domains")
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *TenantList) contextValidateTiers(ctx context.Context, formats strfmt.Registry) error {
|
||||
|
||||
for i := 0; i < len(m.Tiers); i++ {
|
||||
|
||||
@@ -2000,6 +2000,10 @@ func init() {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"domains": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/domainsConfiguration"
|
||||
},
|
||||
"enable_console": {
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
@@ -2158,6 +2162,20 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"domainsConfiguration": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"console": {
|
||||
"type": "string"
|
||||
},
|
||||
"minio": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"encryptionConfiguration": {
|
||||
"allOf": [
|
||||
{
|
||||
@@ -3430,6 +3448,9 @@ func init() {
|
||||
"deletion_date": {
|
||||
"type": "string"
|
||||
},
|
||||
"domains": {
|
||||
"$ref": "#/definitions/domainsConfiguration"
|
||||
},
|
||||
"enable_prometheus": {
|
||||
"type": "boolean"
|
||||
},
|
||||
@@ -3517,6 +3538,10 @@ func init() {
|
||||
"deletion_date": {
|
||||
"type": "string"
|
||||
},
|
||||
"domains": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/domainsConfiguration"
|
||||
},
|
||||
"health_status": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -6837,6 +6862,10 @@ func init() {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"domains": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/domainsConfiguration"
|
||||
},
|
||||
"enable_console": {
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
@@ -6995,6 +7024,20 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"domainsConfiguration": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"console": {
|
||||
"type": "string"
|
||||
},
|
||||
"minio": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"encryptionConfiguration": {
|
||||
"allOf": [
|
||||
{
|
||||
@@ -8120,6 +8163,9 @@ func init() {
|
||||
"deletion_date": {
|
||||
"type": "string"
|
||||
},
|
||||
"domains": {
|
||||
"$ref": "#/definitions/domainsConfiguration"
|
||||
},
|
||||
"enable_prometheus": {
|
||||
"type": "boolean"
|
||||
},
|
||||
@@ -8207,6 +8253,10 @@ func init() {
|
||||
"deletion_date": {
|
||||
"type": "string"
|
||||
},
|
||||
"domains": {
|
||||
"type": "object",
|
||||
"$ref": "#/definitions/domainsConfiguration"
|
||||
},
|
||||
"health_status": {
|
||||
"type": "string"
|
||||
},
|
||||
|
||||
@@ -430,6 +430,7 @@ func getTenantCreatedResponse(session *models.Principal, params operator_api.Cre
|
||||
if (diskSpaceFromAPI / humanize.GiByte) < int64(auditMaxCap) {
|
||||
auditMaxCap = int(diskSpaceFromAPI / humanize.GiByte)
|
||||
}
|
||||
|
||||
// default activate lgo search and prometheus
|
||||
minInst.Spec.Log = &miniov2.LogConfig{
|
||||
Audit: &miniov2.AuditConfig{DiskCapacityGB: swag.Int(auditMaxCap)},
|
||||
@@ -541,6 +542,24 @@ func getTenantCreatedResponse(session *models.Principal, params operator_api.Cre
|
||||
}
|
||||
minInst.Spec.Configuration = &corev1.LocalObjectReference{Name: tenantConfigurationName}
|
||||
|
||||
if tenantReq.Domains != nil {
|
||||
var features miniov2.Features
|
||||
var domains miniov2.TenantDomains
|
||||
|
||||
// tenant domains
|
||||
if tenantReq.Domains.Console != "" {
|
||||
domains.Console = tenantReq.Domains.Console
|
||||
}
|
||||
|
||||
if tenantReq.Domains.Minio != nil {
|
||||
domains.Minio = tenantReq.Domains.Minio
|
||||
}
|
||||
|
||||
features.Domains = &domains
|
||||
|
||||
minInst.Spec.Features = &features
|
||||
}
|
||||
|
||||
opClient, err := cluster.OperatorClient(session.STSSessionToken)
|
||||
if err != nil {
|
||||
return nil, prepareError(err)
|
||||
|
||||
@@ -150,5 +150,16 @@ func getTenantDetailsResponse(session *models.Principal, params operator_api.Ten
|
||||
}
|
||||
}
|
||||
|
||||
var domains models.DomainsConfiguration
|
||||
|
||||
if minTenant.Spec.Features != nil && minTenant.Spec.Features.Domains != nil {
|
||||
domains = models.DomainsConfiguration{
|
||||
Console: minTenant.Spec.Features.Domains.Console,
|
||||
Minio: minTenant.Spec.Features.Domains.Minio,
|
||||
}
|
||||
}
|
||||
|
||||
info.Domains = &domains
|
||||
|
||||
return info, nil
|
||||
}
|
||||
|
||||
@@ -1073,6 +1073,15 @@ func listTenants(ctx context.Context, operatorClient OperatorClientI, namespace
|
||||
tiers = append(tiers, tierItem)
|
||||
}
|
||||
|
||||
var domains models.DomainsConfiguration
|
||||
|
||||
if tenant.Spec.Features != nil && tenant.Spec.Features.Domains != nil {
|
||||
domains = models.DomainsConfiguration{
|
||||
Console: tenant.Spec.Features.Domains.Console,
|
||||
Minio: tenant.Spec.Features.Domains.Minio,
|
||||
}
|
||||
}
|
||||
|
||||
tenants = append(tenants, &models.TenantList{
|
||||
CreationDate: tenant.ObjectMeta.CreationTimestamp.Format(time.RFC3339),
|
||||
DeletionDate: deletion,
|
||||
@@ -1089,6 +1098,7 @@ func listTenants(ctx context.Context, operatorClient OperatorClientI, namespace
|
||||
Capacity: tenant.Status.Usage.Capacity,
|
||||
CapacityUsage: tenant.Status.Usage.Usage,
|
||||
Tiers: tiers,
|
||||
Domains: &domains,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1426,6 +1426,8 @@ definitions:
|
||||
$ref: "#/definitions/tenantStatus"
|
||||
minioTLS:
|
||||
type: boolean
|
||||
domains:
|
||||
$ref: "#/definitions/domainsConfiguration"
|
||||
|
||||
tenantUsage:
|
||||
type: object
|
||||
@@ -1476,6 +1478,9 @@ definitions:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/definitions/tenantTierElement"
|
||||
domains:
|
||||
type: object
|
||||
$ref: "#/definitions/domainsConfiguration"
|
||||
|
||||
listTenantsResponse:
|
||||
type: object
|
||||
@@ -1581,6 +1586,9 @@ definitions:
|
||||
type: boolean
|
||||
expose_console:
|
||||
type: boolean
|
||||
domains:
|
||||
type: object
|
||||
$ref: "#/definitions/domainsConfiguration"
|
||||
|
||||
metadataFields:
|
||||
type: object
|
||||
@@ -2925,3 +2933,12 @@ definitions:
|
||||
size:
|
||||
type: integer
|
||||
format: int64
|
||||
domainsConfiguration:
|
||||
type: object
|
||||
properties:
|
||||
minio:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
console:
|
||||
type: string
|
||||
|
||||
Reference in New Issue
Block a user