Remove unused check-version api (#3045)

This commit is contained in:
Cesar N
2023-09-13 12:55:06 -07:00
committed by GitHub
parent 8a918324aa
commit 6ef35c26a4
16 changed files with 21 additions and 825 deletions

View File

@@ -127,8 +127,6 @@ func configureAPI(api *operations.ConsoleAPI) http.Handler {
registerServiceHandlers(api)
// Register session handlers
registerSessionHandlers(api)
// Register version handlers
registerVersionHandlers(api)
// Register admin info handlers
registerAdminInfoHandlers(api)
// Register admin arns handlers

View File

@@ -2561,30 +2561,6 @@ func init() {
}
}
},
"/check-version": {
"get": {
"security": [],
"tags": [
"System"
],
"summary": "Checks the current MinIO version against the latest",
"operationId": "CheckMinIOVersion",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/checkVersionResponse"
}
},
"default": {
"description": "Generic error response.",
"schema": {
"$ref": "#/definitions/ApiError"
}
}
}
}
},
"/configs": {
"get": {
"tags": [
@@ -6096,17 +6072,6 @@ func init() {
}
}
},
"checkVersionResponse": {
"type": "object",
"properties": {
"current_version": {
"type": "string"
},
"latest_version": {
"type": "string"
}
}
},
"configDescription": {
"type": "object",
"properties": {
@@ -11637,30 +11602,6 @@ func init() {
}
}
},
"/check-version": {
"get": {
"security": [],
"tags": [
"System"
],
"summary": "Checks the current MinIO version against the latest",
"operationId": "CheckMinIOVersion",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/checkVersionResponse"
}
},
"default": {
"description": "Generic error response.",
"schema": {
"$ref": "#/definitions/ApiError"
}
}
}
}
},
"/configs": {
"get": {
"tags": [
@@ -15321,17 +15262,6 @@ func init() {
}
}
},
"checkVersionResponse": {
"type": "object",
"properties": {
"current_version": {
"type": "string"
},
"latest_version": {
"type": "string"
}
}
},
"configDescription": {
"type": "object",
"properties": {

View File

@@ -133,9 +133,6 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI {
AccountChangeUserPasswordHandler: account.ChangeUserPasswordHandlerFunc(func(params account.ChangeUserPasswordParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation account.ChangeUserPassword has not yet been implemented")
}),
SystemCheckMinIOVersionHandler: system.CheckMinIOVersionHandlerFunc(func(params system.CheckMinIOVersionParams) middleware.Responder {
return middleware.NotImplemented("operation system.CheckMinIOVersion has not yet been implemented")
}),
UserCheckUserServiceAccountsHandler: user.CheckUserServiceAccountsHandlerFunc(func(params user.CheckUserServiceAccountsParams, principal *models.Principal) middleware.Responder {
return middleware.NotImplemented("operation user.CheckUserServiceAccounts has not yet been implemented")
}),
@@ -652,8 +649,6 @@ type ConsoleAPI struct {
UserBulkUpdateUsersGroupsHandler user.BulkUpdateUsersGroupsHandler
// AccountChangeUserPasswordHandler sets the operation handler for the change user password operation
AccountChangeUserPasswordHandler account.ChangeUserPasswordHandler
// SystemCheckMinIOVersionHandler sets the operation handler for the check min i o version operation
SystemCheckMinIOVersionHandler system.CheckMinIOVersionHandler
// UserCheckUserServiceAccountsHandler sets the operation handler for the check user service accounts operation
UserCheckUserServiceAccountsHandler user.CheckUserServiceAccountsHandler
// ConfigurationConfigInfoHandler sets the operation handler for the config info operation
@@ -1072,9 +1067,6 @@ func (o *ConsoleAPI) Validate() error {
if o.AccountChangeUserPasswordHandler == nil {
unregistered = append(unregistered, "account.ChangeUserPasswordHandler")
}
if o.SystemCheckMinIOVersionHandler == nil {
unregistered = append(unregistered, "system.CheckMinIOVersionHandler")
}
if o.UserCheckUserServiceAccountsHandler == nil {
unregistered = append(unregistered, "user.CheckUserServiceAccountsHandler")
}
@@ -1665,10 +1657,6 @@ func (o *ConsoleAPI) initHandlerCache() {
o.handlers["POST"] = make(map[string]http.Handler)
}
o.handlers["POST"]["/account/change-user-password"] = account.NewChangeUserPassword(o.context, o.AccountChangeUserPasswordHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/check-version"] = system.NewCheckMinIOVersion(o.context, o.SystemCheckMinIOVersionHandler)
if o.handlers["POST"] == nil {
o.handlers["POST"] = make(map[string]http.Handler)
}

View File

@@ -1,73 +0,0 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2023 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 system
// 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"
)
// CheckMinIOVersionHandlerFunc turns a function with the right signature into a check min i o version handler
type CheckMinIOVersionHandlerFunc func(CheckMinIOVersionParams) middleware.Responder
// Handle executing the request and returning a response
func (fn CheckMinIOVersionHandlerFunc) Handle(params CheckMinIOVersionParams) middleware.Responder {
return fn(params)
}
// CheckMinIOVersionHandler interface for that can handle valid check min i o version params
type CheckMinIOVersionHandler interface {
Handle(CheckMinIOVersionParams) middleware.Responder
}
// NewCheckMinIOVersion creates a new http.Handler for the check min i o version operation
func NewCheckMinIOVersion(ctx *middleware.Context, handler CheckMinIOVersionHandler) *CheckMinIOVersion {
return &CheckMinIOVersion{Context: ctx, Handler: handler}
}
/*
CheckMinIOVersion swagger:route GET /check-version System checkMinIOVersion
Checks the current MinIO version against the latest
*/
type CheckMinIOVersion struct {
Context *middleware.Context
Handler CheckMinIOVersionHandler
}
func (o *CheckMinIOVersion) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
*r = *rCtx
}
var Params = NewCheckMinIOVersionParams()
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) // actually handle the request
o.Context.Respond(rw, r, route.Produces, route, res)
}

View File

@@ -1,63 +0,0 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2023 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 system
// 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/errors"
"github.com/go-openapi/runtime/middleware"
)
// NewCheckMinIOVersionParams creates a new CheckMinIOVersionParams object
//
// There are no default values defined in the spec.
func NewCheckMinIOVersionParams() CheckMinIOVersionParams {
return CheckMinIOVersionParams{}
}
// CheckMinIOVersionParams contains all the bound params for the check min i o version operation
// typically these are obtained from a http.Request
//
// swagger:parameters CheckMinIOVersion
type CheckMinIOVersionParams struct {
// HTTP Request Object
HTTPRequest *http.Request `json:"-"`
}
// 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 NewCheckMinIOVersionParams() beforehand.
func (o *CheckMinIOVersionParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
var res []error
o.HTTPRequest = r
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

View File

@@ -1,135 +0,0 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2023 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 system
// 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"
)
// CheckMinIOVersionOKCode is the HTTP code returned for type CheckMinIOVersionOK
const CheckMinIOVersionOKCode int = 200
/*
CheckMinIOVersionOK A successful response.
swagger:response checkMinIOVersionOK
*/
type CheckMinIOVersionOK struct {
/*
In: Body
*/
Payload *models.CheckVersionResponse `json:"body,omitempty"`
}
// NewCheckMinIOVersionOK creates CheckMinIOVersionOK with default headers values
func NewCheckMinIOVersionOK() *CheckMinIOVersionOK {
return &CheckMinIOVersionOK{}
}
// WithPayload adds the payload to the check min i o version o k response
func (o *CheckMinIOVersionOK) WithPayload(payload *models.CheckVersionResponse) *CheckMinIOVersionOK {
o.Payload = payload
return o
}
// SetPayload sets the payload to the check min i o version o k response
func (o *CheckMinIOVersionOK) SetPayload(payload *models.CheckVersionResponse) {
o.Payload = payload
}
// WriteResponse to the client
func (o *CheckMinIOVersionOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.WriteHeader(200)
if o.Payload != nil {
payload := o.Payload
if err := producer.Produce(rw, payload); err != nil {
panic(err) // let the recovery middleware deal with this
}
}
}
/*
CheckMinIOVersionDefault Generic error response.
swagger:response checkMinIOVersionDefault
*/
type CheckMinIOVersionDefault struct {
_statusCode int
/*
In: Body
*/
Payload *models.APIError `json:"body,omitempty"`
}
// NewCheckMinIOVersionDefault creates CheckMinIOVersionDefault with default headers values
func NewCheckMinIOVersionDefault(code int) *CheckMinIOVersionDefault {
if code <= 0 {
code = 500
}
return &CheckMinIOVersionDefault{
_statusCode: code,
}
}
// WithStatusCode adds the status to the check min i o version default response
func (o *CheckMinIOVersionDefault) WithStatusCode(code int) *CheckMinIOVersionDefault {
o._statusCode = code
return o
}
// SetStatusCode sets the status to the check min i o version default response
func (o *CheckMinIOVersionDefault) SetStatusCode(code int) {
o._statusCode = code
}
// WithPayload adds the payload to the check min i o version default response
func (o *CheckMinIOVersionDefault) WithPayload(payload *models.APIError) *CheckMinIOVersionDefault {
o.Payload = payload
return o
}
// SetPayload sets the payload to the check min i o version default response
func (o *CheckMinIOVersionDefault) SetPayload(payload *models.APIError) {
o.Payload = payload
}
// WriteResponse to the client
func (o *CheckMinIOVersionDefault) 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
}
}
}

