diff --git a/cmd/gateway-main.go b/cmd/gateway-main.go index 3c36ddb4c..d87af72f4 100644 --- a/cmd/gateway-main.go +++ b/cmd/gateway-main.go @@ -48,7 +48,7 @@ var ( // RegisterGatewayCommand registers a new command for gateway. func RegisterGatewayCommand(cmd cli.Command) error { - cmd.Flags = append(append(cmd.Flags, append(cmd.Flags, ServerFlags...)...), GlobalFlags...) + cmd.Flags = append(append(cmd.Flags, ServerFlags...), GlobalFlags...) gatewayCmd.Subcommands = append(gatewayCmd.Subcommands, cmd) return nil } diff --git a/cmd/gateway-main_test.go b/cmd/gateway-main_test.go index b030e8cf9..ddef8f744 100644 --- a/cmd/gateway-main_test.go +++ b/cmd/gateway-main_test.go @@ -17,6 +17,7 @@ package cmd import ( + "fmt" "strings" "testing" @@ -34,6 +35,36 @@ func TestRegisterGatewayCommand(t *testing.T) { } } +// Test running a registered gateway command with a flag +func TestRunRegisteredGatewayCommand(t *testing.T) { + var err error + + flagName := "test-flag" + flagValue := "foo" + + cmd := cli.Command{ + Name: "test-run-with-flag", + Flags: []cli.Flag{ + cli.StringFlag{Name: flagName}, + }, + Action: func(ctx *cli.Context) { + if actual := ctx.String(flagName); actual != flagValue { + t.Errorf("value of %s expects %s, but got %s", flagName, flagValue, actual) + } + }, + } + + err = RegisterGatewayCommand(cmd) + if err != nil { + t.Errorf("RegisterGatewayCommand got unexpected error: %s", err) + } + + if err = newApp("minio").Run( + []string{"minio", "gateway", cmd.Name, fmt.Sprintf("--%s", flagName), flagValue}); err != nil { + t.Errorf("running registered gateway command got unexpected error: %s", err) + } +} + // Test parseGatewayEndpoint func TestParseGatewayEndpoint(t *testing.T) { testCases := []struct { diff --git a/docs/gateway/gcs.md b/docs/gateway/gcs.md index 586fbc464..717009d3b 100644 --- a/docs/gateway/gcs.md +++ b/docs/gateway/gcs.md @@ -19,7 +19,7 @@ MinIO GCS Gateway allows you to access Google Cloud Storage (GCS) with Amazon S3 **Note:** For alternate ways to set up *Application Default Credentials*, see [Setting Up Authentication for Server to Server Production Applications](https://developers.google.com/identity/protocols/application-default-credentials). -### 1.1 Run MinIO GCS Gateway Using Docker +### 1.2 Run MinIO GCS Gateway Using Docker ```sh docker run -p 9000:9000 --name gcs-s3 \ -v /path/to/credentials.json:/credentials.json \ @@ -29,7 +29,7 @@ docker run -p 9000:9000 --name gcs-s3 \ minio/minio gateway gcs yourprojectid ``` -### 1.2 Run MinIO GCS Gateway Using the MinIO Binary +### 1.3 Run MinIO GCS Gateway Using the MinIO Binary ```sh export GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json