From adf3f929a4690d39ddb8fd7f4338ce5303ff55ee Mon Sep 17 00:00:00 2001 From: Daniel Valdivia Date: Sat, 5 Sep 2020 23:37:01 -0700 Subject: [PATCH] Add Tenant Deletion Date to tenant responses (#270) --- models/tenant.go | 3 + models/tenant_list.go | 3 + models/update_certificates_request.go | 113 -------------------------- restapi/admin_tenants.go | 11 +++ restapi/embedded_spec.go | 12 +++ swagger.yml | 4 + 6 files changed, 33 insertions(+), 113 deletions(-) delete mode 100644 models/update_certificates_request.go diff --git a/models/tenant.go b/models/tenant.go index cbbcdff98..b2258bb81 100644 --- a/models/tenant.go +++ b/models/tenant.go @@ -41,6 +41,9 @@ type Tenant struct { // current state CurrentState string `json:"currentState,omitempty"` + // deletion date + DeletionDate string `json:"deletion_date,omitempty"` + // image Image string `json:"image,omitempty"` diff --git a/models/tenant_list.go b/models/tenant_list.go index 665e05ecb..5532f874e 100644 --- a/models/tenant_list.go +++ b/models/tenant_list.go @@ -38,6 +38,9 @@ type TenantList struct { // current state CurrentState string `json:"currentState,omitempty"` + // deletion date + DeletionDate string `json:"deletion_date,omitempty"` + // instance count InstanceCount int64 `json:"instance_count,omitempty"` diff --git a/models/update_certificates_request.go b/models/update_certificates_request.go deleted file mode 100644 index e57772188..000000000 --- a/models/update_certificates_request.go +++ /dev/null @@ -1,113 +0,0 @@ -// 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 . -// - -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/errors" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" -) - -// UpdateCertificatesRequest update certificates request -// -// swagger:model updateCertificatesRequest -type UpdateCertificatesRequest struct { - - // console - Console *KeyPairConfiguration `json:"console,omitempty"` - - // minio - Minio *KeyPairConfiguration `json:"minio,omitempty"` -} - -// Validate validates this update certificates request -func (m *UpdateCertificatesRequest) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateConsole(formats); err != nil { - res = append(res, err) - } - - if err := m.validateMinio(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *UpdateCertificatesRequest) validateConsole(formats strfmt.Registry) error { - - if swag.IsZero(m.Console) { // not required - return nil - } - - if m.Console != nil { - if err := m.Console.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("console") - } - return err - } - } - - return nil -} - -func (m *UpdateCertificatesRequest) validateMinio(formats strfmt.Registry) error { - - if swag.IsZero(m.Minio) { // not required - return nil - } - - if m.Minio != nil { - if err := m.Minio.Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName("minio") - } - return err - } - } - - return nil -} - -// MarshalBinary interface implementation -func (m *UpdateCertificatesRequest) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *UpdateCertificatesRequest) UnmarshalBinary(b []byte) error { - var res UpdateCertificatesRequest - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/restapi/admin_tenants.go b/restapi/admin_tenants.go index cb78daaae..81002c07d 100644 --- a/restapi/admin_tenants.go +++ b/restapi/admin_tenants.go @@ -266,9 +266,14 @@ func getTenantInfo(tenant *operator.Tenant) *models.Tenant { zoneSize := int64(z.Servers) * int64(z.VolumesPerServer) * z.VolumeClaimTemplate.Spec.Resources.Requests.Storage().Value() totalSize = totalSize + zoneSize } + var deletion string + if tenant.ObjectMeta.DeletionTimestamp != nil { + deletion = tenant.ObjectMeta.DeletionTimestamp.String() + } return &models.Tenant{ CreationDate: tenant.ObjectMeta.CreationTimestamp.String(), + DeletionDate: deletion, Name: tenant.Name, TotalSize: totalSize, CurrentState: tenant.Status.CurrentState, @@ -330,8 +335,14 @@ func listTenants(ctx context.Context, operatorClient OperatorClientI, namespace } } + var deletion string + if tenant.ObjectMeta.DeletionTimestamp != nil { + deletion = tenant.ObjectMeta.DeletionTimestamp.String() + } + tenants = append(tenants, &models.TenantList{ CreationDate: tenant.ObjectMeta.CreationTimestamp.String(), + DeletionDate: deletion, Name: tenant.ObjectMeta.Name, ZoneCount: int64(len(tenant.Spec.Zones)), InstanceCount: instanceCount, diff --git a/restapi/embedded_spec.go b/restapi/embedded_spec.go index ae287db90..71674aaff 100644 --- a/restapi/embedded_spec.go +++ b/restapi/embedded_spec.go @@ -3156,6 +3156,9 @@ func init() { "currentState": { "type": "string" }, + "deletion_date": { + "type": "string" + }, "image": { "type": "string" }, @@ -3186,6 +3189,9 @@ func init() { "currentState": { "type": "string" }, + "deletion_date": { + "type": "string" + }, "instance_count": { "type": "integer" }, @@ -7231,6 +7237,9 @@ func init() { "currentState": { "type": "string" }, + "deletion_date": { + "type": "string" + }, "image": { "type": "string" }, @@ -7261,6 +7270,9 @@ func init() { "currentState": { "type": "string" }, + "deletion_date": { + "type": "string" + }, "instance_count": { "type": "integer" }, diff --git a/swagger.yml b/swagger.yml index 50ce3c44e..56331ad2f 100644 --- a/swagger.yml +++ b/swagger.yml @@ -1828,6 +1828,8 @@ definitions: type: string creation_date: type: string + deletion_date: + type: string currentState: type: string zones: @@ -1867,6 +1869,8 @@ definitions: type: integer creation_date: type: string + deletion_date: + type: string currentState: type: string namespace: