API for domains update (#1889)
* API for domains update Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
This commit is contained in:
2
.github/workflows/jobs.yaml
vendored
2
.github/workflows/jobs.yaml
vendored
@@ -1346,7 +1346,7 @@ jobs:
|
||||
result=${result%\%}
|
||||
echo "result:"
|
||||
echo $result
|
||||
threshold=36.3
|
||||
threshold=36.6
|
||||
if (( $(echo "$result >= $threshold" |bc -l) )); then
|
||||
echo "It is equal or greater than threshold, passed!"
|
||||
else
|
||||
|
||||
121
models/update_domains_request.go
Normal file
121
models/update_domains_request.go
Normal file
@@ -0,0 +1,121 @@
|
||||
// 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/errors"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// UpdateDomainsRequest update domains request
|
||||
//
|
||||
// swagger:model updateDomainsRequest
|
||||
type UpdateDomainsRequest struct {
|
||||
|
||||
// domains
|
||||
Domains *DomainsConfiguration `json:"domains,omitempty"`
|
||||
}
|
||||
|
||||
// Validate validates this update domains request
|
||||
func (m *UpdateDomainsRequest) Validate(formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.validateDomains(formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *UpdateDomainsRequest) 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
|
||||
}
|
||||
|
||||
// ContextValidate validate this update domains request based on the context it is used
|
||||
func (m *UpdateDomainsRequest) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
|
||||
var res []error
|
||||
|
||||
if err := m.contextValidateDomains(ctx, formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *UpdateDomainsRequest) 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
|
||||
}
|
||||
|
||||
// MarshalBinary interface implementation
|
||||
func (m *UpdateDomainsRequest) MarshalBinary() ([]byte, error) {
|
||||
if m == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return swag.WriteJSON(m)
|
||||
}
|
||||
|
||||
// UnmarshalBinary interface implementation
|
||||
func (m *UpdateDomainsRequest) UnmarshalBinary(b []byte) error {
|
||||
var res UpdateDomainsRequest
|
||||
if err := swag.ReadJSON(b, &res); err != nil {
|
||||
return err
|
||||
}
|
||||
*m = res
|
||||
return nil
|
||||
}
|
||||
@@ -620,6 +620,48 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/namespaces/{namespace}/tenants/{tenant}/domains": {
|
||||
"put": {
|
||||
"tags": [
|
||||
"OperatorAPI"
|
||||
],
|
||||
"summary": "Update Domains for a Tenant",
|
||||
"operationId": "UpdateTenantDomains",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"name": "namespace",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "tenant",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/updateDomainsRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "A successful response."
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/namespaces/{namespace}/tenants/{tenant}/enable-logging": {
|
||||
"post": {
|
||||
"tags": [
|
||||
@@ -3859,6 +3901,14 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"updateDomainsRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"domains": {
|
||||
"$ref": "#/definitions/domainsConfiguration"
|
||||
}
|
||||
}
|
||||
},
|
||||
"updateTenantRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -4640,6 +4690,48 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/namespaces/{namespace}/tenants/{tenant}/domains": {
|
||||
"put": {
|
||||
"tags": [
|
||||
"OperatorAPI"
|
||||
],
|
||||
"summary": "Update Domains for a Tenant",
|
||||
"operationId": "UpdateTenantDomains",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"name": "namespace",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "tenant",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/updateDomainsRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "A successful response."
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/namespaces/{namespace}/tenants/{tenant}/enable-logging": {
|
||||
"post": {
|
||||
"tags": [
|
||||
@@ -8575,6 +8667,14 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"updateDomainsRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"domains": {
|
||||
"$ref": "#/definitions/domainsConfiguration"
|
||||
}
|
||||
}
|
||||
},
|
||||
"updateTenantRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
@@ -207,6 +207,9 @@ func NewOperatorAPI(spec *loads.Document) *OperatorAPI {
|
||||
OperatorAPIUpdateTenantHandler: operator_api.UpdateTenantHandlerFunc(func(params operator_api.UpdateTenantParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation operator_api.UpdateTenant has not yet been implemented")
|
||||
}),
|
||||
OperatorAPIUpdateTenantDomainsHandler: operator_api.UpdateTenantDomainsHandlerFunc(func(params operator_api.UpdateTenantDomainsParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation operator_api.UpdateTenantDomains has not yet been implemented")
|
||||
}),
|
||||
OperatorAPIUpdateTenantIdentityProviderHandler: operator_api.UpdateTenantIdentityProviderHandlerFunc(func(params operator_api.UpdateTenantIdentityProviderParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation operator_api.UpdateTenantIdentityProvider has not yet been implemented")
|
||||
}),
|
||||
@@ -358,6 +361,8 @@ type OperatorAPI struct {
|
||||
OperatorAPITenantUpdatePoolsHandler operator_api.TenantUpdatePoolsHandler
|
||||
// OperatorAPIUpdateTenantHandler sets the operation handler for the update tenant operation
|
||||
OperatorAPIUpdateTenantHandler operator_api.UpdateTenantHandler
|
||||
// OperatorAPIUpdateTenantDomainsHandler sets the operation handler for the update tenant domains operation
|
||||
OperatorAPIUpdateTenantDomainsHandler operator_api.UpdateTenantDomainsHandler
|
||||
// OperatorAPIUpdateTenantIdentityProviderHandler sets the operation handler for the update tenant identity provider operation
|
||||
OperatorAPIUpdateTenantIdentityProviderHandler operator_api.UpdateTenantIdentityProviderHandler
|
||||
// OperatorAPIUpdateTenantSecurityHandler sets the operation handler for the update tenant security operation
|
||||
@@ -587,6 +592,9 @@ func (o *OperatorAPI) Validate() error {
|
||||
if o.OperatorAPIUpdateTenantHandler == nil {
|
||||
unregistered = append(unregistered, "operator_api.UpdateTenantHandler")
|
||||
}
|
||||
if o.OperatorAPIUpdateTenantDomainsHandler == nil {
|
||||
unregistered = append(unregistered, "operator_api.UpdateTenantDomainsHandler")
|
||||
}
|
||||
if o.OperatorAPIUpdateTenantIdentityProviderHandler == nil {
|
||||
unregistered = append(unregistered, "operator_api.UpdateTenantIdentityProviderHandler")
|
||||
}
|
||||
@@ -883,6 +891,10 @@ func (o *OperatorAPI) initHandlerCache() {
|
||||
o.handlers["PUT"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["PUT"]["/namespaces/{namespace}/tenants/{tenant}"] = operator_api.NewUpdateTenant(o.context, o.OperatorAPIUpdateTenantHandler)
|
||||
if o.handlers["PUT"] == nil {
|
||||
o.handlers["PUT"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["PUT"]["/namespaces/{namespace}/tenants/{tenant}/domains"] = operator_api.NewUpdateTenantDomains(o.context, o.OperatorAPIUpdateTenantDomainsHandler)
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
}
|
||||
|
||||
88
operatorapi/operations/operator_api/update_tenant_domains.go
Normal file
88
operatorapi/operations/operator_api/update_tenant_domains.go
Normal file
@@ -0,0 +1,88 @@
|
||||
// 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 operator_api
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// UpdateTenantDomainsHandlerFunc turns a function with the right signature into a update tenant domains handler
|
||||
type UpdateTenantDomainsHandlerFunc func(UpdateTenantDomainsParams, *models.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn UpdateTenantDomainsHandlerFunc) Handle(params UpdateTenantDomainsParams, principal *models.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// UpdateTenantDomainsHandler interface for that can handle valid update tenant domains params
|
||||
type UpdateTenantDomainsHandler interface {
|
||||
Handle(UpdateTenantDomainsParams, *models.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewUpdateTenantDomains creates a new http.Handler for the update tenant domains operation
|
||||
func NewUpdateTenantDomains(ctx *middleware.Context, handler UpdateTenantDomainsHandler) *UpdateTenantDomains {
|
||||
return &UpdateTenantDomains{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/* UpdateTenantDomains swagger:route PUT /namespaces/{namespace}/tenants/{tenant}/domains OperatorAPI updateTenantDomains
|
||||
|
||||
Update Domains for a Tenant
|
||||
|
||||
*/
|
||||
type UpdateTenantDomains struct {
|
||||
Context *middleware.Context
|
||||
Handler UpdateTenantDomainsHandler
|
||||
}
|
||||
|
||||
func (o *UpdateTenantDomains) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewUpdateTenantDomainsParams()
|
||||
uprinc, aCtx, err := o.Context.Authorize(r, route)
|
||||
if err != nil {
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
if aCtx != nil {
|
||||
*r = *aCtx
|
||||
}
|
||||
var principal *models.Principal
|
||||
if uprinc != nil {
|
||||
principal = uprinc.(*models.Principal) // this is really a models.Principal, I promise
|
||||
}
|
||||
|
||||
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
|
||||
o.Context.Respond(rw, r, route.Produces, route, err)
|
||||
return
|
||||
}
|
||||
|
||||
res := o.Handler.Handle(Params, principal) // actually handle the request
|
||||
o.Context.Respond(rw, r, route.Produces, route, res)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
// 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 operator_api
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/validate"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// NewUpdateTenantDomainsParams creates a new UpdateTenantDomainsParams object
|
||||
//
|
||||
// There are no default values defined in the spec.
|
||||
func NewUpdateTenantDomainsParams() UpdateTenantDomainsParams {
|
||||
|
||||
return UpdateTenantDomainsParams{}
|
||||
}
|
||||
|
||||
// UpdateTenantDomainsParams contains all the bound params for the update tenant domains operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters UpdateTenantDomains
|
||||
type UpdateTenantDomainsParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
|
||||
/*
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Body *models.UpdateDomainsRequest
|
||||
/*
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
Namespace string
|
||||
/*
|
||||
Required: true
|
||||
In: path
|
||||
*/
|
||||
Tenant string
|
||||
}
|
||||
|
||||
// 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 NewUpdateTenantDomainsParams() beforehand.
|
||||
func (o *UpdateTenantDomainsParams) 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.UpdateDomainsRequest
|
||||
if err := route.Consumer.Consume(r.Body, &body); err != nil {
|
||||
if err == io.EOF {
|
||||
res = append(res, errors.Required("body", "body", ""))
|
||||
} else {
|
||||
res = append(res, errors.NewParseError("body", "body", "", err))
|
||||
}
|
||||
} else {
|
||||
// validate body object
|
||||
if err := body.Validate(route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
ctx := validate.WithOperationRequest(context.Background())
|
||||
if err := body.ContextValidate(ctx, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
if len(res) == 0 {
|
||||
o.Body = &body
|
||||
}
|
||||
}
|
||||
} else {
|
||||
res = append(res, errors.Required("body", "body", ""))
|
||||
}
|
||||
|
||||
rNamespace, rhkNamespace, _ := route.Params.GetOK("namespace")
|
||||
if err := o.bindNamespace(rNamespace, rhkNamespace, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
|
||||
rTenant, rhkTenant, _ := route.Params.GetOK("tenant")
|
||||
if err := o.bindTenant(rTenant, rhkTenant, route.Formats); err != nil {
|
||||
res = append(res, err)
|
||||
}
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindNamespace binds and validates parameter Namespace from path.
|
||||
func (o *UpdateTenantDomainsParams) bindNamespace(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: true
|
||||
// Parameter is provided by construction from the route
|
||||
o.Namespace = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// bindTenant binds and validates parameter Tenant from path.
|
||||
func (o *UpdateTenantDomainsParams) bindTenant(rawData []string, hasKey bool, formats strfmt.Registry) error {
|
||||
var raw string
|
||||
if len(rawData) > 0 {
|
||||
raw = rawData[len(rawData)-1]
|
||||
}
|
||||
|
||||
// Required: true
|
||||
// Parameter is provided by construction from the route
|
||||
o.Tenant = raw
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
// 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 operator_api
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// UpdateTenantDomainsNoContentCode is the HTTP code returned for type UpdateTenantDomainsNoContent
|
||||
const UpdateTenantDomainsNoContentCode int = 204
|
||||
|
||||
/*UpdateTenantDomainsNoContent A successful response.
|
||||
|
||||
swagger:response updateTenantDomainsNoContent
|
||||
*/
|
||||
type UpdateTenantDomainsNoContent struct {
|
||||
}
|
||||
|
||||
// NewUpdateTenantDomainsNoContent creates UpdateTenantDomainsNoContent with default headers values
|
||||
func NewUpdateTenantDomainsNoContent() *UpdateTenantDomainsNoContent {
|
||||
|
||||
return &UpdateTenantDomainsNoContent{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *UpdateTenantDomainsNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(204)
|
||||
}
|
||||
|
||||
/*UpdateTenantDomainsDefault Generic error response.
|
||||
|
||||
swagger:response updateTenantDomainsDefault
|
||||
*/
|
||||
type UpdateTenantDomainsDefault struct {
|
||||
_statusCode int
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewUpdateTenantDomainsDefault creates UpdateTenantDomainsDefault with default headers values
|
||||
func NewUpdateTenantDomainsDefault(code int) *UpdateTenantDomainsDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &UpdateTenantDomainsDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the update tenant domains default response
|
||||
func (o *UpdateTenantDomainsDefault) WithStatusCode(code int) *UpdateTenantDomainsDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the update tenant domains default response
|
||||
func (o *UpdateTenantDomainsDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the update tenant domains default response
|
||||
func (o *UpdateTenantDomainsDefault) WithPayload(payload *models.Error) *UpdateTenantDomainsDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the update tenant domains default response
|
||||
func (o *UpdateTenantDomainsDefault) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *UpdateTenantDomainsDefault) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(o._statusCode)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
panic(err) // let the recovery middleware deal with this
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
// 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 operator_api
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the generate command
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
golangswaggerpaths "path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// UpdateTenantDomainsURL generates an URL for the update tenant domains operation
|
||||
type UpdateTenantDomainsURL struct {
|
||||
Namespace string
|
||||
Tenant string
|
||||
|
||||
_basePath string
|
||||
// avoid unkeyed usage
|
||||
_ 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 *UpdateTenantDomainsURL) WithBasePath(bp string) *UpdateTenantDomainsURL {
|
||||
o.SetBasePath(bp)
|
||||
return o
|
||||
}
|
||||
|
||||
// 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 *UpdateTenantDomainsURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *UpdateTenantDomainsURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/namespaces/{namespace}/tenants/{tenant}/domains"
|
||||
|
||||
namespace := o.Namespace
|
||||
if namespace != "" {
|
||||
_path = strings.Replace(_path, "{namespace}", namespace, -1)
|
||||
} else {
|
||||
return nil, errors.New("namespace is required on UpdateTenantDomainsURL")
|
||||
}
|
||||
|
||||
tenant := o.Tenant
|
||||
if tenant != "" {
|
||||
_path = strings.Replace(_path, "{tenant}", tenant, -1)
|
||||
} else {
|
||||
return nil, errors.New("tenant is required on UpdateTenantDomainsURL")
|
||||
}
|
||||
|
||||
_basePath := o._basePath
|
||||
if _basePath == "" {
|
||||
_basePath = "/api/v1"
|
||||
}
|
||||
_result.Path = golangswaggerpaths.Join(_basePath, _path)
|
||||
|
||||
return &_result, nil
|
||||
}
|
||||
|
||||
// Must is a helper function to panic when the url builder returns an error
|
||||
func (o *UpdateTenantDomainsURL) Must(u *url.URL, err error) *url.URL {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if u == nil {
|
||||
panic("url can't be nil")
|
||||
}
|
||||
return u
|
||||
}
|
||||
|
||||
// String returns the string representation of the path with query string
|
||||
func (o *UpdateTenantDomainsURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *UpdateTenantDomainsURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on UpdateTenantDomainsURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on UpdateTenantDomainsURL")
|
||||
}
|
||||
|
||||
base, err := o.Build()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
base.Scheme = scheme
|
||||
base.Host = host
|
||||
return base, nil
|
||||
}
|
||||
|
||||
// StringFull returns the string representation of a complete url
|
||||
func (o *UpdateTenantDomainsURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
||||
@@ -342,6 +342,14 @@ func registerTenantHandlers(api *operations.OperatorAPI) {
|
||||
}
|
||||
return operator_api.NewGetTenantEventsOK().WithPayload(payload)
|
||||
})
|
||||
// Update Tenant Domains
|
||||
api.OperatorAPIUpdateTenantDomainsHandler = operator_api.UpdateTenantDomainsHandlerFunc(func(params operator_api.UpdateTenantDomainsParams, principal *models.Principal) middleware.Responder {
|
||||
err := getUpdateDomainsResponse(principal, params)
|
||||
if err != nil {
|
||||
operator_api.NewUpdateTenantDomainsDefault(int(err.Code)).WithPayload(err)
|
||||
}
|
||||
return operator_api.NewUpdateTenantDomainsNoContent()
|
||||
})
|
||||
}
|
||||
|
||||
// getDeleteTenantResponse gets the output of deleting a minio instance
|
||||
@@ -2588,3 +2596,62 @@ func getTenantEventsResponse(session *models.Principal, params operator_api.GetT
|
||||
})
|
||||
return retval, nil
|
||||
}
|
||||
|
||||
func getUpdateDomainsResponse(session *models.Principal, params operator_api.UpdateTenantDomainsParams) *models.Error {
|
||||
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
|
||||
defer cancel()
|
||||
|
||||
operatorCli, err := cluster.OperatorClient(session.STSSessionToken)
|
||||
if err != nil {
|
||||
return prepareError(err)
|
||||
}
|
||||
|
||||
opClient := &operatorClient{
|
||||
client: operatorCli,
|
||||
}
|
||||
|
||||
err = updateTenantDomains(ctx, opClient, params.Namespace, params.Tenant, params.Body.Domains)
|
||||
|
||||
if err != nil {
|
||||
return prepareError(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func updateTenantDomains(ctx context.Context, operatorClient OperatorClientI, namespace string, tenantName string, domainConfig *models.DomainsConfiguration) error {
|
||||
|
||||
minTenant, err := getTenant(ctx, operatorClient, namespace, tenantName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var features miniov2.Features
|
||||
var domains miniov2.TenantDomains
|
||||
|
||||
// We include current value for BucketDNS. Domains will be overwritten as we are passing all the values that must be saved.
|
||||
if minTenant.Spec.Features != nil {
|
||||
features = miniov2.Features{
|
||||
BucketDNS: minTenant.Spec.Features.BucketDNS,
|
||||
}
|
||||
}
|
||||
|
||||
if domainConfig != nil {
|
||||
// tenant domains
|
||||
if domainConfig.Console != "" {
|
||||
domains.Console = domainConfig.Console
|
||||
}
|
||||
|
||||
if domainConfig.Minio != nil {
|
||||
domains.Minio = domainConfig.Minio
|
||||
}
|
||||
|
||||
features.Domains = &domains
|
||||
}
|
||||
|
||||
minTenant.Spec.Features = &features
|
||||
|
||||
_, err = operatorClient.TenantUpdate(ctx, minTenant, metav1.UpdateOptions{})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1080,3 +1080,133 @@ func Test_UpdateTenantAction(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_UpdateDomainsResponse(t *testing.T) {
|
||||
opClient := opClientMock{}
|
||||
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
operatorClient OperatorClientI
|
||||
nameSpace string
|
||||
tenantName string
|
||||
mockTenantUpdate func(ctx context.Context, tenant *miniov2.Tenant, options metav1.UpdateOptions) (*miniov2.Tenant, error)
|
||||
mockTenantGet func(ctx context.Context, namespace string, tenantName string, options metav1.GetOptions) (*miniov2.Tenant, error)
|
||||
domains *models.DomainsConfiguration
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
objs []runtime.Object
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "Update console & minio domains OK",
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
operatorClient: opClient,
|
||||
nameSpace: "default",
|
||||
tenantName: "minio-tenant",
|
||||
mockTenantUpdate: func(ctx context.Context, tenant *miniov2.Tenant, options metav1.UpdateOptions) (*miniov2.Tenant, error) {
|
||||
return &miniov2.Tenant{}, nil
|
||||
},
|
||||
mockTenantGet: func(ctx context.Context, namespace string, tenantName string, options metav1.GetOptions) (*miniov2.Tenant, error) {
|
||||
return &miniov2.Tenant{}, nil
|
||||
},
|
||||
domains: &models.DomainsConfiguration{
|
||||
Console: "http://console.min.io",
|
||||
Minio: []string{"http://domain1.min.io", "http://domain2.min.io", "http://domain3.min.io"},
|
||||
},
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "Error occurs getting minioTenant",
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
operatorClient: opClient,
|
||||
nameSpace: "default",
|
||||
tenantName: "minio-tenant",
|
||||
mockTenantUpdate: func(ctx context.Context, tenant *miniov2.Tenant, options metav1.UpdateOptions) (*miniov2.Tenant, error) {
|
||||
return &miniov2.Tenant{}, nil
|
||||
},
|
||||
mockTenantGet: func(ctx context.Context, namespace string, tenantName string, options metav1.GetOptions) (*miniov2.Tenant, error) {
|
||||
return nil, errors.New("error-getting-tenant-info")
|
||||
},
|
||||
domains: &models.DomainsConfiguration{
|
||||
Console: "http://console.min.io",
|
||||
Minio: []string{"http://domain1.min.io", "http://domain2.min.io", "http://domain3.min.io"},
|
||||
},
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "Tenant already has domains",
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
operatorClient: opClient,
|
||||
nameSpace: "default",
|
||||
tenantName: "minio-tenant",
|
||||
mockTenantUpdate: func(ctx context.Context, tenant *miniov2.Tenant, options metav1.UpdateOptions) (*miniov2.Tenant, error) {
|
||||
return &miniov2.Tenant{}, nil
|
||||
},
|
||||
mockTenantGet: func(ctx context.Context, namespace string, tenantName string, options metav1.GetOptions) (*miniov2.Tenant, error) {
|
||||
domains := miniov2.TenantDomains{
|
||||
Console: "http://onerandomdomain.min.io",
|
||||
Minio: []string{
|
||||
"http://oneDomain.min.io",
|
||||
"http://twoDomains.min.io",
|
||||
},
|
||||
}
|
||||
|
||||
features := miniov2.Features{
|
||||
Domains: &domains,
|
||||
}
|
||||
|
||||
return &miniov2.Tenant{
|
||||
Spec: miniov2.TenantSpec{Features: &features},
|
||||
}, nil
|
||||
},
|
||||
domains: &models.DomainsConfiguration{
|
||||
Console: "http://console.min.io",
|
||||
Minio: []string{"http://domain1.min.io", "http://domain2.min.io", "http://domain3.min.io"},
|
||||
},
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "Tenant features only have BucketDNS",
|
||||
args: args{
|
||||
ctx: context.Background(),
|
||||
operatorClient: opClient,
|
||||
nameSpace: "default",
|
||||
tenantName: "minio-tenant",
|
||||
mockTenantUpdate: func(ctx context.Context, tenant *miniov2.Tenant, options metav1.UpdateOptions) (*miniov2.Tenant, error) {
|
||||
return &miniov2.Tenant{}, nil
|
||||
},
|
||||
mockTenantGet: func(ctx context.Context, namespace string, tenantName string, options metav1.GetOptions) (*miniov2.Tenant, error) {
|
||||
features := miniov2.Features{
|
||||
BucketDNS: true,
|
||||
}
|
||||
|
||||
return &miniov2.Tenant{
|
||||
Spec: miniov2.TenantSpec{Features: &features},
|
||||
}, nil
|
||||
},
|
||||
domains: &models.DomainsConfiguration{
|
||||
Console: "http://console.min.io",
|
||||
Minio: []string{"http://domain1.min.io", "http://domain2.min.io", "http://domain3.min.io"},
|
||||
},
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
opClientTenantGetMock = tt.args.mockTenantGet
|
||||
opClientTenantUpdateMock = tt.args.mockTenantUpdate
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if err := updateTenantDomains(tt.args.ctx, tt.args.operatorClient, tt.args.nameSpace, tt.args.tenantName, tt.args.domains); (err != nil) != tt.wantErr {
|
||||
t.Errorf("updateTenantDomains() error = %v, wantErr %v", err, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1035,6 +1035,34 @@ paths:
|
||||
tags:
|
||||
- OperatorAPI
|
||||
|
||||
/namespaces/{namespace}/tenants/{tenant}/domains:
|
||||
put:
|
||||
summary: Update Domains for a Tenant
|
||||
operationId: UpdateTenantDomains
|
||||
parameters:
|
||||
- name: namespace
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
- name: tenant
|
||||
in: path
|
||||
required: true
|
||||
type: string
|
||||
- name: body
|
||||
in: body
|
||||
required: true
|
||||
schema:
|
||||
$ref: "#/definitions/updateDomainsRequest"
|
||||
responses:
|
||||
204:
|
||||
description: A successful response.
|
||||
default:
|
||||
description: Generic error response.
|
||||
schema:
|
||||
$ref: "#/definitions/error"
|
||||
tags:
|
||||
- OperatorAPI
|
||||
|
||||
/namespaces/{namespace}/resourcequotas/{resource-quota-name}:
|
||||
get:
|
||||
summary: Get Resource Quota
|
||||
@@ -2942,3 +2970,9 @@ definitions:
|
||||
type: string
|
||||
console:
|
||||
type: string
|
||||
|
||||
updateDomainsRequest:
|
||||
type: object
|
||||
properties:
|
||||
domains:
|
||||
$ref: "#/definitions/domainsConfiguration"
|
||||
|
||||
Reference in New Issue
Block a user