Call Home Enabled in console (#2248)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
This commit is contained in:
@@ -31,10 +31,11 @@ var (
|
||||
MinioServerInfoMock func(ctx context.Context) (madmin.InfoMessage, error)
|
||||
minioChangePasswordMock func(ctx context.Context, accessKey, secretKey string) error
|
||||
|
||||
minioHelpConfigKVMock func(subSys, key string, envOnly bool) (madmin.Help, error)
|
||||
minioGetConfigKVMock func(key string) ([]byte, error)
|
||||
minioSetConfigKVMock func(kv string) (restart bool, err error)
|
||||
minioDelConfigKVMock func(name string) (err error)
|
||||
minioHelpConfigKVMock func(subSys, key string, envOnly bool) (madmin.Help, error)
|
||||
minioGetConfigKVMock func(key string) ([]byte, error)
|
||||
minioSetConfigKVMock func(kv string) (restart bool, err error)
|
||||
minioDelConfigKVMock func(name string) (err error)
|
||||
minioHelpConfigKVGlobalMock func(envOnly bool) (madmin.Help, error)
|
||||
|
||||
minioGetLogsMock func(ctx context.Context, node string, lineCnt int, logKind string) <-chan madmin.LogInfo
|
||||
|
||||
@@ -133,6 +134,11 @@ func (ac AdminClientMock) setConfigKV(ctx context.Context, kv string) (restart b
|
||||
return minioSetConfigKVMock(kv)
|
||||
}
|
||||
|
||||
// mock function helpConfigKV()
|
||||
func (ac AdminClientMock) helpConfigKVGlobal(ctx context.Context, envOnly bool) (madmin.Help, error) {
|
||||
return minioHelpConfigKVGlobalMock(envOnly)
|
||||
}
|
||||
|
||||
func (ac AdminClientMock) delConfigKV(ctx context.Context, name string) (err error) {
|
||||
return minioDelConfigKVMock(name)
|
||||
}
|
||||
|
||||
@@ -83,8 +83,10 @@ type MinioAdmin interface {
|
||||
setPolicy(ctx context.Context, policyName, entityName string, isGroup bool) error
|
||||
getConfigKV(ctx context.Context, key string) ([]byte, error)
|
||||
helpConfigKV(ctx context.Context, subSys, key string, envOnly bool) (madmin.Help, error)
|
||||
helpConfigKVGlobal(ctx context.Context, envOnly bool) (madmin.Help, error)
|
||||
setConfigKV(ctx context.Context, kv string) (restart bool, err error)
|
||||
delConfigKV(ctx context.Context, kv string) (err error)
|
||||
|
||||
serviceRestart(ctx context.Context) error
|
||||
serverInfo(ctx context.Context) (madmin.InfoMessage, error)
|
||||
startProfiling(ctx context.Context, profiler madmin.ProfilerType) ([]madmin.StartProfilingResult, error)
|
||||
@@ -269,6 +271,11 @@ func (ac AdminClient) helpConfigKV(ctx context.Context, subSys, key string, envO
|
||||
return ac.Client.HelpConfigKV(ctx, subSys, key, envOnly)
|
||||
}
|
||||
|
||||
// implements madmin.helpConfigKVGlobal()
|
||||
func (ac AdminClient) helpConfigKVGlobal(ctx context.Context, envOnly bool) (madmin.Help, error) {
|
||||
return ac.Client.HelpConfigKV(ctx, "", "", envOnly)
|
||||
}
|
||||
|
||||
// implements madmin.SetConfigKV()
|
||||
func (ac AdminClient) setConfigKV(ctx context.Context, kv string) (restart bool, err error) {
|
||||
return ac.Client.SetConfigKV(ctx, kv)
|
||||
|
||||
@@ -156,6 +156,8 @@ func configureAPI(api *operations.ConsoleAPI) http.Handler {
|
||||
|
||||
registerSiteReplicationHandler(api)
|
||||
registerSiteReplicationStatusHandler(api)
|
||||
// Register Support Handler
|
||||
registerSupportHandlers(api)
|
||||
|
||||
// Operator Console
|
||||
|
||||
|
||||
@@ -4725,6 +4725,57 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/support/callhome": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Support"
|
||||
],
|
||||
"summary": "Get Callhome current status",
|
||||
"operationId": "GetCallHomeOptionValue",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/callHomeGetResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"put": {
|
||||
"tags": [
|
||||
"Support"
|
||||
],
|
||||
"summary": "Sets callhome status",
|
||||
"operationId": "SetCallHomeStatus",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/callHomeSetStatus"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "A successful response."
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/policy": {
|
||||
"get": {
|
||||
"tags": [
|
||||
@@ -5828,6 +5879,32 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"callHomeGetResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"diagnosticsStatus": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"logsStatus": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"callHomeSetStatus": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"diagState",
|
||||
"logsState"
|
||||
],
|
||||
"properties": {
|
||||
"diagState": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"logsState": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"changeUserPasswordRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
@@ -13418,6 +13495,57 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"/support/callhome": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"Support"
|
||||
],
|
||||
"summary": "Get Callhome current status",
|
||||
"operationId": "GetCallHomeOptionValue",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "A successful response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/callHomeGetResponse"
|
||||
}
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"put": {
|
||||
"tags": [
|
||||
"Support"
|
||||
],
|
||||
"summary": "Sets callhome status",
|
||||
"operationId": "SetCallHomeStatus",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/callHomeSetStatus"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"204": {
|
||||
"description": "A successful response."
|
||||
},
|
||||
"default": {
|
||||
"description": "Generic error response.",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/user/policy": {
|
||||
"get": {
|
||||
"tags": [
|
||||
@@ -14647,6 +14775,32 @@ func init() {
|
||||
}
|
||||
}
|
||||
},
|
||||
"callHomeGetResponse": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"diagnosticsStatus": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"logsStatus": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"callHomeSetStatus": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"diagState",
|
||||
"logsState"
|
||||
],
|
||||
"properties": {
|
||||
"diagState": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"logsState": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
"changeUserPasswordRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
||||
@@ -55,6 +55,7 @@ import (
|
||||
"github.com/minio/console/restapi/operations/service_account"
|
||||
"github.com/minio/console/restapi/operations/site_replication"
|
||||
"github.com/minio/console/restapi/operations/subnet"
|
||||
"github.com/minio/console/restapi/operations/support"
|
||||
"github.com/minio/console/restapi/operations/system"
|
||||
"github.com/minio/console/restapi/operations/tiering"
|
||||
"github.com/minio/console/restapi/operations/user"
|
||||
@@ -243,6 +244,9 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI {
|
||||
BucketGetBucketVersioningHandler: bucket.GetBucketVersioningHandlerFunc(func(params bucket.GetBucketVersioningParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation bucket.GetBucketVersioning has not yet been implemented")
|
||||
}),
|
||||
SupportGetCallHomeOptionValueHandler: support.GetCallHomeOptionValueHandlerFunc(func(params support.GetCallHomeOptionValueParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation support.GetCallHomeOptionValue has not yet been implemented")
|
||||
}),
|
||||
IdpGetConfigurationHandler: idp.GetConfigurationHandlerFunc(func(params idp.GetConfigurationParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation idp.GetConfiguration has not yet been implemented")
|
||||
}),
|
||||
@@ -471,6 +475,9 @@ func NewConsoleAPI(spec *loads.Document) *ConsoleAPI {
|
||||
BucketSetBucketVersioningHandler: bucket.SetBucketVersioningHandlerFunc(func(params bucket.SetBucketVersioningParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation bucket.SetBucketVersioning has not yet been implemented")
|
||||
}),
|
||||
SupportSetCallHomeStatusHandler: support.SetCallHomeStatusHandlerFunc(func(params support.SetCallHomeStatusParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation support.SetCallHomeStatus has not yet been implemented")
|
||||
}),
|
||||
ConfigurationSetConfigHandler: configuration.SetConfigHandlerFunc(func(params configuration.SetConfigParams, principal *models.Principal) middleware.Responder {
|
||||
return middleware.NotImplemented("operation configuration.SetConfig has not yet been implemented")
|
||||
}),
|
||||
@@ -707,6 +714,8 @@ type ConsoleAPI struct {
|
||||
BucketGetBucketRewindHandler bucket.GetBucketRewindHandler
|
||||
// BucketGetBucketVersioningHandler sets the operation handler for the get bucket versioning operation
|
||||
BucketGetBucketVersioningHandler bucket.GetBucketVersioningHandler
|
||||
// SupportGetCallHomeOptionValueHandler sets the operation handler for the get call home option value operation
|
||||
SupportGetCallHomeOptionValueHandler support.GetCallHomeOptionValueHandler
|
||||
// IdpGetConfigurationHandler sets the operation handler for the get configuration operation
|
||||
IdpGetConfigurationHandler idp.GetConfigurationHandler
|
||||
// ObjectGetObjectMetadataHandler sets the operation handler for the get object metadata operation
|
||||
@@ -859,6 +868,8 @@ type ConsoleAPI struct {
|
||||
BucketSetBucketRetentionConfigHandler bucket.SetBucketRetentionConfigHandler
|
||||
// BucketSetBucketVersioningHandler sets the operation handler for the set bucket versioning operation
|
||||
BucketSetBucketVersioningHandler bucket.SetBucketVersioningHandler
|
||||
// SupportSetCallHomeStatusHandler sets the operation handler for the set call home status operation
|
||||
SupportSetCallHomeStatusHandler support.SetCallHomeStatusHandler
|
||||
// ConfigurationSetConfigHandler sets the operation handler for the set config operation
|
||||
ConfigurationSetConfigHandler configuration.SetConfigHandler
|
||||
// BucketSetMultiBucketReplicationHandler sets the operation handler for the set multi bucket replication operation
|
||||
@@ -1152,6 +1163,9 @@ func (o *ConsoleAPI) Validate() error {
|
||||
if o.BucketGetBucketVersioningHandler == nil {
|
||||
unregistered = append(unregistered, "bucket.GetBucketVersioningHandler")
|
||||
}
|
||||
if o.SupportGetCallHomeOptionValueHandler == nil {
|
||||
unregistered = append(unregistered, "support.GetCallHomeOptionValueHandler")
|
||||
}
|
||||
if o.IdpGetConfigurationHandler == nil {
|
||||
unregistered = append(unregistered, "idp.GetConfigurationHandler")
|
||||
}
|
||||
@@ -1380,6 +1394,9 @@ func (o *ConsoleAPI) Validate() error {
|
||||
if o.BucketSetBucketVersioningHandler == nil {
|
||||
unregistered = append(unregistered, "bucket.SetBucketVersioningHandler")
|
||||
}
|
||||
if o.SupportSetCallHomeStatusHandler == nil {
|
||||
unregistered = append(unregistered, "support.SetCallHomeStatusHandler")
|
||||
}
|
||||
if o.ConfigurationSetConfigHandler == nil {
|
||||
unregistered = append(unregistered, "configuration.SetConfigHandler")
|
||||
}
|
||||
@@ -1767,6 +1784,10 @@ func (o *ConsoleAPI) initHandlerCache() {
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/support/callhome"] = support.NewGetCallHomeOptionValue(o.context, o.SupportGetCallHomeOptionValueHandler)
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["GET"]["/idp/{type}/{name}"] = idp.NewGetConfiguration(o.context, o.IdpGetConfigurationHandler)
|
||||
if o.handlers["GET"] == nil {
|
||||
o.handlers["GET"] = make(map[string]http.Handler)
|
||||
@@ -2071,6 +2092,10 @@ func (o *ConsoleAPI) initHandlerCache() {
|
||||
if o.handlers["PUT"] == nil {
|
||||
o.handlers["PUT"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["PUT"]["/support/callhome"] = support.NewSetCallHomeStatus(o.context, o.SupportSetCallHomeStatusHandler)
|
||||
if o.handlers["PUT"] == nil {
|
||||
o.handlers["PUT"] = make(map[string]http.Handler)
|
||||
}
|
||||
o.handlers["PUT"]["/configs/{name}"] = configuration.NewSetConfig(o.context, o.ConfigurationSetConfigHandler)
|
||||
if o.handlers["POST"] == nil {
|
||||
o.handlers["POST"] = make(map[string]http.Handler)
|
||||
|
||||
88
restapi/operations/support/get_call_home_option_value.go
Normal file
88
restapi/operations/support/get_call_home_option_value.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) 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 support
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// GetCallHomeOptionValueHandlerFunc turns a function with the right signature into a get call home option value handler
|
||||
type GetCallHomeOptionValueHandlerFunc func(GetCallHomeOptionValueParams, *models.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn GetCallHomeOptionValueHandlerFunc) Handle(params GetCallHomeOptionValueParams, principal *models.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// GetCallHomeOptionValueHandler interface for that can handle valid get call home option value params
|
||||
type GetCallHomeOptionValueHandler interface {
|
||||
Handle(GetCallHomeOptionValueParams, *models.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewGetCallHomeOptionValue creates a new http.Handler for the get call home option value operation
|
||||
func NewGetCallHomeOptionValue(ctx *middleware.Context, handler GetCallHomeOptionValueHandler) *GetCallHomeOptionValue {
|
||||
return &GetCallHomeOptionValue{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*
|
||||
GetCallHomeOptionValue swagger:route GET /support/callhome Support getCallHomeOptionValue
|
||||
|
||||
Get Callhome current status
|
||||
*/
|
||||
type GetCallHomeOptionValue struct {
|
||||
Context *middleware.Context
|
||||
Handler GetCallHomeOptionValueHandler
|
||||
}
|
||||
|
||||
func (o *GetCallHomeOptionValue) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewGetCallHomeOptionValueParams()
|
||||
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,63 @@
|
||||
// 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 support
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// NewGetCallHomeOptionValueParams creates a new GetCallHomeOptionValueParams object
|
||||
//
|
||||
// There are no default values defined in the spec.
|
||||
func NewGetCallHomeOptionValueParams() GetCallHomeOptionValueParams {
|
||||
|
||||
return GetCallHomeOptionValueParams{}
|
||||
}
|
||||
|
||||
// GetCallHomeOptionValueParams contains all the bound params for the get call home option value operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters GetCallHomeOptionValue
|
||||
type GetCallHomeOptionValueParams 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 NewGetCallHomeOptionValueParams() beforehand.
|
||||
func (o *GetCallHomeOptionValueParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
|
||||
var res []error
|
||||
|
||||
o.HTTPRequest = r
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
// 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 support
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// GetCallHomeOptionValueOKCode is the HTTP code returned for type GetCallHomeOptionValueOK
|
||||
const GetCallHomeOptionValueOKCode int = 200
|
||||
|
||||
/*
|
||||
GetCallHomeOptionValueOK A successful response.
|
||||
|
||||
swagger:response getCallHomeOptionValueOK
|
||||
*/
|
||||
type GetCallHomeOptionValueOK struct {
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.CallHomeGetResponse `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewGetCallHomeOptionValueOK creates GetCallHomeOptionValueOK with default headers values
|
||||
func NewGetCallHomeOptionValueOK() *GetCallHomeOptionValueOK {
|
||||
|
||||
return &GetCallHomeOptionValueOK{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the get call home option value o k response
|
||||
func (o *GetCallHomeOptionValueOK) WithPayload(payload *models.CallHomeGetResponse) *GetCallHomeOptionValueOK {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the get call home option value o k response
|
||||
func (o *GetCallHomeOptionValueOK) SetPayload(payload *models.CallHomeGetResponse) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *GetCallHomeOptionValueOK) 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
GetCallHomeOptionValueDefault Generic error response.
|
||||
|
||||
swagger:response getCallHomeOptionValueDefault
|
||||
*/
|
||||
type GetCallHomeOptionValueDefault struct {
|
||||
_statusCode int
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewGetCallHomeOptionValueDefault creates GetCallHomeOptionValueDefault with default headers values
|
||||
func NewGetCallHomeOptionValueDefault(code int) *GetCallHomeOptionValueDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &GetCallHomeOptionValueDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the get call home option value default response
|
||||
func (o *GetCallHomeOptionValueDefault) WithStatusCode(code int) *GetCallHomeOptionValueDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the get call home option value default response
|
||||
func (o *GetCallHomeOptionValueDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the get call home option value default response
|
||||
func (o *GetCallHomeOptionValueDefault) WithPayload(payload *models.Error) *GetCallHomeOptionValueDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the get call home option value default response
|
||||
func (o *GetCallHomeOptionValueDefault) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *GetCallHomeOptionValueDefault) 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,104 @@
|
||||
// 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 support
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// GetCallHomeOptionValueURL generates an URL for the get call home option value operation
|
||||
type GetCallHomeOptionValueURL 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 *GetCallHomeOptionValueURL) WithBasePath(bp string) *GetCallHomeOptionValueURL {
|
||||
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 *GetCallHomeOptionValueURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *GetCallHomeOptionValueURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/support/callhome"
|
||||
|
||||
_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 *GetCallHomeOptionValueURL) 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 *GetCallHomeOptionValueURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *GetCallHomeOptionValueURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on GetCallHomeOptionValueURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on GetCallHomeOptionValueURL")
|
||||
}
|
||||
|
||||
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 *GetCallHomeOptionValueURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
||||
88
restapi/operations/support/set_call_home_status.go
Normal file
88
restapi/operations/support/set_call_home_status.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) 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 support
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// SetCallHomeStatusHandlerFunc turns a function with the right signature into a set call home status handler
|
||||
type SetCallHomeStatusHandlerFunc func(SetCallHomeStatusParams, *models.Principal) middleware.Responder
|
||||
|
||||
// Handle executing the request and returning a response
|
||||
func (fn SetCallHomeStatusHandlerFunc) Handle(params SetCallHomeStatusParams, principal *models.Principal) middleware.Responder {
|
||||
return fn(params, principal)
|
||||
}
|
||||
|
||||
// SetCallHomeStatusHandler interface for that can handle valid set call home status params
|
||||
type SetCallHomeStatusHandler interface {
|
||||
Handle(SetCallHomeStatusParams, *models.Principal) middleware.Responder
|
||||
}
|
||||
|
||||
// NewSetCallHomeStatus creates a new http.Handler for the set call home status operation
|
||||
func NewSetCallHomeStatus(ctx *middleware.Context, handler SetCallHomeStatusHandler) *SetCallHomeStatus {
|
||||
return &SetCallHomeStatus{Context: ctx, Handler: handler}
|
||||
}
|
||||
|
||||
/*
|
||||
SetCallHomeStatus swagger:route PUT /support/callhome Support setCallHomeStatus
|
||||
|
||||
Sets callhome status
|
||||
*/
|
||||
type SetCallHomeStatus struct {
|
||||
Context *middleware.Context
|
||||
Handler SetCallHomeStatusHandler
|
||||
}
|
||||
|
||||
func (o *SetCallHomeStatus) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
||||
route, rCtx, _ := o.Context.RouteInfo(r)
|
||||
if rCtx != nil {
|
||||
*r = *rCtx
|
||||
}
|
||||
var Params = NewSetCallHomeStatusParams()
|
||||
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)
|
||||
|
||||
}
|
||||
101
restapi/operations/support/set_call_home_status_parameters.go
Normal file
101
restapi/operations/support/set_call_home_status_parameters.go
Normal file
@@ -0,0 +1,101 @@
|
||||
// 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 support
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/go-openapi/validate"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
)
|
||||
|
||||
// NewSetCallHomeStatusParams creates a new SetCallHomeStatusParams object
|
||||
//
|
||||
// There are no default values defined in the spec.
|
||||
func NewSetCallHomeStatusParams() SetCallHomeStatusParams {
|
||||
|
||||
return SetCallHomeStatusParams{}
|
||||
}
|
||||
|
||||
// SetCallHomeStatusParams contains all the bound params for the set call home status operation
|
||||
// typically these are obtained from a http.Request
|
||||
//
|
||||
// swagger:parameters SetCallHomeStatus
|
||||
type SetCallHomeStatusParams struct {
|
||||
|
||||
// HTTP Request Object
|
||||
HTTPRequest *http.Request `json:"-"`
|
||||
|
||||
/*
|
||||
Required: true
|
||||
In: body
|
||||
*/
|
||||
Body *models.CallHomeSetStatus
|
||||
}
|
||||
|
||||
// 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 NewSetCallHomeStatusParams() beforehand.
|
||||
func (o *SetCallHomeStatusParams) 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.CallHomeSetStatus
|
||||
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(r.Context())
|
||||
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", ""))
|
||||
}
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
115
restapi/operations/support/set_call_home_status_responses.go
Normal file
115
restapi/operations/support/set_call_home_status_responses.go
Normal file
@@ -0,0 +1,115 @@
|
||||
// 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 support
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// SetCallHomeStatusNoContentCode is the HTTP code returned for type SetCallHomeStatusNoContent
|
||||
const SetCallHomeStatusNoContentCode int = 204
|
||||
|
||||
/*
|
||||
SetCallHomeStatusNoContent A successful response.
|
||||
|
||||
swagger:response setCallHomeStatusNoContent
|
||||
*/
|
||||
type SetCallHomeStatusNoContent struct {
|
||||
}
|
||||
|
||||
// NewSetCallHomeStatusNoContent creates SetCallHomeStatusNoContent with default headers values
|
||||
func NewSetCallHomeStatusNoContent() *SetCallHomeStatusNoContent {
|
||||
|
||||
return &SetCallHomeStatusNoContent{}
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *SetCallHomeStatusNoContent) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
|
||||
|
||||
rw.WriteHeader(204)
|
||||
}
|
||||
|
||||
/*
|
||||
SetCallHomeStatusDefault Generic error response.
|
||||
|
||||
swagger:response setCallHomeStatusDefault
|
||||
*/
|
||||
type SetCallHomeStatusDefault struct {
|
||||
_statusCode int
|
||||
|
||||
/*
|
||||
In: Body
|
||||
*/
|
||||
Payload *models.Error `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewSetCallHomeStatusDefault creates SetCallHomeStatusDefault with default headers values
|
||||
func NewSetCallHomeStatusDefault(code int) *SetCallHomeStatusDefault {
|
||||
if code <= 0 {
|
||||
code = 500
|
||||
}
|
||||
|
||||
return &SetCallHomeStatusDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatusCode adds the status to the set call home status default response
|
||||
func (o *SetCallHomeStatusDefault) WithStatusCode(code int) *SetCallHomeStatusDefault {
|
||||
o._statusCode = code
|
||||
return o
|
||||
}
|
||||
|
||||
// SetStatusCode sets the status to the set call home status default response
|
||||
func (o *SetCallHomeStatusDefault) SetStatusCode(code int) {
|
||||
o._statusCode = code
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the set call home status default response
|
||||
func (o *SetCallHomeStatusDefault) WithPayload(payload *models.Error) *SetCallHomeStatusDefault {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the set call home status default response
|
||||
func (o *SetCallHomeStatusDefault) SetPayload(payload *models.Error) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *SetCallHomeStatusDefault) 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
|
||||
}
|
||||
}
|
||||
}
|
||||
104
restapi/operations/support/set_call_home_status_urlbuilder.go
Normal file
104
restapi/operations/support/set_call_home_status_urlbuilder.go
Normal file
@@ -0,0 +1,104 @@
|
||||
// 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 support
|
||||
|
||||
// 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"
|
||||
)
|
||||
|
||||
// SetCallHomeStatusURL generates an URL for the set call home status operation
|
||||
type SetCallHomeStatusURL 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 *SetCallHomeStatusURL) WithBasePath(bp string) *SetCallHomeStatusURL {
|
||||
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 *SetCallHomeStatusURL) SetBasePath(bp string) {
|
||||
o._basePath = bp
|
||||
}
|
||||
|
||||
// Build a url path and query string
|
||||
func (o *SetCallHomeStatusURL) Build() (*url.URL, error) {
|
||||
var _result url.URL
|
||||
|
||||
var _path = "/support/callhome"
|
||||
|
||||
_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 *SetCallHomeStatusURL) 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 *SetCallHomeStatusURL) String() string {
|
||||
return o.Must(o.Build()).String()
|
||||
}
|
||||
|
||||
// BuildFull builds a full url with scheme, host, path and query string
|
||||
func (o *SetCallHomeStatusURL) BuildFull(scheme, host string) (*url.URL, error) {
|
||||
if scheme == "" {
|
||||
return nil, errors.New("scheme is required for a full url on SetCallHomeStatusURL")
|
||||
}
|
||||
if host == "" {
|
||||
return nil, errors.New("host is required for a full url on SetCallHomeStatusURL")
|
||||
}
|
||||
|
||||
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 *SetCallHomeStatusURL) StringFull(scheme, host string) string {
|
||||
return o.Must(o.BuildFull(scheme, host)).String()
|
||||
}
|
||||
235
restapi/user_support.go
Normal file
235
restapi/user_support.go
Normal file
@@ -0,0 +1,235 @@
|
||||
// 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 restapi
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/minio/console/models"
|
||||
"github.com/minio/console/pkg/subnet"
|
||||
"github.com/minio/console/restapi/operations"
|
||||
"github.com/minio/console/restapi/operations/support"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type ConfigurationSetItem struct {
|
||||
Value string
|
||||
Enable bool
|
||||
}
|
||||
|
||||
func registerSupportHandlers(api *operations.ConsoleAPI) {
|
||||
// callhome handlers
|
||||
api.SupportGetCallHomeOptionValueHandler = support.GetCallHomeOptionValueHandlerFunc(func(params support.GetCallHomeOptionValueParams, session *models.Principal) middleware.Responder {
|
||||
callhomeResp, err := getCallHomeOptionResponse(session, params)
|
||||
if err != nil {
|
||||
return support.NewGetCallHomeOptionValueDefault(int(err.Code)).WithPayload(err)
|
||||
}
|
||||
|
||||
return support.NewGetCallHomeOptionValueOK().WithPayload(callhomeResp)
|
||||
})
|
||||
|
||||
api.SupportSetCallHomeStatusHandler = support.SetCallHomeStatusHandlerFunc(func(params support.SetCallHomeStatusParams, session *models.Principal) middleware.Responder {
|
||||
err := editCallHomeOptionResponse(session, params)
|
||||
if err != nil {
|
||||
return support.NewSetCallHomeStatusDefault(int(err.Code)).WithPayload(err)
|
||||
}
|
||||
|
||||
return support.NewSetCallHomeStatusNoContent()
|
||||
})
|
||||
}
|
||||
|
||||
// getCallHomeOptionResponse returns the selected option value
|
||||
func getCallHomeOptionResponse(session *models.Principal, params support.GetCallHomeOptionValueParams) (*models.CallHomeGetResponse, *models.Error) {
|
||||
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
|
||||
defer cancel()
|
||||
|
||||
mAdmin, err := NewMinioAdminClient(session)
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
|
||||
minioClient := AdminClient{Client: mAdmin}
|
||||
|
||||
response, err := getCallHomeRule(ctx, minioClient)
|
||||
if err != nil {
|
||||
return nil, ErrorWithContext(ctx, err)
|
||||
}
|
||||
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func getCallHomeRule(ctx context.Context, client MinioAdmin) (*models.CallHomeGetResponse, error) {
|
||||
// We verify if callhome SubSys is supported
|
||||
supportedSubSys, err := minioConfigSupportsSubSys(ctx, client, "callhome")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var returnResponse models.CallHomeGetResponse
|
||||
|
||||
// SubSys is not supported, hence callhome is disabled.
|
||||
if !supportedSubSys {
|
||||
returnResponse.DiagnosticsStatus = false
|
||||
returnResponse.LogsStatus = false
|
||||
|
||||
return &returnResponse, nil
|
||||
}
|
||||
|
||||
diagnosticsProps, err := getConfig(ctx, client, "callhome")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
diagnosticsSt := true
|
||||
|
||||
for _, properties := range diagnosticsProps {
|
||||
for _, property := range properties.KeyValues {
|
||||
if property.Key == "enable" {
|
||||
diagnosticsSt = property.Value == "on"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
loggerSt := true
|
||||
|
||||
loggerProps, err := getConfig(ctx, client, "logger_webhook:subnet")
|
||||
|
||||
// Logger not defined, then it is disabled.
|
||||
if err != nil {
|
||||
loggerSt = false
|
||||
} else {
|
||||
for _, logger := range loggerProps {
|
||||
for _, property := range logger.KeyValues {
|
||||
if property.Key == "enable" {
|
||||
loggerSt = property.Value == "on"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
returnModel := models.CallHomeGetResponse{DiagnosticsStatus: diagnosticsSt, LogsStatus: loggerSt}
|
||||
|
||||
return &returnModel, nil
|
||||
}
|
||||
|
||||
// editCallHomeOptionResponse returns if there was an error setting the option
|
||||
func editCallHomeOptionResponse(session *models.Principal, params support.SetCallHomeStatusParams) *models.Error {
|
||||
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
|
||||
defer cancel()
|
||||
|
||||
mAdmin, err := NewMinioAdminClient(session)
|
||||
if err != nil {
|
||||
return ErrorWithContext(ctx, err)
|
||||
}
|
||||
|
||||
minioClient := AdminClient{Client: mAdmin}
|
||||
|
||||
err = setCallHomeConfiguration(ctx, minioClient, *params.Body.DiagState, *params.Body.LogsState)
|
||||
if err != nil {
|
||||
return ErrorWithContext(ctx, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func configureCallHomeDiagnostics(ctx context.Context, client MinioAdmin, diagState bool) error {
|
||||
// We verify if callhome SubSys is supported
|
||||
supportedSubSys, err := minioConfigSupportsSubSys(ctx, client, "callhome")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// SubSys is not supported, hence callhome not available
|
||||
if !supportedSubSys {
|
||||
return errors.New("your version of MinIO doesn't support this configuration")
|
||||
}
|
||||
|
||||
enableStr := "off"
|
||||
if diagState {
|
||||
enableStr = "on"
|
||||
}
|
||||
configStr := "callhome enable=" + enableStr
|
||||
_, err = client.setConfigKV(ctx, configStr)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func configureCallHomeLogs(ctx context.Context, client MinioAdmin, logState bool, apiKey string) error {
|
||||
var configStr string
|
||||
if logState {
|
||||
configStr = fmt.Sprintf("logger_webhook:subnet endpoint=%s auth_token=%s enable=on",
|
||||
subnet.LogWebhookURL(), apiKey)
|
||||
} else {
|
||||
configStr = "logger_webhook:subnet enable=off"
|
||||
}
|
||||
|
||||
// Call set config API
|
||||
_, err := client.setConfigKV(ctx, configStr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func setCallHomeConfiguration(ctx context.Context, client MinioAdmin, diagState, logsState bool) error {
|
||||
tokenConfig, err := GetSubnetKeyFromMinIOConfig(ctx, client)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
apiKey := tokenConfig.APIKey
|
||||
|
||||
if len(apiKey) == 0 {
|
||||
return errors.New("please register this cluster in subnet to continue")
|
||||
}
|
||||
|
||||
err = configureCallHomeDiagnostics(ctx, client, diagState)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = configureCallHomeLogs(ctx, client, logsState, apiKey)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func minioConfigSupportsSubSys(ctx context.Context, client MinioAdmin, subSys string) (bool, error) {
|
||||
help, err := client.helpConfigKVGlobal(ctx, false)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
for _, h := range help.KeysHelp {
|
||||
if h.Key == subSys {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
return false, nil
|
||||
}
|
||||
382
restapi/user_support_test.go
Normal file
382
restapi/user_support_test.go
Normal file
@@ -0,0 +1,382 @@
|
||||
// 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 restapi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/minio/console/models"
|
||||
"github.com/minio/madmin-go/v2"
|
||||
)
|
||||
|
||||
func Test_getCallHomeRule(t *testing.T) {
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
session *models.Principal
|
||||
}
|
||||
ctx := context.Background()
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
helpConfigKVGlobal func(envOnly bool) (madmin.Help, error)
|
||||
helpConfigKV func(subSys, key string, envOnly bool) (madmin.Help, error)
|
||||
getConfigKV func(key string) ([]byte, error)
|
||||
want *models.CallHomeGetResponse
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "subsys is not supported, dont crash / return anything",
|
||||
args: args{
|
||||
ctx: ctx,
|
||||
session: nil,
|
||||
},
|
||||
helpConfigKV: func(subSys, key string, envOnly bool) (madmin.Help, error) {
|
||||
return madmin.Help{}, errors.New("feature is not supported")
|
||||
},
|
||||
getConfigKV: func(key string) ([]byte, error) {
|
||||
return []byte{}, nil
|
||||
},
|
||||
helpConfigKVGlobal: func(envOnly bool) (madmin.Help, error) {
|
||||
return madmin.Help{
|
||||
SubSys: "",
|
||||
Description: "",
|
||||
MultipleTargets: false,
|
||||
KeysHelp: madmin.HelpKVS{},
|
||||
}, nil
|
||||
},
|
||||
want: nil,
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "callhome enabled",
|
||||
args: args{
|
||||
ctx: ctx,
|
||||
session: nil,
|
||||
},
|
||||
helpConfigKVGlobal: func(envOnly bool) (madmin.Help, error) {
|
||||
return madmin.Help{
|
||||
SubSys: "",
|
||||
Description: "",
|
||||
MultipleTargets: false,
|
||||
KeysHelp: madmin.HelpKVS{
|
||||
{Key: "callhome", Description: "enable callhome for the cluster", Optional: true, Type: "string", MultipleTargets: false},
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
helpConfigKV: func(subSys, key string, envOnly bool) (madmin.Help, error) {
|
||||
return madmin.Help{
|
||||
SubSys: "callhome",
|
||||
Description: "enable callhome for the cluster",
|
||||
MultipleTargets: false,
|
||||
KeysHelp: madmin.HelpKVS{
|
||||
{Key: "frequency", Type: "duration", Optional: true, MultipleTargets: false},
|
||||
{Key: "enable", Type: "on|off", Optional: true, MultipleTargets: false},
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
getConfigKV: func(key string) ([]byte, error) {
|
||||
return []byte(`callhome:_ frequency=24h enable=on`), nil
|
||||
},
|
||||
want: &models.CallHomeGetResponse{
|
||||
DiagnosticsStatus: true,
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "callhome is disabled",
|
||||
args: args{
|
||||
ctx: ctx,
|
||||
session: nil,
|
||||
},
|
||||
helpConfigKVGlobal: func(envOnly bool) (madmin.Help, error) {
|
||||
return madmin.Help{
|
||||
SubSys: "",
|
||||
Description: "",
|
||||
MultipleTargets: false,
|
||||
KeysHelp: madmin.HelpKVS{
|
||||
{Key: "callhome", Description: "enable callhome for the cluster", Optional: true, Type: "string", MultipleTargets: false},
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
helpConfigKV: func(subSys, key string, envOnly bool) (madmin.Help, error) {
|
||||
return madmin.Help{
|
||||
SubSys: "callhome",
|
||||
Description: "enable callhome for the cluster",
|
||||
MultipleTargets: false,
|
||||
KeysHelp: madmin.HelpKVS{
|
||||
{Key: "frequency", Type: "duration", Optional: true, MultipleTargets: false},
|
||||
{Key: "enable", Type: "on|off", Optional: true, MultipleTargets: false},
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
getConfigKV: func(key string) ([]byte, error) {
|
||||
return []byte(`callhome:_ frequency=24h enable=off`), nil
|
||||
},
|
||||
want: &models.CallHomeGetResponse{
|
||||
DiagnosticsStatus: false,
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
adminClient := AdminClientMock{}
|
||||
|
||||
minioGetConfigKVMock = tt.getConfigKV
|
||||
minioHelpConfigKVMock = tt.helpConfigKV
|
||||
minioHelpConfigKVGlobalMock = tt.helpConfigKVGlobal
|
||||
|
||||
response, err := getCallHomeRule(tt.args.ctx, adminClient)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("getCallHomeRule() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
if tt.want != nil {
|
||||
if response.DiagnosticsStatus != tt.want.DiagnosticsStatus {
|
||||
t.Errorf("getCallHomeRule() got status = %v, want status %v", response.DiagnosticsStatus, tt.want.DiagnosticsStatus)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_setCallHomeConfiguration(t *testing.T) {
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
session *models.Principal
|
||||
diagState bool
|
||||
}
|
||||
ctx := context.Background()
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
helpConfigKVGlobal func(envOnly bool) (madmin.Help, error)
|
||||
helpConfigKV func(subSys, key string, envOnly bool) (madmin.Help, error)
|
||||
getConfigKV func(key string) ([]byte, error)
|
||||
setConfigEnv func(kv string) (restart bool, err error)
|
||||
wantErr bool
|
||||
error error
|
||||
}{
|
||||
{
|
||||
name: "subsys is not supported, return error",
|
||||
args: args{
|
||||
ctx: ctx,
|
||||
session: nil,
|
||||
diagState: false,
|
||||
},
|
||||
helpConfigKV: func(subSys, key string, envOnly bool) (madmin.Help, error) {
|
||||
return madmin.Help{}, errors.New("feature is not supported")
|
||||
},
|
||||
getConfigKV: func(key string) ([]byte, error) {
|
||||
return []byte{}, nil
|
||||
},
|
||||
helpConfigKVGlobal: func(envOnly bool) (madmin.Help, error) {
|
||||
return madmin.Help{
|
||||
SubSys: "",
|
||||
Description: "",
|
||||
MultipleTargets: false,
|
||||
KeysHelp: madmin.HelpKVS{},
|
||||
}, nil
|
||||
},
|
||||
setConfigEnv: func(kv string) (restart bool, err error) {
|
||||
return false, nil
|
||||
},
|
||||
wantErr: true,
|
||||
error: errors.New("unable to find subnet configuration"),
|
||||
},
|
||||
{
|
||||
name: "cluster not registered",
|
||||
args: args{
|
||||
ctx: ctx,
|
||||
session: nil,
|
||||
diagState: false,
|
||||
},
|
||||
helpConfigKV: func(subSys, key string, envOnly bool) (madmin.Help, error) {
|
||||
return madmin.Help{
|
||||
SubSys: "subnet",
|
||||
Description: "set subnet config for the cluster e.g. api key",
|
||||
MultipleTargets: false,
|
||||
KeysHelp: madmin.HelpKVS{
|
||||
{Key: "license", Type: "string", Optional: true, MultipleTargets: false},
|
||||
{Key: "api_key", Type: "string", Optional: true, MultipleTargets: false},
|
||||
{Key: "proxy", Type: "string", Optional: true, MultipleTargets: false},
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
getConfigKV: func(key string) ([]byte, error) {
|
||||
return []byte(`subnet license= api_key= proxy=http://127.0.0.1 `), nil
|
||||
},
|
||||
helpConfigKVGlobal: func(envOnly bool) (madmin.Help, error) {
|
||||
return madmin.Help{
|
||||
SubSys: "",
|
||||
Description: "",
|
||||
MultipleTargets: false,
|
||||
KeysHelp: madmin.HelpKVS{
|
||||
{Key: "callhome", Description: "enable callhome for the cluster", Optional: true, Type: "string", MultipleTargets: false},
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
setConfigEnv: func(kv string) (restart bool, err error) {
|
||||
return false, nil
|
||||
},
|
||||
wantErr: true,
|
||||
error: errors.New("please register this cluster in subnet to continue"),
|
||||
},
|
||||
{
|
||||
name: "enable without errors",
|
||||
args: args{
|
||||
ctx: ctx,
|
||||
session: nil,
|
||||
diagState: true,
|
||||
},
|
||||
helpConfigKV: func(subSys, key string, envOnly bool) (madmin.Help, error) {
|
||||
return madmin.Help{
|
||||
SubSys: "subnet",
|
||||
Description: "set subnet config for the cluster e.g. api key",
|
||||
MultipleTargets: false,
|
||||
KeysHelp: madmin.HelpKVS{
|
||||
{Key: "license", Type: "string", Optional: true, MultipleTargets: false},
|
||||
{Key: "api_key", Type: "string", Optional: true, MultipleTargets: false},
|
||||
{Key: "proxy", Type: "string", Optional: true, MultipleTargets: false},
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
getConfigKV: func(key string) ([]byte, error) {
|
||||
return []byte(`subnet license= api_key=testAPIKey proxy=http://127.0.0.1 `), nil
|
||||
},
|
||||
helpConfigKVGlobal: func(envOnly bool) (madmin.Help, error) {
|
||||
return madmin.Help{
|
||||
SubSys: "",
|
||||
Description: "",
|
||||
MultipleTargets: false,
|
||||
KeysHelp: madmin.HelpKVS{
|
||||
{Key: "callhome", Description: "enable callhome for the cluster", Optional: true, Type: "string", MultipleTargets: false},
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
setConfigEnv: func(kv string) (restart bool, err error) {
|
||||
return false, nil
|
||||
},
|
||||
wantErr: false,
|
||||
error: nil,
|
||||
},
|
||||
{
|
||||
name: "disable without errors",
|
||||
args: args{
|
||||
ctx: ctx,
|
||||
session: nil,
|
||||
diagState: false,
|
||||
},
|
||||
helpConfigKV: func(subSys, key string, envOnly bool) (madmin.Help, error) {
|
||||
return madmin.Help{
|
||||
SubSys: "subnet",
|
||||
Description: "set subnet config for the cluster e.g. api key",
|
||||
MultipleTargets: false,
|
||||
KeysHelp: madmin.HelpKVS{
|
||||
{Key: "license", Type: "string", Optional: true, MultipleTargets: false},
|
||||
{Key: "api_key", Type: "string", Optional: true, MultipleTargets: false},
|
||||
{Key: "proxy", Type: "string", Optional: true, MultipleTargets: false},
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
getConfigKV: func(key string) ([]byte, error) {
|
||||
return []byte(`subnet license= api_key=testAPIKey proxy=http://127.0.0.1 `), nil
|
||||
},
|
||||
helpConfigKVGlobal: func(envOnly bool) (madmin.Help, error) {
|
||||
return madmin.Help{
|
||||
SubSys: "",
|
||||
Description: "",
|
||||
MultipleTargets: false,
|
||||
KeysHelp: madmin.HelpKVS{
|
||||
{Key: "callhome", Description: "enable callhome for the cluster", Optional: true, Type: "string", MultipleTargets: false},
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
setConfigEnv: func(kv string) (restart bool, err error) {
|
||||
return false, nil
|
||||
},
|
||||
wantErr: false,
|
||||
error: nil,
|
||||
},
|
||||
{
|
||||
name: "Error setting diagState",
|
||||
args: args{
|
||||
ctx: ctx,
|
||||
session: nil,
|
||||
diagState: false,
|
||||
},
|
||||
helpConfigKV: func(subSys, key string, envOnly bool) (madmin.Help, error) {
|
||||
return madmin.Help{
|
||||
SubSys: "subnet",
|
||||
Description: "set subnet config for the cluster e.g. api key",
|
||||
MultipleTargets: false,
|
||||
KeysHelp: madmin.HelpKVS{
|
||||
{Key: "license", Type: "string", Optional: true, MultipleTargets: false},
|
||||
{Key: "api_key", Type: "string", Optional: true, MultipleTargets: false},
|
||||
{Key: "proxy", Type: "string", Optional: true, MultipleTargets: false},
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
getConfigKV: func(key string) ([]byte, error) {
|
||||
return []byte(`subnet license= api_key=testAPIKey proxy=http://127.0.0.1 `), nil
|
||||
},
|
||||
helpConfigKVGlobal: func(envOnly bool) (madmin.Help, error) {
|
||||
return madmin.Help{
|
||||
SubSys: "",
|
||||
Description: "",
|
||||
MultipleTargets: false,
|
||||
KeysHelp: madmin.HelpKVS{
|
||||
{Key: "callhome", Description: "enable callhome for the cluster", Optional: true, Type: "string", MultipleTargets: false},
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
setConfigEnv: func(kv string) (restart bool, err error) {
|
||||
return false, errors.New("new error detected")
|
||||
},
|
||||
wantErr: true,
|
||||
error: errors.New("new error detected"),
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
adminClient := AdminClientMock{}
|
||||
|
||||
minioGetConfigKVMock = tt.getConfigKV
|
||||
minioHelpConfigKVMock = tt.helpConfigKV
|
||||
minioHelpConfigKVGlobalMock = tt.helpConfigKVGlobal
|
||||
minioSetConfigKVMock = tt.setConfigEnv
|
||||
|
||||
err := setCallHomeConfiguration(tt.args.ctx, adminClient, tt.args.diagState, false)
|
||||
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("setCallHomeConfiguration() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
|
||||
if tt.wantErr {
|
||||
if tt.error.Error() != err.Error() {
|
||||
t.Errorf("setCallHomeConfiguration() error mismatch, error = %v, wantErr %v", err.Error(), tt.error.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user