mirror of
https://github.com/minio/minio.git
synced 2025-11-12 23:01:39 -05:00
Implement backblaze-b2 gateway support (#5002)
Fixes https://github.com/minio/minio/issues/4072
This commit is contained in:
committed by
Nitish Tiwari
parent
3d0dced23c
commit
0c0d1e4150
@@ -125,6 +125,31 @@ EXAMPLES:
|
||||
|
||||
`
|
||||
|
||||
const b2GatewayTemplate = `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} {{if .VisibleFlags}}[FLAGS]{{end}}
|
||||
{{if .VisibleFlags}}
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}{{end}}
|
||||
ENVIRONMENT VARIABLES:
|
||||
ACCESS:
|
||||
MINIO_ACCESS_KEY: B2 account id.
|
||||
MINIO_SECRET_KEY: B2 application key.
|
||||
|
||||
BROWSER:
|
||||
MINIO_BROWSER: To disable web browser access, set this value to "off".
|
||||
|
||||
EXAMPLES:
|
||||
1. Start minio gateway server for B2 backend.
|
||||
$ export MINIO_ACCESS_KEY=accountID
|
||||
$ export MINIO_SECRET_KEY=applicationKey
|
||||
$ {{.HelpName}}
|
||||
|
||||
`
|
||||
|
||||
var (
|
||||
azureBackendCmd = cli.Command{
|
||||
Name: "azure",
|
||||
@@ -143,6 +168,7 @@ var (
|
||||
Flags: append(serverFlags, globalFlags...),
|
||||
HideHelpCommand: true,
|
||||
}
|
||||
|
||||
gcsBackendCmd = cli.Command{
|
||||
Name: "gcs",
|
||||
Usage: "Google Cloud Storage.",
|
||||
@@ -152,12 +178,21 @@ var (
|
||||
HideHelpCommand: true,
|
||||
}
|
||||
|
||||
b2BackendCmd = cli.Command{
|
||||
Name: "b2",
|
||||
Usage: "Backblaze B2.",
|
||||
Action: b2GatewayMain,
|
||||
CustomHelpTemplate: b2GatewayTemplate,
|
||||
Flags: append(serverFlags, globalFlags...),
|
||||
HideHelpCommand: true,
|
||||
}
|
||||
|
||||
gatewayCmd = cli.Command{
|
||||
Name: "gateway",
|
||||
Usage: "Start object storage gateway.",
|
||||
Flags: append(serverFlags, globalFlags...),
|
||||
HideHelpCommand: true,
|
||||
Subcommands: []cli.Command{azureBackendCmd, s3BackendCmd, gcsBackendCmd},
|
||||
Subcommands: []cli.Command{azureBackendCmd, s3BackendCmd, gcsBackendCmd, b2BackendCmd},
|
||||
}
|
||||
)
|
||||
|
||||
@@ -168,6 +203,7 @@ const (
|
||||
azureBackend gatewayBackend = "azure"
|
||||
s3Backend gatewayBackend = "s3"
|
||||
gcsBackend gatewayBackend = "gcs"
|
||||
b2Backend gatewayBackend = "b2"
|
||||
// Add more backends here.
|
||||
)
|
||||
|
||||
@@ -177,6 +213,7 @@ const (
|
||||
// - Azure Blob Storage.
|
||||
// - AWS S3.
|
||||
// - Google Cloud Storage.
|
||||
// - Backblaze B2.
|
||||
// - Add your favorite backend here.
|
||||
func newGatewayLayer(backendType gatewayBackend, arg string) (GatewayLayer, error) {
|
||||
switch backendType {
|
||||
@@ -189,6 +226,11 @@ func newGatewayLayer(backendType gatewayBackend, arg string) (GatewayLayer, erro
|
||||
// will be removed when gcs is ready for production use.
|
||||
log.Println(colorYellow("\n *** Warning: Not Ready for Production ***"))
|
||||
return newGCSGateway(arg)
|
||||
case b2Backend:
|
||||
// FIXME: The following print command is temporary and
|
||||
// will be removed when B2 is ready for production use.
|
||||
log.Println(colorYellow("\n *** Warning: Not Ready for Production ***"))
|
||||
return newB2Gateway()
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("Unrecognized backend type %s", backendType)
|
||||
@@ -285,6 +327,17 @@ func gcsGatewayMain(ctx *cli.Context) {
|
||||
gatewayMain(ctx, gcsBackend)
|
||||
}
|
||||
|
||||
func b2GatewayMain(ctx *cli.Context) {
|
||||
if ctx.Args().Present() && ctx.Args().First() == "help" {
|
||||
cli.ShowCommandHelpAndExit(ctx, "b2", 1)
|
||||
}
|
||||
|
||||
// Validate gateway arguments.
|
||||
fatalIf(validateGatewayArguments(ctx.GlobalString("address"), ctx.Args().First()), "Invalid argument")
|
||||
|
||||
gatewayMain(ctx, b2Backend)
|
||||
}
|
||||
|
||||
// Handler for 'minio gateway'.
|
||||
func gatewayMain(ctx *cli.Context, backendType gatewayBackend) {
|
||||
// Get quiet flag from command line argument.
|
||||
@@ -393,6 +446,8 @@ func gatewayMain(ctx *cli.Context, backendType gatewayBackend) {
|
||||
mode = globalMinioModeGatewayGCS
|
||||
case s3Backend:
|
||||
mode = globalMinioModeGatewayS3
|
||||
case b2Backend:
|
||||
mode = globalMinioModeGatewayB2
|
||||
}
|
||||
|
||||
// Check update mode.
|
||||
|
||||
Reference in New Issue
Block a user