| 
									
										
										
										
											2017-03-17 03:21:58 +08:00
										 |  |  | /* | 
					
						
							| 
									
										
										
										
											2019-04-10 02:39:42 +08:00
										 |  |  |  * MinIO Cloud Storage, (C) 2016, 2017 MinIO, Inc. | 
					
						
							| 
									
										
										
										
											2017-03-17 03:21:58 +08:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Licensed under the Apache License, Version 2.0 (the "License"); | 
					
						
							|  |  |  |  * you may not use this file except in compliance with the License. | 
					
						
							|  |  |  |  * You may obtain a copy of the License at | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  *     http://www.apache.org/licenses/LICENSE-2.0
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Unless required by applicable law or agreed to in writing, software | 
					
						
							|  |  |  |  * distributed under the License is distributed on an "AS IS" BASIS, | 
					
						
							|  |  |  |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
					
						
							|  |  |  |  * See the License for the specific language governing permissions and | 
					
						
							|  |  |  |  * limitations under the License. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | package cmd | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"fmt" | 
					
						
							|  |  |  | 	"strings" | 
					
						
							| 
									
										
										
										
											2019-10-05 01:35:33 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	"github.com/minio/minio/pkg/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) { | 
					
						
							| 
									
										
										
										
											2017-06-10 10:50:51 +08:00
										 |  |  | 	strippedAPIEndpoints := stripStandardPorts(apiEndPoints) | 
					
						
							| 
									
										
										
										
											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() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// SSL is configured reads certification chain, prints
 | 
					
						
							|  |  |  | 	// authority and expiry.
 | 
					
						
							| 
									
										
										
										
											2020-05-01 07:15:29 +08:00
										 |  |  | 	if color.IsTerminal() && !globalCLIContext.Anonymous { | 
					
						
							| 
									
										
										
										
											2020-12-22 13:42:38 +08:00
										 |  |  | 		if globalIsTLS { | 
					
						
							| 
									
										
										
										
											2020-05-01 07:15:29 +08:00
										 |  |  | 			printCertificateMsg(globalPublicCerts) | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											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-01-07 02:38:07 +08:00
										 |  |  | 	logStartupMessage(color.Blue("Endpoint: ") + 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() | 
					
						
							| 
									
										
										
										
											2017-06-10 10:50:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-23 13:59:13 +08:00
										 |  |  | 	if globalBrowserEnabled { | 
					
						
							| 
									
										
										
										
											2019-10-05 01:35:33 +08:00
										 |  |  | 		logStartupMessage(color.Blue("\nBrowser Access:")) | 
					
						
							| 
									
										
										
										
											2019-09-22 16:24:32 +08:00
										 |  |  | 		logStartupMessage(fmt.Sprintf(getFormatStr(len(apiEndpointStr), 3), apiEndpointStr)) | 
					
						
							| 
									
										
										
										
											2018-01-04 13:30:52 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-03-17 03:21:58 +08:00
										 |  |  | } |