Add option to delete tenant's pvcs on tenant deletion (#251)
This commit is contained in:
@@ -8,4 +8,4 @@ resources:
|
|||||||
- console-configmap.yaml
|
- console-configmap.yaml
|
||||||
- console-service.yaml
|
- console-service.yaml
|
||||||
- console-deployment.yaml
|
- console-deployment.yaml
|
||||||
- minio-operator.yaml
|
- https://github.com/minio/operator/?ref=v3.0.10
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -28,6 +28,12 @@ rules:
|
|||||||
- create
|
- create
|
||||||
- list
|
- list
|
||||||
- patch
|
- patch
|
||||||
|
- apiGroups:
|
||||||
|
- ""
|
||||||
|
resources:
|
||||||
|
- persistentvolumeclaims
|
||||||
|
verbs:
|
||||||
|
- deletecollection
|
||||||
- apiGroups:
|
- apiGroups:
|
||||||
- "storage.k8s.io"
|
- "storage.k8s.io"
|
||||||
resources:
|
resources:
|
||||||
|
|||||||
@@ -8,4 +8,4 @@ resources:
|
|||||||
- console-configmap.yaml
|
- console-configmap.yaml
|
||||||
- console-service.yaml
|
- console-service.yaml
|
||||||
- console-deployment.yaml
|
- console-deployment.yaml
|
||||||
- minio-operator.yaml
|
- https://github.com/minio/operator/?ref=v3.0.10
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
60
models/delete_tenant_request.go
Normal file
60
models/delete_tenant_request.go
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
// Code generated by go-swagger; DO NOT EDIT.
|
||||||
|
|
||||||
|
// This file is part of MinIO Console Server
|
||||||
|
// Copyright (c) 2020 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 (
|
||||||
|
"github.com/go-openapi/strfmt"
|
||||||
|
"github.com/go-openapi/swag"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DeleteTenantRequest delete tenant request
|
||||||
|
//
|
||||||
|
// swagger:model deleteTenantRequest
|
||||||
|
type DeleteTenantRequest struct {
|
||||||
|
|
||||||
|
// delete pvcs
|
||||||
|
DeletePvcs bool `json:"delete_pvcs,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate validates this delete tenant request
|
||||||
|
func (m *DeleteTenantRequest) Validate(formats strfmt.Registry) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalBinary interface implementation
|
||||||
|
func (m *DeleteTenantRequest) MarshalBinary() ([]byte, error) {
|
||||||
|
if m == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return swag.WriteJSON(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalBinary interface implementation
|
||||||
|
func (m *DeleteTenantRequest) UnmarshalBinary(b []byte) error {
|
||||||
|
var res DeleteTenantRequest
|
||||||
|
if err := swag.ReadJSON(b, &res); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*m = res
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -110,7 +110,7 @@ func registerTenantHandlers(api *operations.ConsoleAPI) {
|
|||||||
err := getDeleteTenantResponse(session, params)
|
err := getDeleteTenantResponse(session, params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
return admin_api.NewTenantInfoDefault(500).WithPayload(&models.Error{Code: 500, Message: swag.String("Unable to delete tenant")})
|
return admin_api.NewTenantInfoDefault(500).WithPayload(&models.Error{Code: 500, Message: swag.String(err.Error())})
|
||||||
}
|
}
|
||||||
return admin_api.NewTenantInfoOK()
|
return admin_api.NewTenantInfoOK()
|
||||||
|
|
||||||
@@ -145,25 +145,53 @@ func registerTenantHandlers(api *operations.ConsoleAPI) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// deleteTenantAction performs the actions of deleting a tenant
|
|
||||||
func deleteTenantAction(ctx context.Context, operatorClient OperatorClient, nameSpace, instanceName string) error {
|
|
||||||
err := operatorClient.TenantDelete(ctx, nameSpace, instanceName, metav1.DeleteOptions{})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// getDeleteTenantResponse gets the output of deleting a minio instance
|
// getDeleteTenantResponse gets the output of deleting a minio instance
|
||||||
func getDeleteTenantResponse(session *models.Principal, params admin_api.DeleteTenantParams) error {
|
func getDeleteTenantResponse(session *models.Principal, params admin_api.DeleteTenantParams) error {
|
||||||
opClientClientSet, err := cluster.OperatorClient(session.SessionToken)
|
opClientClientSet, err := cluster.OperatorClient(session.SessionToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
// get Kubernetes Client
|
||||||
|
clientset, err := cluster.K8sClient(session.SessionToken)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
opClient := &operatorClient{
|
opClient := &operatorClient{
|
||||||
client: opClientClientSet,
|
client: opClientClientSet,
|
||||||
}
|
}
|
||||||
return deleteTenantAction(context.Background(), opClient, params.Namespace, params.Tenant)
|
deleteTenantPVCs := false
|
||||||
|
if params.Body != nil {
|
||||||
|
deleteTenantPVCs = params.Body.DeletePvcs
|
||||||
|
}
|
||||||
|
return deleteTenantAction(context.Background(), opClient, clientset.CoreV1(), params.Namespace, params.Tenant, deleteTenantPVCs)
|
||||||
|
}
|
||||||
|
|
||||||
|
// deleteTenantAction performs the actions of deleting a tenant
|
||||||
|
//
|
||||||
|
// It also adds the option of deleting the tenant's underlying pvcs if deletePvcs set
|
||||||
|
func deleteTenantAction(
|
||||||
|
ctx context.Context,
|
||||||
|
operatorClient OperatorClient,
|
||||||
|
clientset v1.CoreV1Interface,
|
||||||
|
namespace, tenantName string,
|
||||||
|
deletePvcs bool) error {
|
||||||
|
|
||||||
|
err := operatorClient.TenantDelete(ctx, namespace, tenantName, metav1.DeleteOptions{})
|
||||||
|
if err != nil {
|
||||||
|
// try to delete pvc even if the tenant doesn't exist anymore but only if deletePvcs is set to true,
|
||||||
|
// else, we return the error
|
||||||
|
if (deletePvcs && !k8sErrors.IsNotFound(err)) || !deletePvcs {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if deletePvcs {
|
||||||
|
opts := metav1.ListOptions{
|
||||||
|
LabelSelector: fmt.Sprintf("%s=%s", operator.TenantLabel, tenantName),
|
||||||
|
}
|
||||||
|
return clientset.PersistentVolumeClaims(namespace).DeleteCollection(ctx, metav1.DeleteOptions{}, opts)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTenantScheme(mi *operator.Tenant) string {
|
func getTenantScheme(mi *operator.Tenant) string {
|
||||||
|
|||||||
@@ -33,9 +33,11 @@ import (
|
|||||||
operator "github.com/minio/operator/pkg/apis/minio.min.io/v1"
|
operator "github.com/minio/operator/pkg/apis/minio.min.io/v1"
|
||||||
v1 "github.com/minio/operator/pkg/apis/minio.min.io/v1"
|
v1 "github.com/minio/operator/pkg/apis/minio.min.io/v1"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
|
k8sErrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
"k8s.io/apimachinery/pkg/api/resource"
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
types "k8s.io/apimachinery/pkg/types"
|
types "k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/client-go/kubernetes/fake"
|
"k8s.io/client-go/kubernetes/fake"
|
||||||
)
|
)
|
||||||
@@ -335,12 +337,13 @@ func Test_TenantInfo(t *testing.T) {
|
|||||||
|
|
||||||
func Test_deleteTenantAction(t *testing.T) {
|
func Test_deleteTenantAction(t *testing.T) {
|
||||||
opClient := opClientMock{}
|
opClient := opClientMock{}
|
||||||
|
|
||||||
type args struct {
|
type args struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
operatorClient OperatorClient
|
operatorClient OperatorClient
|
||||||
nameSpace string
|
nameSpace string
|
||||||
tenantName string
|
tenantName string
|
||||||
|
deletePvcs bool
|
||||||
|
objs []runtime.Object
|
||||||
mockTenantDelete func(ctx context.Context, namespace string, tenantName string, options metav1.DeleteOptions) error
|
mockTenantDelete func(ctx context.Context, namespace string, tenantName string, options metav1.DeleteOptions) error
|
||||||
}
|
}
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
@@ -355,6 +358,7 @@ func Test_deleteTenantAction(t *testing.T) {
|
|||||||
operatorClient: opClient,
|
operatorClient: opClient,
|
||||||
nameSpace: "default",
|
nameSpace: "default",
|
||||||
tenantName: "minio-tenant",
|
tenantName: "minio-tenant",
|
||||||
|
deletePvcs: false,
|
||||||
mockTenantDelete: func(ctx context.Context, namespace string, tenantName string, options metav1.DeleteOptions) error {
|
mockTenantDelete: func(ctx context.Context, namespace string, tenantName string, options metav1.DeleteOptions) error {
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
@@ -368,17 +372,155 @@ func Test_deleteTenantAction(t *testing.T) {
|
|||||||
operatorClient: opClient,
|
operatorClient: opClient,
|
||||||
nameSpace: "default",
|
nameSpace: "default",
|
||||||
tenantName: "minio-tenant",
|
tenantName: "minio-tenant",
|
||||||
|
deletePvcs: false,
|
||||||
mockTenantDelete: func(ctx context.Context, namespace string, tenantName string, options metav1.DeleteOptions) error {
|
mockTenantDelete: func(ctx context.Context, namespace string, tenantName string, options metav1.DeleteOptions) error {
|
||||||
return errors.New("something happened")
|
return errors.New("something happened")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
// Delete only PVCs of the defined tenant on the specific namespace
|
||||||
|
name: "Delete PVCs on Tenant Deletion",
|
||||||
|
args: args{
|
||||||
|
ctx: context.Background(),
|
||||||
|
operatorClient: opClient,
|
||||||
|
nameSpace: "minio-tenant",
|
||||||
|
tenantName: "tenant1",
|
||||||
|
deletePvcs: true,
|
||||||
|
objs: []runtime.Object{
|
||||||
|
&corev1.PersistentVolumeClaim{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: "PVC1",
|
||||||
|
Namespace: "minio-tenant",
|
||||||
|
Labels: map[string]string{
|
||||||
|
operator.TenantLabel: "tenant1",
|
||||||
|
operator.ZoneLabel: "zone-1",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mockTenantDelete: func(ctx context.Context, namespace string, tenantName string, options metav1.DeleteOptions) error {
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
},
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Do not delete underlying pvcs
|
||||||
|
name: "Don't Delete PVCs on Tenant Deletion",
|
||||||
|
args: args{
|
||||||
|
ctx: context.Background(),
|
||||||
|
operatorClient: opClient,
|
||||||
|
nameSpace: "minio-tenant",
|
||||||
|
tenantName: "tenant1",
|
||||||
|
deletePvcs: false,
|
||||||
|
objs: []runtime.Object{
|
||||||
|
&corev1.PersistentVolumeClaim{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: "PVC1",
|
||||||
|
Namespace: "minio-tenant",
|
||||||
|
Labels: map[string]string{
|
||||||
|
operator.TenantLabel: "tenant1",
|
||||||
|
operator.ZoneLabel: "zone-1",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mockTenantDelete: func(ctx context.Context, namespace string, tenantName string, options metav1.DeleteOptions) error {
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
},
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// If error is different than NotFound, PVC deletion should not continue
|
||||||
|
name: "Don't delete pvcs if error Deleting Tenant, return",
|
||||||
|
args: args{
|
||||||
|
ctx: context.Background(),
|
||||||
|
operatorClient: opClient,
|
||||||
|
nameSpace: "minio-tenant",
|
||||||
|
tenantName: "tenant1",
|
||||||
|
deletePvcs: true,
|
||||||
|
objs: []runtime.Object{
|
||||||
|
&corev1.PersistentVolumeClaim{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: "PVC1",
|
||||||
|
Namespace: "minio-tenant",
|
||||||
|
Labels: map[string]string{
|
||||||
|
operator.TenantLabel: "tenant1",
|
||||||
|
operator.ZoneLabel: "zone-1",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mockTenantDelete: func(ctx context.Context, namespace string, tenantName string, options metav1.DeleteOptions) error {
|
||||||
|
return errors.New("error returned")
|
||||||
|
},
|
||||||
|
},
|
||||||
|
wantErr: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// If error is NotFound while trying to Delete Tenant, PVC deletion should continue
|
||||||
|
name: "Delete pvcs if tenant not found",
|
||||||
|
args: args{
|
||||||
|
ctx: context.Background(),
|
||||||
|
operatorClient: opClient,
|
||||||
|
nameSpace: "minio-tenant",
|
||||||
|
tenantName: "tenant1",
|
||||||
|
deletePvcs: true,
|
||||||
|
objs: []runtime.Object{
|
||||||
|
&corev1.PersistentVolumeClaim{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: "PVC1",
|
||||||
|
Namespace: "minio-tenant",
|
||||||
|
Labels: map[string]string{
|
||||||
|
operator.TenantLabel: "tenant1",
|
||||||
|
operator.ZoneLabel: "zone-1",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mockTenantDelete: func(ctx context.Context, namespace string, tenantName string, options metav1.DeleteOptions) error {
|
||||||
|
return k8sErrors.NewNotFound(schema.GroupResource{}, "tenant1")
|
||||||
|
},
|
||||||
|
},
|
||||||
|
wantErr: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// If error is NotFound while trying to Delete Tenant and pvcdeletion=false,
|
||||||
|
// error should be returned
|
||||||
|
name: "Don't delete pvcs and return error if tenant not found",
|
||||||
|
args: args{
|
||||||
|
ctx: context.Background(),
|
||||||
|
operatorClient: opClient,
|
||||||
|
nameSpace: "minio-tenant",
|
||||||
|
tenantName: "tenant1",
|
||||||
|
deletePvcs: false,
|
||||||
|
objs: []runtime.Object{
|
||||||
|
&corev1.PersistentVolumeClaim{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: "PVC1",
|
||||||
|
Namespace: "minio-tenant",
|
||||||
|
Labels: map[string]string{
|
||||||
|
operator.TenantLabel: "tenant1",
|
||||||
|
operator.ZoneLabel: "zone-1",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mockTenantDelete: func(ctx context.Context, namespace string, tenantName string, options metav1.DeleteOptions) error {
|
||||||
|
return k8sErrors.NewNotFound(schema.GroupResource{}, "tenant1")
|
||||||
|
},
|
||||||
|
},
|
||||||
|
wantErr: true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
opClientTenantDeleteMock = tt.args.mockTenantDelete
|
opClientTenantDeleteMock = tt.args.mockTenantDelete
|
||||||
|
kubeClient := fake.NewSimpleClientset(tt.args.objs...)
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
if err := deleteTenantAction(tt.args.ctx, tt.args.operatorClient, tt.args.nameSpace, tt.args.tenantName); (err != nil) != tt.wantErr {
|
if err := deleteTenantAction(tt.args.ctx, tt.args.operatorClient, kubeClient.CoreV1(), tt.args.nameSpace, tt.args.tenantName, tt.args.deletePvcs); (err != nil) != tt.wantErr {
|
||||||
t.Errorf("deleteTenantAction() error = %v, wantErr %v", err, tt.wantErr)
|
t.Errorf("deleteTenantAction() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -768,7 +910,7 @@ func Test_UpdateTenantAction(t *testing.T) {
|
|||||||
cnsClient := fake.NewSimpleClientset(tt.objs...)
|
cnsClient := fake.NewSimpleClientset(tt.objs...)
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
if err := updateTenantAction(tt.args.ctx, tt.args.operatorClient, cnsClient.CoreV1(), tt.args.httpCl, tt.args.nameSpace, tt.args.params); (err != nil) != tt.wantErr {
|
if err := updateTenantAction(tt.args.ctx, tt.args.operatorClient, cnsClient.CoreV1(), tt.args.httpCl, tt.args.nameSpace, tt.args.params); (err != nil) != tt.wantErr {
|
||||||
t.Errorf("deleteTenantAction() error = %v, wantErr %v", err, tt.wantErr)
|
t.Errorf("updateTenantAction() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1007,7 +1007,7 @@ func init() {
|
|||||||
"tags": [
|
"tags": [
|
||||||
"AdminAPI"
|
"AdminAPI"
|
||||||
],
|
],
|
||||||
"summary": "Delete Tenant",
|
"summary": "Delete tenant and underlying pvcs",
|
||||||
"operationId": "DeleteTenant",
|
"operationId": "DeleteTenant",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
@@ -1021,6 +1021,13 @@ func init() {
|
|||||||
"name": "tenant",
|
"name": "tenant",
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"required": true
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "body",
|
||||||
|
"in": "body",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/deleteTenantRequest"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
@@ -2105,6 +2112,14 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"deleteTenantRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"delete_pvcs": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"encryptionConfiguration": {
|
"encryptionConfiguration": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -4423,7 +4438,7 @@ func init() {
|
|||||||
"tags": [
|
"tags": [
|
||||||
"AdminAPI"
|
"AdminAPI"
|
||||||
],
|
],
|
||||||
"summary": "Delete Tenant",
|
"summary": "Delete tenant and underlying pvcs",
|
||||||
"operationId": "DeleteTenant",
|
"operationId": "DeleteTenant",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
@@ -4437,6 +4452,13 @@ func init() {
|
|||||||
"name": "tenant",
|
"name": "tenant",
|
||||||
"in": "path",
|
"in": "path",
|
||||||
"required": true
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "body",
|
||||||
|
"in": "body",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/deleteTenantRequest"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
@@ -6032,6 +6054,14 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"deleteTenantRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"delete_pvcs": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"encryptionConfiguration": {
|
"encryptionConfiguration": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ func NewDeleteTenant(ctx *middleware.Context, handler DeleteTenantHandler) *Dele
|
|||||||
|
|
||||||
/*DeleteTenant swagger:route DELETE /namespaces/{namespace}/tenants/{tenant} AdminAPI deleteTenant
|
/*DeleteTenant swagger:route DELETE /namespaces/{namespace}/tenants/{tenant} AdminAPI deleteTenant
|
||||||
|
|
||||||
Delete Tenant
|
Delete tenant and underlying pvcs
|
||||||
|
|
||||||
*/
|
*/
|
||||||
type DeleteTenant struct {
|
type DeleteTenant struct {
|
||||||
|
|||||||
@@ -26,8 +26,11 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/go-openapi/errors"
|
"github.com/go-openapi/errors"
|
||||||
|
"github.com/go-openapi/runtime"
|
||||||
"github.com/go-openapi/runtime/middleware"
|
"github.com/go-openapi/runtime/middleware"
|
||||||
"github.com/go-openapi/strfmt"
|
"github.com/go-openapi/strfmt"
|
||||||
|
|
||||||
|
"github.com/minio/console/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewDeleteTenantParams creates a new DeleteTenantParams object
|
// NewDeleteTenantParams creates a new DeleteTenantParams object
|
||||||
@@ -46,6 +49,10 @@ type DeleteTenantParams struct {
|
|||||||
// HTTP Request Object
|
// HTTP Request Object
|
||||||
HTTPRequest *http.Request `json:"-"`
|
HTTPRequest *http.Request `json:"-"`
|
||||||
|
|
||||||
|
/*
|
||||||
|
In: body
|
||||||
|
*/
|
||||||
|
Body *models.DeleteTenantRequest
|
||||||
/*
|
/*
|
||||||
Required: true
|
Required: true
|
||||||
In: path
|
In: path
|
||||||
@@ -67,6 +74,22 @@ func (o *DeleteTenantParams) BindRequest(r *http.Request, route *middleware.Matc
|
|||||||
|
|
||||||
o.HTTPRequest = r
|
o.HTTPRequest = r
|
||||||
|
|
||||||
|
if runtime.HasBody(r) {
|
||||||
|
defer r.Body.Close()
|
||||||
|
var body models.DeleteTenantRequest
|
||||||
|
if err := route.Consumer.Consume(r.Body, &body); err != nil {
|
||||||
|
res = append(res, errors.NewParseError("body", "body", "", err))
|
||||||
|
} else {
|
||||||
|
// validate body object
|
||||||
|
if err := body.Validate(route.Formats); err != nil {
|
||||||
|
res = append(res, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(res) == 0 {
|
||||||
|
o.Body = &body
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
rNamespace, rhkNamespace, _ := route.Params.GetOK("namespace")
|
rNamespace, rhkNamespace, _ := route.Params.GetOK("namespace")
|
||||||
if err := o.bindNamespace(rNamespace, rhkNamespace, route.Formats); err != nil {
|
if err := o.bindNamespace(rNamespace, rhkNamespace, route.Formats); err != nil {
|
||||||
res = append(res, err)
|
res = append(res, err)
|
||||||
|
|||||||
13
swagger.yml
13
swagger.yml
@@ -1069,7 +1069,7 @@ paths:
|
|||||||
tags:
|
tags:
|
||||||
- AdminAPI
|
- AdminAPI
|
||||||
delete:
|
delete:
|
||||||
summary: Delete Tenant
|
summary: Delete tenant and underlying pvcs
|
||||||
operationId: DeleteTenant
|
operationId: DeleteTenant
|
||||||
parameters:
|
parameters:
|
||||||
- name: namespace
|
- name: namespace
|
||||||
@@ -1080,6 +1080,11 @@ paths:
|
|||||||
in: path
|
in: path
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
|
- name: body
|
||||||
|
in: body
|
||||||
|
required: false
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/deleteTenantRequest"
|
||||||
responses:
|
responses:
|
||||||
204:
|
204:
|
||||||
description: A successful response.
|
description: A successful response.
|
||||||
@@ -2516,3 +2521,9 @@ definitions:
|
|||||||
used:
|
used:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
|
|
||||||
|
deleteTenantRequest:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
delete_pvcs:
|
||||||
|
type: boolean
|
||||||
|
|||||||
Reference in New Issue
Block a user