| 
									
										
										
										
											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 ( | 
					
						
							| 
									
										
										
										
											2018-03-29 05:14:06 +08:00
										 |  |  | 	"context" | 
					
						
							| 
									
										
										
										
											2017-03-17 03:21:58 +08:00
										 |  |  | 	"fmt" | 
					
						
							|  |  |  | 	"strings" | 
					
						
							| 
									
										
										
										
											2018-04-06 06:04:40 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	"github.com/minio/minio/cmd/logger" | 
					
						
							| 
									
										
										
										
											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.
 | 
					
						
							|  |  |  | 	cacheObjectAPI := newCacheObjectsFn() | 
					
						
							|  |  |  | 	if cacheObjectAPI != nil { | 
					
						
							|  |  |  | 		printCacheStorageInfo(cacheObjectAPI.StorageInfo(context.Background())) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											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.
 | 
					
						
							|  |  |  | 	if globalIsSSL { | 
					
						
							| 
									
										
										
										
											2017-03-31 02:21:19 +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.
 | 
					
						
							| 
									
										
										
										
											2017-11-30 05:12:47 +08:00
										 |  |  | 	cred := globalServerConfig.GetCredential() | 
					
						
							| 
									
										
										
										
											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.
 | 
					
						
							| 
									
										
										
										
											2018-12-19 00:26:30 +08:00
										 |  |  | 	logger.StartupMessage(colorBlue("Endpoint: ") + colorBold(fmt.Sprintf(getFormatStr(len(apiEndpointStr), 1), apiEndpointStr))) | 
					
						
							| 
									
										
										
										
											2018-12-19 08:08:11 +08:00
										 |  |  | 	if isTerminal() && !globalCLIContext.Anonymous { | 
					
						
							| 
									
										
										
										
											2018-10-17 04:19:12 +08:00
										 |  |  | 		logger.StartupMessage(colorBlue("AccessKey: ") + colorBold(fmt.Sprintf("%s ", cred.AccessKey))) | 
					
						
							|  |  |  | 		logger.StartupMessage(colorBlue("SecretKey: ") + colorBold(fmt.Sprintf("%s ", cred.SecretKey))) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-12-03 16:32:14 +08:00
										 |  |  | 	printEventNotifiers() | 
					
						
							| 
									
										
										
										
											2017-06-10 10:50:51 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-04 13:30:52 +08:00
										 |  |  | 	if globalIsBrowserEnabled { | 
					
						
							| 
									
										
										
										
											2018-04-11 00:37:14 +08:00
										 |  |  | 		logger.StartupMessage(colorBlue("\nBrowser Access:")) | 
					
						
							|  |  |  | 		logger.StartupMessage(fmt.Sprintf(getFormatStr(len(apiEndpointStr), 3), apiEndpointStr)) | 
					
						
							| 
									
										
										
										
											2018-01-04 13:30:52 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-03-17 03:21:58 +08:00
										 |  |  | } |