View File

@@ -1,104 +0,0 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2023 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 system
// 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"
)
// CheckMinIOVersionURL generates an URL for the check min i o version operation
type CheckMinIOVersionURL struct {
_basePath string
}
// 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 *CheckMinIOVersionURL) WithBasePath(bp string) *CheckMinIOVersionURL {
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 *CheckMinIOVersionURL) SetBasePath(bp string) {
o._basePath = bp
}
// Build a url path and query string
func (o *CheckMinIOVersionURL) Build() (*url.URL, error) {
var _result url.URL
var _path = "/check-version"
_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 *CheckMinIOVersionURL) 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 *CheckMinIOVersionURL) String() string {
return o.Must(o.Build()).String()
}
// BuildFull builds a full url with scheme, host, path and query string
func (o *CheckMinIOVersionURL) BuildFull(scheme, host string) (*url.URL, error) {
if scheme == "" {
return nil, errors.New("scheme is required for a full url on CheckMinIOVersionURL")
}
if host == "" {
return nil, errors.New("host is required for a full url on CheckMinIOVersionURL")
}
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 *CheckMinIOVersionURL) StringFull(scheme, host string) string {
return o.Must(o.BuildFull(scheme, host)).String()
}

View File

@@ -1,59 +0,0 @@
// 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 restapi
import (
"context"
"time"
xhttp "github.com/minio/console/pkg/http"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/models"
"github.com/minio/console/pkg/utils"
"github.com/minio/console/restapi/operations"
systemApi "github.com/minio/console/restapi/operations/system"
)
func registerVersionHandlers(api *operations.ConsoleAPI) {
api.SystemCheckMinIOVersionHandler = systemApi.CheckMinIOVersionHandlerFunc(func(params systemApi.CheckMinIOVersionParams) middleware.Responder {
versionResponse, err := getVersionResponse(params)
if err != nil {
return systemApi.NewCheckMinIOVersionDefault(err.Code).WithPayload(err.APIError)
}
return systemApi.NewCheckMinIOVersionOK().WithPayload(versionResponse)
})
}
// getSessionResponse parse the token of the current session and returns a list of allowed actions to render in the UI
func getVersionResponse(params systemApi.CheckMinIOVersionParams) (*models.CheckVersionResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
client := GetConsoleHTTPClient("", getClientIP(params.HTTPRequest))
client.Timeout = 15 * time.Second
ver, err := utils.GetLatestMinIOImage(&xhttp.Client{
Client: client,
})
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return &models.CheckVersionResponse{
LatestVersion: *ver,
}, nil
}