github.com/minio/mc@v0.0.0-20240503112107-b471de8d1882/cmd/support-proxy-remove.go (about) 1 // Copyright (c) 2015-2022 MinIO, Inc. 2 // 3 // This file is part of MinIO Object Storage stack 4 // 5 // This program is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU Affero General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU Affero General Public License for more details. 14 // 15 // You should have received a copy of the GNU Affero General Public License 16 // along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18 package cmd 19 20 import ( 21 "github.com/minio/cli" 22 "github.com/minio/mc/pkg/probe" 23 "github.com/minio/pkg/v2/console" 24 ) 25 26 type supportProxyRemoveMessage struct { 27 Status string `json:"status"` 28 } 29 30 // String colorized proxy remove message 31 func (s supportProxyRemoveMessage) String() string { 32 return console.Colorize(supportSuccessMsgTag, "Proxy has been removed") 33 } 34 35 // JSON jsonified proxy remove message 36 func (s supportProxyRemoveMessage) JSON() string { 37 s.Status = "success" 38 return toJSON(s) 39 } 40 41 var supportProxyRemoveCmd = cli.Command{ 42 Name: "remove", 43 Usage: "Remove proxy configuration", 44 Action: mainSupportProxyRemove, 45 OnUsageError: onUsageError, 46 Before: setGlobalsFromContext, 47 Flags: globalFlags, 48 HideHelpCommand: true, 49 CustomHelpTemplate: `NAME: 50 {{.HelpName}} - {{.Usage}} 51 52 USAGE: 53 {{.HelpName}} [FLAGS] TARGET 54 55 FLAGS: 56 {{range .VisibleFlags}}{{.}} 57 {{end}} 58 EXAMPLES: 59 1. Remove the proxy configured for cluster with alias 'myminio' 60 {{.Prompt}} {{.HelpName}} myminio 61 `, 62 } 63 64 func checkSupportProxyRemoveSyntax(ctx *cli.Context) { 65 if len(ctx.Args()) != 1 { 66 showCommandHelpAndExit(ctx, 1) // last argument is exit code 67 } 68 } 69 70 // mainSupportProxyRemove is the handler for "mc support proxy remove" command. 71 func mainSupportProxyRemove(ctx *cli.Context) error { 72 // Check for command syntax 73 checkSupportProxyRemoveSyntax(ctx) 74 setSuccessMessageColor() 75 76 // Get the alias parameter from cli 77 args := ctx.Args() 78 aliasedURL := args.Get(0) 79 alias, _ := url2Alias(aliasedURL) 80 81 validateClusterRegistered(alias, false) 82 83 // Create a new MinIO Admin Client 84 client := getClient(aliasedURL) 85 86 // Main execution 87 _, e := client.DelConfigKV(globalContext, "subnet proxy") 88 fatalIf(probe.NewError(e), "Unable to remove proxy:") 89 90 printMsg(supportProxyRemoveMessage{}) 91 return nil 92 }