| 
									
										
										
										
											2021-04-19 03:41:13 +08:00
										 |  |  | // Copyright (c) 2015-2021 MinIO, Inc.
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // This file is part of MinIO Object Storage stack
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | // 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/>.
 | 
					
						
							| 
									
										
										
										
											2017-03-17 03:21:58 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | package cmd | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"fmt" | 
					
						
							|  |  |  | 	"strings" | 
					
						
							| 
									
										
										
										
											2019-10-05 01:35:33 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-02 05:59:40 +08:00
										 |  |  | 	"github.com/minio/minio/internal/color" | 
					
						
							| 
									
										
										
										
											2017-03-17 03:21:58 +08:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Prints the formatted startup message.
 | 
					
						
							| 
									
										
										
										
											2017-10-28 06:07:46 +08:00
										 |  |  | func printGatewayStartupMessage(apiEndPoints []string, backendType string) { | 
					
						
							| 
									
										
										
										
											2021-06-21 14:04:47 +08:00
										 |  |  | 	strippedAPIEndpoints := stripStandardPorts(apiEndPoints, globalMinioHost) | 
					
						
							| 
									
										
										
										
											2018-03-29 05:14:06 +08:00
										 |  |  | 	// If cache layer is enabled, print cache capacity.
 | 
					
						
							| 
									
										
										
										
											2019-11-10 01:27:23 +08:00
										 |  |  | 	cacheAPI := newCachedObjectLayerFn() | 
					
						
							|  |  |  | 	if cacheAPI != nil { | 
					
						
							| 
									
										
										
										
											2020-04-10 00:30:02 +08:00
										 |  |  | 		printCacheStorageInfo(cacheAPI.StorageInfo(GlobalContext)) | 
					
						
							| 
									
										
										
										
											2018-03-29 05:14:06 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-03-17 03:21:58 +08:00
										 |  |  | 	// Prints credential.
 | 
					
						
							| 
									
										
										
										
											2017-06-10 10:50:51 +08:00
										 |  |  | 	printGatewayCommonMsg(strippedAPIEndpoints) | 
					
						
							| 
									
										
										
										
											2017-03-17 03:21:58 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Prints `mc` cli configuration message chooses
 | 
					
						
							|  |  |  | 	// first endpoint as default.
 | 
					
						
							| 
									
										
										
										
											2017-06-10 10:50:51 +08:00
										 |  |  | 	printCLIAccessMsg(strippedAPIEndpoints[0], fmt.Sprintf("my%s", backendType)) | 
					
						
							| 
									
										
										
										
											2017-03-17 03:21:58 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Prints documentation message.
 | 
					
						
							|  |  |  | 	printObjectAPIMsg() | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-18 11:27:04 +08:00
										 |  |  | 	if globalMinioConsolePortAuto && globalBrowserEnabled { | 
					
						
							|  |  |  | 		msg := fmt.Sprintf("\nWARNING: Console endpoint is listening on a dynamic port (%s), please use --console-address \":PORT\" to choose a static port.", | 
					
						
							|  |  |  | 			globalMinioConsolePort) | 
					
						
							|  |  |  | 		logStartupMessage(color.RedBold(msg)) | 
					
						
							| 
									
										
										
										
											2017-03-17 03:21:58 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Prints common server startup message. Prints credential, region and browser access.
 | 
					
						
							| 
									
										
										
										
											2017-06-10 10:50:51 +08:00
										 |  |  | func printGatewayCommonMsg(apiEndpoints []string) { | 
					
						
							|  |  |  | 	// Get saved credentials.
 | 
					
						
							| 
									
										
										
										
											2019-10-23 13:59:13 +08:00
										 |  |  | 	cred := globalActiveCred | 
					
						
							| 
									
										
										
										
											2017-06-10 10:50:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-17 03:21:58 +08:00
										 |  |  | 	apiEndpointStr := strings.Join(apiEndpoints, "  ") | 
					
						
							| 
									
										
										
										
											2018-12-19 00:26:30 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-17 03:21:58 +08:00
										 |  |  | 	// Colorize the message and print.
 | 
					
						
							| 
									
										
										
										
											2021-06-18 11:27:04 +08:00
										 |  |  | 	logStartupMessage(color.Blue("API: ") + color.Bold(fmt.Sprintf("%s ", apiEndpointStr))) | 
					
						
							| 
									
										
										
										
											2019-10-05 01:35:33 +08:00
										 |  |  | 	if color.IsTerminal() && !globalCLIContext.Anonymous { | 
					
						
							| 
									
										
										
										
											2021-01-06 02:22:57 +08:00
										 |  |  | 		logStartupMessage(color.Blue("RootUser: ") + color.Bold(fmt.Sprintf("%s ", cred.AccessKey))) | 
					
						
							| 
									
										
										
										
											2021-01-07 02:38:07 +08:00
										 |  |  | 		logStartupMessage(color.Blue("RootPass: ") + color.Bold(fmt.Sprintf("%s ", cred.SecretKey))) | 
					
						
							| 
									
										
										
										
											2018-10-17 04:19:12 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-12-03 16:32:14 +08:00
										 |  |  | 	printEventNotifiers() | 
					
						
							| 
									
										
										
										
											2021-04-30 10:01:43 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if globalBrowserEnabled { | 
					
						
							| 
									
										
										
										
											2021-06-21 14:04:47 +08:00
										 |  |  | 		consoleEndpointStr := strings.Join(stripStandardPorts(getConsoleEndpoints(), globalMinioConsoleHost), " ") | 
					
						
							| 
									
										
										
										
											2021-06-18 11:27:04 +08:00
										 |  |  | 		logStartupMessage(color.Blue("\nConsole: ") + color.Bold(fmt.Sprintf("%s ", consoleEndpointStr))) | 
					
						
							|  |  |  | 		if color.IsTerminal() && !globalCLIContext.Anonymous { | 
					
						
							|  |  |  | 			logStartupMessage(color.Blue("RootUser: ") + color.Bold(fmt.Sprintf("%s ", cred.AccessKey))) | 
					
						
							|  |  |  | 			logStartupMessage(color.Blue("RootPass: ") + color.Bold(fmt.Sprintf("%s ", cred.SecretKey))) | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2021-04-30 10:01:43 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-03-17 03:21:58 +08:00
										 |  |  | } |