mirror of
https://github.com/minio/minio.git
synced 2025-01-11 23:13:23 -05:00
Bring nicer ui error if creds are missing in Gateway (#6003)
This commit is contained in:
parent
69b9d6fbee
commit
537fd8c821
@ -18,7 +18,6 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
@ -151,10 +150,7 @@ func StartGateway(ctx *cli.Context, gw Gateway) {
|
|||||||
|
|
||||||
// Validate if we have access, secret set through environment.
|
// Validate if we have access, secret set through environment.
|
||||||
if !globalIsEnvCreds {
|
if !globalIsEnvCreds {
|
||||||
reqInfo := (&logger.ReqInfo{}).AppendTags("gatewayName", gatewayName)
|
logger.Fatal(uiErrEnvCredentialsMissing(nil), "Unable to start gateway")
|
||||||
contxt := logger.SetReqInfo(context.Background(), reqInfo)
|
|
||||||
logger.LogIf(contxt, errors.New("Access and Secret keys should be set through ENVs for backend"))
|
|
||||||
cli.ShowCommandHelpAndExit(ctx, gatewayName, 1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create certs path.
|
// Create certs path.
|
||||||
|
@ -85,17 +85,16 @@ EXAMPLES:
|
|||||||
// Handler for 'minio gateway nas' command line.
|
// Handler for 'minio gateway nas' command line.
|
||||||
func nasGatewayMain(ctx *cli.Context) {
|
func nasGatewayMain(ctx *cli.Context) {
|
||||||
// Validate gateway arguments.
|
// Validate gateway arguments.
|
||||||
host := ctx.Args().First()
|
if !ctx.Args().Present() || ctx.Args().First() == "help" {
|
||||||
if host == "help" {
|
|
||||||
cli.ShowCommandHelpAndExit(ctx, nasBackend, 1)
|
cli.ShowCommandHelpAndExit(ctx, nasBackend, 1)
|
||||||
}
|
}
|
||||||
// Validate gateway arguments.
|
|
||||||
minio.StartGateway(ctx, &NAS{host})
|
minio.StartGateway(ctx, &NAS{ctx.Args().First()})
|
||||||
}
|
}
|
||||||
|
|
||||||
// NAS implements Gateway.
|
// NAS implements Gateway.
|
||||||
type NAS struct {
|
type NAS struct {
|
||||||
host string
|
path string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Name implements Gateway interface.
|
// Name implements Gateway interface.
|
||||||
@ -106,7 +105,7 @@ func (g *NAS) Name() string {
|
|||||||
// NewGatewayLayer returns nas gatewaylayer.
|
// NewGatewayLayer returns nas gatewaylayer.
|
||||||
func (g *NAS) NewGatewayLayer(creds auth.Credentials) (minio.ObjectLayer, error) {
|
func (g *NAS) NewGatewayLayer(creds auth.Credentials) (minio.ObjectLayer, error) {
|
||||||
var err error
|
var err error
|
||||||
newObject, err := minio.NewFSObjectLayer(g.host)
|
newObject, err := minio.NewFSObjectLayer(g.path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,12 @@ var (
|
|||||||
Secret key should be in between 8 and 40 characters.`,
|
Secret key should be in between 8 and 40 characters.`,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
uiErrEnvCredentialsMissing = newUIErrFn(
|
||||||
|
"Credentials missing",
|
||||||
|
"Please provide correct credentials",
|
||||||
|
`Access key and Secret key should be specified in Gateway mode from environment variables MINIO_ACCESS_KEY and MINIO_SECRET_KEY respectively.`,
|
||||||
|
)
|
||||||
|
|
||||||
uiErrInvalidErasureEndpoints = newUIErrFn(
|
uiErrInvalidErasureEndpoints = newUIErrFn(
|
||||||
"Invalid endpoint(s) in erasure mode",
|
"Invalid endpoint(s) in erasure mode",
|
||||||
"Please provide correct combination of local/remote paths",
|
"Please provide correct combination of local/remote paths",
|
||||||
|
Loading…
Reference in New Issue
Block a user