Use constants for gateway names to avoid bugs caused by spelling. (#10355)

This commit is contained in:
飞雪无情
2020-08-26 23:52:46 +08:00
committed by GitHub
parent ea5094e842
commit ea1803417f
9 changed files with 31 additions and 37 deletions

View File

@@ -24,10 +24,6 @@ import (
"github.com/minio/minio/pkg/auth"
)
const (
nasBackend = "nas"
)
func init() {
const nasGatewayTemplate = `NAME:
{{.HelpName}} - {{.Usage}}
@@ -61,7 +57,7 @@ EXAMPLES:
`
minio.RegisterGatewayCommand(cli.Command{
Name: nasBackend,
Name: minio.NASBackendGateway,
Usage: "Network-attached storage (NAS)",
Action: nasGatewayMain,
CustomHelpTemplate: nasGatewayTemplate,
@@ -73,7 +69,7 @@ EXAMPLES:
func nasGatewayMain(ctx *cli.Context) {
// Validate gateway arguments.
if !ctx.Args().Present() || ctx.Args().First() == "help" {
cli.ShowCommandHelpAndExit(ctx, nasBackend, 1)
cli.ShowCommandHelpAndExit(ctx, minio.NASBackendGateway, 1)
}
minio.StartGateway(ctx, &NAS{ctx.Args().First()})
@@ -86,7 +82,7 @@ type NAS struct {
// Name implements Gateway interface.
func (g *NAS) Name() string {
return nasBackend
return minio.NASBackendGateway
}
// NewGatewayLayer returns nas gatewaylayer.