|
|
@ -28,23 +28,22 @@ import ( |
|
|
|
"github.com/minio/cli" |
|
|
|
"github.com/minio/cli" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
var gatewayTemplate = `NAME: |
|
|
|
const azureGatewayTemplate = `NAME: |
|
|
|
{{.HelpName}} - {{.Usage}} |
|
|
|
{{.HelpName}} - {{.Usage}} |
|
|
|
|
|
|
|
|
|
|
|
USAGE: |
|
|
|
USAGE: |
|
|
|
{{.HelpName}} {{if .VisibleFlags}}[FLAGS]{{end}} BACKEND [ENDPOINT] |
|
|
|
{{.HelpName}} {{if .VisibleFlags}}[FLAGS]{{end}} [ENDPOINT] |
|
|
|
{{if .VisibleFlags}} |
|
|
|
{{if .VisibleFlags}} |
|
|
|
FLAGS: |
|
|
|
FLAGS: |
|
|
|
{{range .VisibleFlags}}{{.}} |
|
|
|
{{range .VisibleFlags}}{{.}} |
|
|
|
{{end}}{{end}} |
|
|
|
{{end}}{{end}} |
|
|
|
BACKEND: |
|
|
|
ENDPOINT: |
|
|
|
azure: Microsoft Azure Blob Storage. Default ENDPOINT is https://core.windows.net
|
|
|
|
Azure server endpoint. Default ENDPOINT is https://core.windows.net
|
|
|
|
s3: Amazon Simple Storage Service (S3). Default ENDPOINT is https://s3.amazonaws.com
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ENVIRONMENT VARIABLES: |
|
|
|
ENVIRONMENT VARIABLES: |
|
|
|
ACCESS: |
|
|
|
ACCESS: |
|
|
|
MINIO_ACCESS_KEY: Username or access key of your storage backend. |
|
|
|
MINIO_ACCESS_KEY: Username or access key of Azure storage. |
|
|
|
MINIO_SECRET_KEY: Password or secret key of your storage backend. |
|
|
|
MINIO_SECRET_KEY: Password or secret key of Azure storage. |
|
|
|
|
|
|
|
|
|
|
|
BROWSER: |
|
|
|
BROWSER: |
|
|
|
MINIO_BROWSER: To disable web browser access, set this value to "off". |
|
|
|
MINIO_BROWSER: To disable web browser access, set this value to "off". |
|
|
@ -53,24 +52,64 @@ EXAMPLES: |
|
|
|
1. Start minio gateway server for Azure Blob Storage backend. |
|
|
|
1. Start minio gateway server for Azure Blob Storage backend. |
|
|
|
$ export MINIO_ACCESS_KEY=azureaccountname |
|
|
|
$ export MINIO_ACCESS_KEY=azureaccountname |
|
|
|
$ export MINIO_SECRET_KEY=azureaccountkey |
|
|
|
$ export MINIO_SECRET_KEY=azureaccountkey |
|
|
|
$ {{.HelpName}} azure |
|
|
|
$ {{.HelpName}} |
|
|
|
|
|
|
|
2. Start minio gateway server for Azure Blob Storage backend on custom endpoint. |
|
|
|
|
|
|
|
$ export MINIO_ACCESS_KEY=azureaccountname |
|
|
|
|
|
|
|
$ export MINIO_SECRET_KEY=azureaccountkey |
|
|
|
|
|
|
|
$ {{.HelpName}} https://azure.example.com
|
|
|
|
|
|
|
|
` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var azureBackendCmd = cli.Command{ |
|
|
|
|
|
|
|
Name: "azure", |
|
|
|
|
|
|
|
Usage: "Microsoft Azure Blob Storage.", |
|
|
|
|
|
|
|
Action: azureGatewayMain, |
|
|
|
|
|
|
|
CustomHelpTemplate: azureGatewayTemplate, |
|
|
|
|
|
|
|
Flags: append(serverFlags, |
|
|
|
|
|
|
|
cli.BoolFlag{ |
|
|
|
|
|
|
|
Name: "quiet", |
|
|
|
|
|
|
|
Usage: "Disable startup banner.", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
HideHelpCommand: true, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const s3GatewayTemplate = `NAME: |
|
|
|
|
|
|
|
{{.HelpName}} - {{.Usage}} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
USAGE: |
|
|
|
|
|
|
|
{{.HelpName}} {{if .VisibleFlags}}[FLAGS]{{end}} [ENDPOINT] |
|
|
|
|
|
|
|
{{if .VisibleFlags}} |
|
|
|
|
|
|
|
FLAGS: |
|
|
|
|
|
|
|
{{range .VisibleFlags}}{{.}} |
|
|
|
|
|
|
|
{{end}}{{end}} |
|
|
|
|
|
|
|
ENDPOINT: |
|
|
|
|
|
|
|
S3 server endpoint. Default ENDPOINT is https://s3.amazonaws.com
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ENVIRONMENT VARIABLES: |
|
|
|
|
|
|
|
ACCESS: |
|
|
|
|
|
|
|
MINIO_ACCESS_KEY: Username or access key of S3 storage. |
|
|
|
|
|
|
|
MINIO_SECRET_KEY: Password or secret key of S3 storage. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BROWSER: |
|
|
|
|
|
|
|
MINIO_BROWSER: To disable web browser access, set this value to "off". |
|
|
|
|
|
|
|
|
|
|
|
2. Start minio gateway server for AWS S3 backend. |
|
|
|
EXAMPLES: |
|
|
|
|
|
|
|
1. Start minio gateway server for AWS S3 backend. |
|
|
|
$ export MINIO_ACCESS_KEY=accesskey |
|
|
|
$ export MINIO_ACCESS_KEY=accesskey |
|
|
|
$ export MINIO_SECRET_KEY=secretkey |
|
|
|
$ export MINIO_SECRET_KEY=secretkey |
|
|
|
$ {{.HelpName}} s3 |
|
|
|
$ {{.HelpName}} |
|
|
|
|
|
|
|
|
|
|
|
3. Start minio gateway server for S3 backend on custom endpoint. |
|
|
|
2. Start minio gateway server for S3 backend on custom endpoint. |
|
|
|
$ export MINIO_ACCESS_KEY=Q3AM3UQ867SPQQA43P2F |
|
|
|
$ export MINIO_ACCESS_KEY=Q3AM3UQ867SPQQA43P2F |
|
|
|
$ export MINIO_SECRET_KEY=zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG |
|
|
|
$ export MINIO_SECRET_KEY=zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG |
|
|
|
$ {{.HelpName}} s3 https://play.minio.io:9000
|
|
|
|
$ {{.HelpName}} https://play.minio.io:9000
|
|
|
|
` |
|
|
|
` |
|
|
|
|
|
|
|
|
|
|
|
var gatewayCmd = cli.Command{ |
|
|
|
var s3BackendCmd = cli.Command{ |
|
|
|
Name: "gateway", |
|
|
|
Name: "s3", |
|
|
|
Usage: "Start object storage gateway.", |
|
|
|
Usage: "Amazon Simple Storage Service (S3).", |
|
|
|
Action: gatewayMain, |
|
|
|
Action: s3GatewayMain, |
|
|
|
CustomHelpTemplate: gatewayTemplate, |
|
|
|
CustomHelpTemplate: s3GatewayTemplate, |
|
|
|
Flags: append(serverFlags, |
|
|
|
Flags: append(serverFlags, |
|
|
|
cli.BoolFlag{ |
|
|
|
cli.BoolFlag{ |
|
|
|
Name: "quiet", |
|
|
|
Name: "quiet", |
|
|
@ -80,6 +119,13 @@ var gatewayCmd = cli.Command{ |
|
|
|
HideHelpCommand: true, |
|
|
|
HideHelpCommand: true, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var gatewayCmd = cli.Command{ |
|
|
|
|
|
|
|
Name: "gateway", |
|
|
|
|
|
|
|
Usage: "Start object storage gateway.", |
|
|
|
|
|
|
|
HideHelpCommand: true, |
|
|
|
|
|
|
|
Subcommands: []cli.Command{azureBackendCmd, s3BackendCmd}, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Represents the type of the gateway backend.
|
|
|
|
// Represents the type of the gateway backend.
|
|
|
|
type gatewayBackend string |
|
|
|
type gatewayBackend string |
|
|
|
|
|
|
|
|
|
|
@ -120,7 +166,7 @@ func mustSetBrowserSettingFromEnv() { |
|
|
|
//
|
|
|
|
//
|
|
|
|
// - Azure Blob Storage.
|
|
|
|
// - Azure Blob Storage.
|
|
|
|
// - Add your favorite backend here.
|
|
|
|
// - Add your favorite backend here.
|
|
|
|
func newGatewayLayer(backendType, endpoint, accessKey, secretKey string, secure bool) (GatewayLayer, error) { |
|
|
|
func newGatewayLayer(backendType gatewayBackend, endpoint, accessKey, secretKey string, secure bool) (GatewayLayer, error) { |
|
|
|
|
|
|
|
|
|
|
|
switch gatewayBackend(backendType) { |
|
|
|
switch gatewayBackend(backendType) { |
|
|
|
case azureBackend: |
|
|
|
case azureBackend: |
|
|
@ -212,12 +258,26 @@ func validateGatewayArguments(serverAddr, endpointAddr string) error { |
|
|
|
return nil |
|
|
|
return nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Handler for 'minio gateway'.
|
|
|
|
// Handler for 'minio gateway azure' command line.
|
|
|
|
func gatewayMain(ctx *cli.Context) { |
|
|
|
func azureGatewayMain(ctx *cli.Context) { |
|
|
|
if !ctx.Args().Present() || ctx.Args().First() == "help" { |
|
|
|
if ctx.Args().Present() && ctx.Args().First() == "help" { |
|
|
|
cli.ShowCommandHelpAndExit(ctx, "gateway", 1) |
|
|
|
cli.ShowCommandHelpAndExit(ctx, "azure", 1) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gatewayMain(ctx, azureBackend) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Handler for 'minio gateway s3' command line.
|
|
|
|
|
|
|
|
func s3GatewayMain(ctx *cli.Context) { |
|
|
|
|
|
|
|
if ctx.Args().Present() && ctx.Args().First() == "help" { |
|
|
|
|
|
|
|
cli.ShowCommandHelpAndExit(ctx, "s3", 1) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gatewayMain(ctx, s3Backend) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Handler for 'minio gateway'.
|
|
|
|
|
|
|
|
func gatewayMain(ctx *cli.Context, backendType gatewayBackend) { |
|
|
|
// Fetch access and secret key from env.
|
|
|
|
// Fetch access and secret key from env.
|
|
|
|
accessKey, secretKey := mustGetGatewayCredsFromEnv() |
|
|
|
accessKey, secretKey := mustGetGatewayCredsFromEnv() |
|
|
|
|
|
|
|
|
|
|
@ -234,13 +294,8 @@ func gatewayMain(ctx *cli.Context) { |
|
|
|
log.EnableQuiet() |
|
|
|
log.EnableQuiet() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// First argument is selected backend type.
|
|
|
|
|
|
|
|
backendType := ctx.Args().Get(0) |
|
|
|
|
|
|
|
// Second argument is the endpoint address (optional)
|
|
|
|
|
|
|
|
endpointAddr := ctx.Args().Get(1) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
serverAddr := ctx.String("address") |
|
|
|
serverAddr := ctx.String("address") |
|
|
|
|
|
|
|
endpointAddr := ctx.Args().Get(0) |
|
|
|
err := validateGatewayArguments(serverAddr, endpointAddr) |
|
|
|
err := validateGatewayArguments(serverAddr, endpointAddr) |
|
|
|
fatalIf(err, "Invalid argument") |
|
|
|
fatalIf(err, "Invalid argument") |
|
|
|
|
|
|
|
|
|
|
|