rename all bucket commands (#3334)
This commit is contained in:
@@ -4,34 +4,36 @@
|
||||
MinIO Client (mc) provides a modern alternative to UNIX commands like ls, cat, cp, mirror, diff, find etc. It supports filesystems and Amazon S3 compatible cloud storage service (AWS Signature v2 and v4).
|
||||
|
||||
```
|
||||
alias set, remove and list aliases in configuration file
|
||||
ls list buckets and objects
|
||||
mb make a bucket
|
||||
rb remove a bucket
|
||||
cp copy objects
|
||||
mirror synchronize object(s) to a remote site
|
||||
cat display object contents
|
||||
head display first 'n' lines of an object
|
||||
pipe stream STDIN to an object
|
||||
share generate URL for temporary access to an object
|
||||
find search for objects
|
||||
sql run sql queries on objects
|
||||
stat show object metadata
|
||||
mv move objects
|
||||
tree list buckets and objects in a tree format
|
||||
du summarize disk usage recursively
|
||||
retention set retention for object(s)
|
||||
legalhold set legal hold for object(s)
|
||||
diff list differences in object name, size, and date between two buckets
|
||||
rm remove objects
|
||||
event manage object notifications
|
||||
watch listen for object notification events
|
||||
policy manage anonymous access to buckets and objects
|
||||
tag manage tags for bucket(s) and object(s)
|
||||
bucket manage bucket configuration
|
||||
admin manage MinIO servers
|
||||
config configure MinIO client
|
||||
update update mc to latest release
|
||||
alias set, remove and list aliases in configuration file
|
||||
ls list buckets and objects
|
||||
mb make a bucket
|
||||
rb remove a bucket
|
||||
cp copy objects
|
||||
mirror synchronize object(s) to a remote site
|
||||
cat display object contents
|
||||
head display first 'n' lines of an object
|
||||
pipe stream STDIN to an object
|
||||
share generate URL for temporary access to an object
|
||||
find search for objects
|
||||
sql run sql queries on objects
|
||||
stat show object metadata
|
||||
mv move objects
|
||||
tree list buckets and objects in a tree format
|
||||
du summarize disk usage recursively
|
||||
retention set retention for object(s)
|
||||
legalhold set legal hold for object(s)
|
||||
diff list differences in object name, size, and date between two buckets
|
||||
rm remove objects
|
||||
event manage object notifications
|
||||
watch listen for object notification events
|
||||
policy manage anonymous access to buckets and objects
|
||||
tag manage tags for bucket(s) and object(s)
|
||||
lock manage default bucket object lock configuration
|
||||
ilm manage bucket lifecycle
|
||||
versioning manage bucket versioning
|
||||
replicate manage bucket replication
|
||||
admin manage MinIO servers
|
||||
update update mc to latest release
|
||||
```
|
||||
|
||||
## Docker Container
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* MinIO Client (C) 2020 MinIO, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminBucketReplicationGetCmd = cli.Command{
|
||||
Name: "get",
|
||||
Usage: "get bucket replication target",
|
||||
Action: mainAdminBucketReplicationGet,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Get replication target on MinIO server for bucket srcbucket.
|
||||
{{.Prompt}} {{.HelpName}} myminio/srcbucket
|
||||
`,
|
||||
}
|
||||
|
||||
// checkAdminBucketReplicationGetSyntax - validate all the passed arguments
|
||||
func checkAdminBucketReplicationGetSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) != 1 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "get", 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
// mainAdminBucketReplicationGet is the handle for "mc admin bucket replication get" command.
|
||||
func mainAdminBucketReplicationGet(ctx *cli.Context) error {
|
||||
checkAdminBucketReplicationGetSyntax(ctx)
|
||||
|
||||
// Additional command specific theme customization.
|
||||
console.SetColor("ReplicationMessage", color.New(color.FgGreen))
|
||||
console.SetColor("AccessKey", color.New(color.FgBlue))
|
||||
console.SetColor("SourceBucket", color.New(color.FgYellow))
|
||||
console.SetColor("ReplicaBucket", color.New(color.FgYellow))
|
||||
console.SetColor("ReplicaURL", color.New(color.FgHiWhite))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
_, sourceBucket := url2Alias(aliasedURL)
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
|
||||
target, e := client.GetBucketReplicationTarget(globalContext, sourceBucket)
|
||||
fatalIf(probe.NewError(e).Trace(args...), "Cannot get replication target")
|
||||
printMsg(replicationMessage{
|
||||
op: "get",
|
||||
AccessKey: target.Credentials.AccessKey,
|
||||
ReplicaBucket: target.TargetBucket,
|
||||
ReplicaURL: target.URL(),
|
||||
SourceBucket: sourceBucket,
|
||||
ReplicationARN: target.Arn,
|
||||
})
|
||||
return nil
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
* MinIO Client (C) 2020 MinIO, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminBucketReplicationRemoveCmd = cli.Command{
|
||||
Name: "remove",
|
||||
Usage: "remove configured replication target",
|
||||
Action: mainAdminBucketReplicationRemove,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Remove existing replication target for bucket srcbucket on MinIO server.
|
||||
{{.Prompt}} {{.HelpName}} myminio/srcbucket
|
||||
`,
|
||||
}
|
||||
|
||||
// checkAdminBucketReplicationRemoveSyntax - validate all the passed arguments
|
||||
func checkAdminBucketReplicationRemoveSyntax(ctx *cli.Context) {
|
||||
|
||||
if len(ctx.Args()) != 1 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "remove", 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
// mainAdminBucketReplicationRemove is the handle for "mc admin bucket replication remove" command.
|
||||
func mainAdminBucketReplicationRemove(ctx *cli.Context) error {
|
||||
checkAdminBucketReplicationRemoveSyntax(ctx)
|
||||
|
||||
console.SetColor("ReplicationMessage", color.New(color.FgGreen))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
// Create a new MinIO Admin Client
|
||||
client, cerr := newAdminClient(aliasedURL)
|
||||
fatalIf(cerr, "Unable to initialize admin connection.")
|
||||
|
||||
_, sourceBucket := url2Alias(args[0])
|
||||
fatalIf(probe.NewError(client.SetBucketReplicationTarget(globalContext, sourceBucket, nil)).Trace(args...), "Cannot remove replication target")
|
||||
|
||||
printMsg(replicationMessage{
|
||||
op: "remove",
|
||||
SourceBucket: sourceBucket,
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,193 +0,0 @@
|
||||
/*
|
||||
* MinIO Client (C) 2020 MinIO, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
json "github.com/minio/mc/pkg/colorjson"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/minio/pkg/auth"
|
||||
"github.com/minio/minio/pkg/console"
|
||||
"github.com/minio/minio/pkg/madmin"
|
||||
)
|
||||
|
||||
var adminBucketReplicationSetFlags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "path-style",
|
||||
Value: "auto",
|
||||
Usage: "path style supported by the server. Valid options are '[on,off,auto]'",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "api",
|
||||
Usage: "API signature. Valid options are '[S3v4, S3v2]'",
|
||||
},
|
||||
}
|
||||
var adminBucketReplicationSetCmd = cli.Command{
|
||||
Name: "set",
|
||||
Usage: "set a new replication target",
|
||||
Action: mainAdminBucketReplicationSet,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: append(globalFlags, adminBucketReplicationSetFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET http(s)://ACCESSKEY:SECRETKEY@REPLICA_URL/REPLICA_BUCKET [--path | --api]
|
||||
|
||||
TARGET:
|
||||
Also called as alias/sourcebucketname
|
||||
|
||||
REPLICA_BUCKET:
|
||||
Also called as replication target bucket.
|
||||
|
||||
REPLICA_URL:
|
||||
Also called as replication endpoint.
|
||||
|
||||
ACCESSKEY:
|
||||
Also called as username.
|
||||
|
||||
SECRETKEY:
|
||||
Also called as password.
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Set a new replication target replicabucket on https://minio2:9000 for bucket 'srcbucket' to MinIO server.
|
||||
{{.DisableHistory}}
|
||||
{{.Prompt}} {{.HelpName}} myminio/srcbucket https://foobar:foo12345@minio2:9000/replicabucket
|
||||
{{.EnableHistory}}
|
||||
`,
|
||||
}
|
||||
|
||||
// checkAdminBucketReplicationSetSyntax - validate all the passed arguments
|
||||
func checkAdminBucketReplicationSetSyntax(ctx *cli.Context) {
|
||||
argsNr := len(ctx.Args())
|
||||
if argsNr < 2 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "set", 1) // last argument is exit code
|
||||
}
|
||||
if argsNr > 2 {
|
||||
fatalIf(errInvalidArgument().Trace(ctx.Args().Tail()...),
|
||||
"Incorrect number of arguments for replication set command.")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// replicationMessage container for content message structure
|
||||
type replicationMessage struct {
|
||||
op string
|
||||
Status string `json:"status"`
|
||||
AccessKey string `json:"accessKey,omitempty"`
|
||||
SecretKey string `json:"secretKey,omitempty"`
|
||||
SourceBucket string `json:"sourceBucket"`
|
||||
ReplicaURL string `json:"replicaURL,omitempty"`
|
||||
ReplicaBucket string `json:"replicaBucket,omitempty"`
|
||||
ReplicationARN string `json:"replicationARN,omitempty"`
|
||||
Path string `json:"path,omitempty"`
|
||||
API string `json:"api,omitempty"`
|
||||
}
|
||||
|
||||
func (r replicationMessage) String() string {
|
||||
switch r.op {
|
||||
case "get":
|
||||
return console.Colorize("ReplicationMessage", "Found Replication target `"+r.ReplicaURL+"` with accessKey: "+r.AccessKey+" for "+r.SourceBucket+" -> "+r.ReplicaBucket+"\n Replication ARN = "+r.ReplicationARN)
|
||||
case "remove":
|
||||
return console.Colorize("ReplicationMessage", "Removed replication target for `"+r.SourceBucket+"` bucket successfully.")
|
||||
case "set":
|
||||
return console.Colorize("ReplicationMessage", "Replication ARN = `"+r.ReplicationARN+"`.")
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (r replicationMessage) JSON() string {
|
||||
r.Status = "success"
|
||||
jsonMessageBytes, e := json.MarshalIndent(r, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
|
||||
return string(jsonMessageBytes)
|
||||
}
|
||||
|
||||
// fetchReplicationTarget - returns the dest bucket, dest endpoint, access and secret key
|
||||
func fetchReplicationTarget(cli *cli.Context) (sourceBucket string, replTarget *madmin.BucketReplicationTarget, err error) {
|
||||
args := cli.Args()
|
||||
argCount := len(args)
|
||||
if argCount < 2 {
|
||||
return sourceBucket, replTarget, fmt.Errorf("Missing replication target configuration")
|
||||
}
|
||||
_, sourceBucket = url2Alias(args[0])
|
||||
replicaURL := args[1]
|
||||
api := cli.String("api")
|
||||
if api != "" && !isValidAPI(api) { // Empty value set to default "S3v4".
|
||||
fatalIf(errInvalidArgument().Trace(api),
|
||||
"Unrecognized API signature. Valid options are `[S3v4, S3v2]`.")
|
||||
}
|
||||
path := cli.String("path-style")
|
||||
if !isValidPath(path) {
|
||||
fatalIf(errInvalidArgument().Trace(path),
|
||||
"Unrecognized bucket path style. Valid options are `[on,off, auto]`.")
|
||||
}
|
||||
u, cerr := url.Parse(replicaURL)
|
||||
if cerr != nil {
|
||||
fatalIf(probe.NewError(cerr), "Malformed replication target URL")
|
||||
}
|
||||
isSSL := u.Scheme == "https"
|
||||
accessKey := u.User.Username()
|
||||
secretKey, _ := u.User.Password()
|
||||
replicaBucket := strings.TrimPrefix(u.Path, slashSeperator)
|
||||
replicaBucket = strings.TrimSuffix(replicaBucket, slashSeperator)
|
||||
|
||||
console.SetColor(cred, color.New(color.FgYellow, color.Italic))
|
||||
creds := &auth.Credentials{AccessKey: accessKey, SecretKey: secretKey}
|
||||
replTarget = &madmin.BucketReplicationTarget{TargetBucket: replicaBucket, IsSSL: isSSL, Credentials: creds, Endpoint: u.Host, Path: path, API: api}
|
||||
return sourceBucket, replTarget, nil
|
||||
}
|
||||
|
||||
// mainAdminBucketReplicationSet is the handle for "mc admin bucket replication set" command.
|
||||
func mainAdminBucketReplicationSet(ctx *cli.Context) error {
|
||||
checkAdminBucketReplicationSetSyntax(ctx)
|
||||
|
||||
console.SetColor("ReplicationMessage", color.New(color.FgGreen))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
// Create a new MinIO Admin Client
|
||||
client, cerr := newAdminClient(aliasedURL)
|
||||
fatalIf(cerr, "Unable to initialize admin connection.")
|
||||
|
||||
sourceBucket, replTarget, perr := fetchReplicationTarget(ctx)
|
||||
fatalIf(probe.NewError(perr), "Unable to parse input arguments.")
|
||||
fatalIf(probe.NewError(client.SetBucketReplicationTarget(globalContext, sourceBucket, replTarget)).Trace(args...), "Cannot add new replication target")
|
||||
arn, e := client.GetBucketReplicationARN(globalContext, replTarget.URL())
|
||||
fatalIf(probe.NewError(e), "Replication ARN missing")
|
||||
|
||||
printMsg(replicationMessage{
|
||||
op: "set",
|
||||
ReplicaURL: replTarget.URL(),
|
||||
ReplicaBucket: replTarget.TargetBucket,
|
||||
AccessKey: replTarget.Credentials.AccessKey,
|
||||
SourceBucket: sourceBucket,
|
||||
ReplicationARN: arn,
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* MinIO Client (C) 2020 MinIO, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
|
||||
import "github.com/minio/cli"
|
||||
|
||||
var adminBucketReplicationCmd = cli.Command{
|
||||
Name: "replication",
|
||||
Usage: "Manage replication targets",
|
||||
Action: mainAdminBucketReplication,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
Subcommands: []cli.Command{
|
||||
adminBucketReplicationSetCmd,
|
||||
adminBucketReplicationGetCmd,
|
||||
adminBucketReplicationRemoveCmd,
|
||||
},
|
||||
HideHelpCommand: true,
|
||||
}
|
||||
|
||||
// mainAdminBucketReplication is the handle for "mc admin bucket replication" command.
|
||||
func mainAdminBucketReplication(ctx *cli.Context) error {
|
||||
cli.ShowCommandHelp(ctx, ctx.Args().First())
|
||||
return nil
|
||||
// Sub-commands like "set", "get" have their own main.
|
||||
}
|
||||
@@ -26,7 +26,6 @@ var adminBucketCmd = cli.Command{
|
||||
Flags: globalFlags,
|
||||
Subcommands: []cli.Command{
|
||||
adminBucketQuotaCmd,
|
||||
adminBucketReplicationCmd,
|
||||
},
|
||||
HideHelpCommand: true,
|
||||
}
|
||||
|
||||
+13
-11
@@ -259,21 +259,24 @@ var completeCmds = map[string]complete.Predictor{
|
||||
"/tag/remove": s3Completer,
|
||||
"/tag/set": s3Completer,
|
||||
|
||||
"/version/info": s3Complete{deepLevel: 2},
|
||||
"/version/enable": s3Complete{deepLevel: 2},
|
||||
"/version/suspend": s3Complete{deepLevel: 2},
|
||||
"/versioning/info": s3Complete{deepLevel: 2},
|
||||
"/versioning/enable": s3Complete{deepLevel: 2},
|
||||
"/versioning/suspend": s3Complete{deepLevel: 2},
|
||||
|
||||
"/bucket/lock/compliance": s3Completer,
|
||||
"/bucket/lock/governance": s3Completer,
|
||||
"/bucket/lock/clear": s3Completer,
|
||||
"/bucket/lock/info": s3Completer,
|
||||
"/lock/compliance": s3Completer,
|
||||
"/lock/governance": s3Completer,
|
||||
"/lock/clear": s3Completer,
|
||||
"/lock/info": s3Completer,
|
||||
|
||||
"/share/download": s3Completer,
|
||||
"/share/list": nil,
|
||||
"/share/upload": s3Completer,
|
||||
|
||||
"/bucket/ilm": s3Complete{deepLevel: 2},
|
||||
"/bucket/replicate": s3Complete{deepLevel: 2},
|
||||
"/ilm/list": s3Complete{deepLevel: 2},
|
||||
"/ilm/add": s3Complete{deepLevel: 2},
|
||||
"/ilm/remove": s3Complete{deepLevel: 2},
|
||||
"/ilm/export": s3Complete{deepLevel: 2},
|
||||
"/ilm/import": s3Complete{deepLevel: 2},
|
||||
|
||||
// Admin API commands MinIO only.
|
||||
"/admin/heal": s3Completer,
|
||||
@@ -327,8 +330,7 @@ var completeCmds = map[string]complete.Predictor{
|
||||
"/config/host/list": aliasCompleter,
|
||||
"/config/host/remove": aliasCompleter,
|
||||
|
||||
"/update": nil,
|
||||
"/version": nil,
|
||||
"/update": nil,
|
||||
}
|
||||
|
||||
// flagsToCompleteFlags transforms a cli.Flag to complete.Flags
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* MinIO Client (C) 2020 MinIO, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
|
||||
import "github.com/minio/cli"
|
||||
|
||||
var (
|
||||
bucketFlags = []cli.Flag{}
|
||||
)
|
||||
|
||||
var bucketCmd = cli.Command{
|
||||
Name: "bucket",
|
||||
Usage: "manage bucket configuration",
|
||||
Action: mainBucket,
|
||||
Before: setGlobalsFromContext,
|
||||
HideHelpCommand: true,
|
||||
Flags: append(bucketFlags, globalFlags...),
|
||||
Subcommands: []cli.Command{
|
||||
bucketILMCmd,
|
||||
bucketLockCmd,
|
||||
bucketReplicateCmd,
|
||||
},
|
||||
}
|
||||
|
||||
// mainBucket is the handle for "mc bucket" command. provides sub-commands which allow managing/viewing bucket info.
|
||||
func mainBucket(ctx *cli.Context) error {
|
||||
cli.ShowCommandHelp(ctx, ctx.Args().First())
|
||||
return nil
|
||||
// Sub-commands like "info", "encrypt" and "version" have their own main.
|
||||
}
|
||||
+4
-3
@@ -339,13 +339,14 @@ var appCmds = []cli.Command{
|
||||
legalHoldCmd,
|
||||
diffCmd,
|
||||
rmCmd,
|
||||
eventCmd,
|
||||
versioningCmd,
|
||||
bucketLockCmd,
|
||||
bucketILMCmd,
|
||||
encryptCmd,
|
||||
eventCmd,
|
||||
watchCmd,
|
||||
policyCmd,
|
||||
tagCmd,
|
||||
versionCmd,
|
||||
bucketCmd,
|
||||
adminCmd,
|
||||
configCmd,
|
||||
updateCmd,
|
||||
|
||||
@@ -1,182 +0,0 @@
|
||||
/*
|
||||
* MinIO Client (C) 2020 MinIO, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/fatih/color"
|
||||
|
||||
"github.com/minio/cli"
|
||||
json "github.com/minio/mc/pkg/colorjson"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/minio-go/v7/pkg/replication"
|
||||
"github.com/minio/minio/pkg/console"
|
||||
)
|
||||
|
||||
var bucketReplicateCmd = cli.Command{
|
||||
Name: "replicate",
|
||||
Usage: "manage bucket replication",
|
||||
Action: mainReplicate,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: append(replicateFlags, globalFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} [COMMAND FLAGS] TARGET
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
DESCRIPTION:
|
||||
Manage replication configuration on the bucket.
|
||||
|
||||
EXAMPLES:
|
||||
1. Add a replication configuration to the "devices" bucket
|
||||
{{.Prompt}} {{.HelpName}} myminio/devices --config "config.json"
|
||||
|
||||
2. List replication configuration on the "devices" bucket
|
||||
{{.Prompt}} {{.HelpName}} myminio/devices
|
||||
|
||||
3. Clear replication configuration on the "devices" bucket
|
||||
{{.Prompt}} {{.HelpName}} myminio/devices --clear
|
||||
`,
|
||||
}
|
||||
|
||||
var replicateFlags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "config",
|
||||
Usage: "add a config.json with replication configuration",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "clear",
|
||||
Usage: "remove replication configuration",
|
||||
},
|
||||
}
|
||||
|
||||
type replicateMessage struct {
|
||||
Op string `json:"-"`
|
||||
Status string `json:"status"`
|
||||
Source string `json:"source"`
|
||||
ReplicationConfig replication.Config `json:"replicationConfig,omitempty"`
|
||||
}
|
||||
|
||||
func (r replicateMessage) String() string {
|
||||
switch r.Op {
|
||||
case "Add":
|
||||
return console.Colorize("ReplicateMessage", "Replication configuration added successfully to "+r.Source+".")
|
||||
case "Remove":
|
||||
return console.Colorize("ReplicateMessage", "Replication configuration removed successfully from "+r.Source+".")
|
||||
default:
|
||||
if r.ReplicationConfig.Empty() {
|
||||
return console.Colorize("ReplicateNMessage", "No replication configuration found for "+r.Source+".")
|
||||
}
|
||||
msgBytes, e := json.MarshalIndent(r.ReplicationConfig, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal replication configuration")
|
||||
return string(msgBytes)
|
||||
}
|
||||
}
|
||||
|
||||
func (r replicateMessage) JSON() string {
|
||||
msgBytes, e := json.MarshalIndent(r, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
return string(msgBytes)
|
||||
}
|
||||
|
||||
// Validate user given arguments
|
||||
func checkReplicateSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) < 1 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "replicate", globalErrorExitStatus)
|
||||
}
|
||||
|
||||
if ctx.IsSet("config") && ctx.String("config") == "" {
|
||||
fatalIf(errInvalidArgument(), "config cannot be empty, please refer mc "+ctx.Command.FullName()+" --help for more details")
|
||||
}
|
||||
}
|
||||
|
||||
// getReplicateArgs - returns the replication config and replication ARN
|
||||
func getReplicateArgs(cli *cli.Context) (replConfig replication.Config, err error) {
|
||||
if !cli.IsSet("config") {
|
||||
return replConfig, nil
|
||||
}
|
||||
if cli.IsSet("clear") {
|
||||
return replConfig, fmt.Errorf("clear flag must be passed with target alone")
|
||||
}
|
||||
cfgFile := cli.String("config")
|
||||
fileReader, e := os.Open(cfgFile)
|
||||
if e != nil {
|
||||
return replConfig, fmt.Errorf("Unable to open config `" + cfgFile + "`.")
|
||||
}
|
||||
defer fileReader.Close()
|
||||
|
||||
const maxJSONSize = 120 * 1024 // 120KiB
|
||||
configBuf, err := ioutil.ReadAll(fileReader)
|
||||
if err != nil {
|
||||
return replConfig, err
|
||||
}
|
||||
if len(configBuf) > maxJSONSize {
|
||||
return replConfig, bytes.ErrTooLarge
|
||||
}
|
||||
|
||||
e = json.Unmarshal(configBuf, &replConfig)
|
||||
if e != nil {
|
||||
return replConfig, e
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func mainReplicate(cliCtx *cli.Context) error {
|
||||
ctx, cancelReplicate := context.WithCancel(globalContext)
|
||||
defer cancelReplicate()
|
||||
checkReplicateSyntax(cliCtx)
|
||||
console.SetColor("ReplicateMessage", color.New(color.FgGreen))
|
||||
console.SetColor("ReplicateNMessage", color.New(color.FgRed))
|
||||
|
||||
args := cliCtx.Args()
|
||||
urlStr := args.Get(0)
|
||||
client, err := newClient(urlStr)
|
||||
fatalIf(err.Trace(urlStr), "Unable to initialize client for "+urlStr)
|
||||
replConfig, cerr := getReplicateArgs(cliCtx)
|
||||
fatalIf(probe.NewError(cerr), "Unable to parse input arguments.")
|
||||
var op string
|
||||
if !replConfig.Empty() {
|
||||
op = "Add"
|
||||
// Configuration that is already set.
|
||||
err = client.SetReplication(ctx, &replConfig)
|
||||
fatalIf(err.Trace(args...), "Unable to set replication configuration for "+urlStr)
|
||||
|
||||
} else if cliCtx.IsSet("clear") {
|
||||
op = "Remove"
|
||||
err = client.RemoveReplication(ctx)
|
||||
fatalIf(err.Trace(args...), "Unable to remove replication configuration for "+urlStr)
|
||||
} else {
|
||||
replConfig, err = client.GetReplication(ctx)
|
||||
fatalIf(err.Trace(args...), "Unable to get replication configuration for "+urlStr)
|
||||
}
|
||||
printMsg(replicateMessage{
|
||||
Op: op,
|
||||
Status: "success",
|
||||
Source: urlStr,
|
||||
ReplicationConfig: replConfig,
|
||||
})
|
||||
return nil
|
||||
}
|
||||
@@ -27,17 +27,17 @@ import (
|
||||
"github.com/minio/minio/pkg/console"
|
||||
)
|
||||
|
||||
var versionEnableCmd = cli.Command{
|
||||
var versioningEnableCmd = cli.Command{
|
||||
Name: "enable",
|
||||
Usage: "Enable bucket versioning",
|
||||
Action: mainVersionEnable,
|
||||
Action: mainVersioningEnable,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET
|
||||
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
@@ -47,8 +47,8 @@ EXAMPLES:
|
||||
`,
|
||||
}
|
||||
|
||||
// checkVersionEnableSyntax - validate all the passed arguments
|
||||
func checkVersionEnableSyntax(ctx *cli.Context) {
|
||||
// checkVersioningEnableSyntax - validate all the passed arguments
|
||||
func checkVersioningEnableSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) != 1 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "enable", 1) // last argument is exit code
|
||||
}
|
||||
@@ -75,13 +75,13 @@ func (v versionEnableMessage) String() string {
|
||||
return console.Colorize("versionEnableMessage", fmt.Sprintf("%s versioning is enabled", v.URL))
|
||||
}
|
||||
|
||||
func mainVersionEnable(cliCtx *cli.Context) error {
|
||||
ctx, cancelVersionEnable := context.WithCancel(globalContext)
|
||||
defer cancelVersionEnable()
|
||||
func mainVersioningEnable(cliCtx *cli.Context) error {
|
||||
ctx, cancelVersioningEnable := context.WithCancel(globalContext)
|
||||
defer cancelVersioningEnable()
|
||||
|
||||
console.SetColor("versionEnableMessage", color.New(color.FgGreen))
|
||||
|
||||
checkVersionEnableSyntax(cliCtx)
|
||||
checkVersioningEnableSyntax(cliCtx)
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := cliCtx.Args()
|
||||
@@ -28,18 +28,18 @@ import (
|
||||
"github.com/minio/minio/pkg/console"
|
||||
)
|
||||
|
||||
var versionInfoCmd = cli.Command{
|
||||
var versioningInfoCmd = cli.Command{
|
||||
Name: "info",
|
||||
Usage: "Show bucket versioning status",
|
||||
Action: mainversionInfo,
|
||||
Action: mainVersioningInfo,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET
|
||||
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
@@ -49,14 +49,14 @@ EXAMPLES:
|
||||
`,
|
||||
}
|
||||
|
||||
// checkversionInfoSyntax - validate all the passed arguments
|
||||
func checkversionInfoSyntax(ctx *cli.Context) {
|
||||
// checkVersioningInfoSyntax - validate all the passed arguments
|
||||
func checkVersioningInfoSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) != 1 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "info", 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
type versionInfoMessage struct {
|
||||
type versioningInfoMessage struct {
|
||||
Op string
|
||||
Status string `json:"status"`
|
||||
URL string `json:"url"`
|
||||
@@ -66,31 +66,31 @@ type versionInfoMessage struct {
|
||||
} `json:"versioning"`
|
||||
}
|
||||
|
||||
func (v versionInfoMessage) JSON() string {
|
||||
func (v versioningInfoMessage) JSON() string {
|
||||
v.Status = "success"
|
||||
jsonMessageBytes, e := json.MarshalIndent(v, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
return string(jsonMessageBytes)
|
||||
}
|
||||
|
||||
func (v versionInfoMessage) String() string {
|
||||
func (v versioningInfoMessage) String() string {
|
||||
msg := ""
|
||||
switch v.Versioning.Status {
|
||||
case "":
|
||||
msg = fmt.Sprintf("%s is un-versioned", v.URL)
|
||||
msg = fmt.Sprintf("%s is un-versioninged", v.URL)
|
||||
default:
|
||||
msg = fmt.Sprintf("%s versioning status is %s", v.URL, strings.ToLower(v.Versioning.Status))
|
||||
}
|
||||
return console.Colorize("versionInfoMessage", msg)
|
||||
return console.Colorize("versioningInfoMessage", msg)
|
||||
}
|
||||
|
||||
func mainversionInfo(cliCtx *cli.Context) error {
|
||||
ctx, cancelVersionInfo := context.WithCancel(globalContext)
|
||||
defer cancelVersionInfo()
|
||||
func mainVersioningInfo(cliCtx *cli.Context) error {
|
||||
ctx, cancelVersioningInfo := context.WithCancel(globalContext)
|
||||
defer cancelVersioningInfo()
|
||||
|
||||
console.SetColor("versionInfoMessage", color.New(color.FgGreen))
|
||||
console.SetColor("versioningInfoMessage", color.New(color.FgGreen))
|
||||
|
||||
checkversionInfoSyntax(cliCtx)
|
||||
checkVersioningInfoSyntax(cliCtx)
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := cliCtx.Args()
|
||||
@@ -99,8 +99,8 @@ func mainversionInfo(cliCtx *cli.Context) error {
|
||||
client, err := newClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize connection.")
|
||||
vConfig, e := client.GetVersioning(ctx)
|
||||
fatalIf(e, "Cannot get version info")
|
||||
vMsg := versionInfoMessage{
|
||||
fatalIf(e, "Cannot get versioning info")
|
||||
vMsg := versioningInfoMessage{
|
||||
Op: "info",
|
||||
Status: "success",
|
||||
URL: aliasedURL,
|
||||
@@ -18,22 +18,22 @@ package cmd
|
||||
|
||||
import "github.com/minio/cli"
|
||||
|
||||
var versionCmd = cli.Command{
|
||||
Name: "version",
|
||||
var versioningCmd = cli.Command{
|
||||
Name: "versioning",
|
||||
Usage: "manage bucket versioning",
|
||||
HideHelpCommand: true,
|
||||
Action: mainVersion,
|
||||
Action: mainVersioning,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
Subcommands: []cli.Command{
|
||||
versionEnableCmd,
|
||||
versionSuspendCmd,
|
||||
versionInfoCmd,
|
||||
versioningEnableCmd,
|
||||
versioningSuspendCmd,
|
||||
versioningInfoCmd,
|
||||
},
|
||||
}
|
||||
|
||||
// mainVersion is the handle for "mc version" command.
|
||||
func mainVersion(ctx *cli.Context) error {
|
||||
// mainVersioning is the handle for "mc versioning" command.
|
||||
func mainVersioning(ctx *cli.Context) error {
|
||||
cli.ShowCommandHelp(ctx, ctx.Args().First())
|
||||
return nil
|
||||
// Sub-commands like "info", "enable", "suspend" have their own main.
|
||||
@@ -27,17 +27,17 @@ import (
|
||||
"github.com/minio/minio/pkg/console"
|
||||
)
|
||||
|
||||
var versionSuspendCmd = cli.Command{
|
||||
var versioningSuspendCmd = cli.Command{
|
||||
Name: "suspend",
|
||||
Usage: "Suspend bucket versioning",
|
||||
Action: mainVersionSuspend,
|
||||
Action: mainVersioningSuspend,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET
|
||||
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
@@ -47,8 +47,8 @@ EXAMPLES:
|
||||
`,
|
||||
}
|
||||
|
||||
// checkVersionSuspendSyntax - validate all the passed arguments
|
||||
func checkVersionSuspendSyntax(ctx *cli.Context) {
|
||||
// checkVersioningSuspendSyntax - validate all the passed arguments
|
||||
func checkVersioningSuspendSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) != 1 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "suspend", 1) // last argument is exit code
|
||||
}
|
||||
@@ -75,13 +75,13 @@ func (v versionSuspendMessage) String() string {
|
||||
return console.Colorize("versionSuspendMessage", fmt.Sprintf("%s versioning is suspended", v.URL))
|
||||
}
|
||||
|
||||
func mainVersionSuspend(cliCtx *cli.Context) error {
|
||||
ctx, cancelVersionSuspend := context.WithCancel(globalContext)
|
||||
defer cancelVersionSuspend()
|
||||
func mainVersioningSuspend(cliCtx *cli.Context) error {
|
||||
ctx, cancelVersioningSuspend := context.WithCancel(globalContext)
|
||||
defer cancelVersioningSuspend()
|
||||
|
||||
console.SetColor("versionSuspendMessage", color.New(color.FgGreen))
|
||||
|
||||
checkVersionSuspendSyntax(cliCtx)
|
||||
checkVersioningSuspendSyntax(cliCtx)
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := cliCtx.Args()
|
||||
@@ -3,36 +3,36 @@
|
||||
MinIO Client (mc) provides a modern alternative to UNIX commands like ls, cat, cp, mirror, diff etc. It supports filesystems and Amazon S3 compatible cloud storage service (AWS Signature v2 and v4).
|
||||
|
||||
```
|
||||
alias set up an alias for an S3 server
|
||||
ls list buckets and objects
|
||||
mb make a bucket
|
||||
rb remove a bucket
|
||||
cp copy objects
|
||||
mirror synchronize object(s) to a remote site
|
||||
cat display object contents
|
||||
head display first 'n' lines of an object
|
||||
pipe stream STDIN to an object
|
||||
share generate URL for temporary access to an object
|
||||
find search for objects
|
||||
sql run sql queries on objects
|
||||
stat show object metadata
|
||||
mv move objects
|
||||
tree list buckets and objects in a tree format
|
||||
du summarize disk usage recursively
|
||||
lock manage default bucket object lock configuration
|
||||
retention set retention for object(s)
|
||||
legalhold set legal hold for object(s)
|
||||
diff list differences in object name, size, and date between two buckets
|
||||
rm remove objects
|
||||
event manage object notifications
|
||||
bucket manage bucket configuration
|
||||
encrypt manage bucket encryption config
|
||||
watch listen for object notification events
|
||||
policy manage anonymous access to buckets and objects
|
||||
tag manage tags for bucket(s) and object(s)
|
||||
bucket manage bucket(s)
|
||||
admin manage MinIO servers
|
||||
update update mc to latest release
|
||||
alias set, remove and list aliases in configuration file
|
||||
ls list buckets and objects
|
||||
mb make a bucket
|
||||
rb remove a bucket
|
||||
cp copy objects
|
||||
mirror synchronize object(s) to a remote site
|
||||
cat display object contents
|
||||
head display first 'n' lines of an object
|
||||
pipe stream STDIN to an object
|
||||
share generate URL for temporary access to an object
|
||||
find search for objects
|
||||
sql run sql queries on objects
|
||||
stat show object metadata
|
||||
mv move objects
|
||||
tree list buckets and objects in a tree format
|
||||
du summarize disk usage recursively
|
||||
retention set retention for object(s)
|
||||
legalhold set legal hold for object(s)
|
||||
diff list differences in object name, size, and date between two buckets
|
||||
rm remove objects
|
||||
versioning manage bucket versioning
|
||||
lock manage default bucket object lock configuration
|
||||
ilm manage bucket lifecycle
|
||||
encrypt manage bucket encryption config
|
||||
event manage object notifications
|
||||
watch listen for object notification events
|
||||
policy manage anonymous access to buckets and objects
|
||||
tag manage tags for bucket(s) and object(s)
|
||||
admin manage MinIO servers
|
||||
update update mc to latest release
|
||||
```
|
||||
|
||||
## 1. Download MinIO Client
|
||||
@@ -299,16 +299,16 @@ mc version RELEASE.2020-04-25T00-43-23Z
|
||||
|
||||
## 7. Commands
|
||||
|
||||
| | | | |
|
||||
|:----------------------------------------------------------------------------------------|:---------------------------------------------------------------|:-----------------------------------------------------------|-------------------------------------------|
|
||||
| [**ls** - list buckets and objects](#ls) | [**tree** - list buckets and objects in a tree format](#tree) | [**mb** - make a bucket](#mb) | [**cat** - display object contents](#cat) |
|
||||
| [**cp** - copy objects](#cp) | [**rb** - remove a bucket](#rb) | [**pipe** - stream STDIN to an object](#pipe) | [**version** - manage bucket version](#version) |
|
||||
| [**share** - generate URL for temporary access to an object](#share) | [**rm** - remove objects](#rm) | [**find** - find files and objects](#find) | |
|
||||
| [**diff** - list differences in object name, size, and date between two buckets](#diff) | [**mirror** - synchronize object(s) to a remote site](#mirror) | [**ilm** - manage bucket lifecycle](#ilm) | |
|
||||
| [**alias** - manage aliases](#alias) | [**policy** - set public policy on bucket or prefix](#policy) | [**event** - manage events on your buckets](#event) |[**replicate** - manage bucket replication](#replicate) |
|
||||
| [**update** - manage software updates](#update) | [**watch** - watch for events](#watch) | [**stat** - stat contents of objects and folders](#stat) | [**encrypt** - manage bucket encryption](#encrypt) |
|
||||
| [**head** - display first 'n' lines of an object](#head) | [**lock** - manage default bucket object lock configuration](#lock) | [**retention** - set retention for object(s)](#retention) | |
|
||||
| [**mv** - move objects](#mv) | [**sql** - run sql queries on objects](#sql) | [**legalhold** - set legal hold for object(s)](#legalhold) | |
|
||||
| | | | |
|
||||
|:----------------------------------------------------------------------------------------|:--------------------------------------------------------------------|:-----------------------------------------------------------|----------------------------------------------------|
|
||||
| [**ls** - list buckets and objects](#ls) | [**tree** - list buckets and objects in a tree format](#tree) | [**mb** - make a bucket](#mb) | [**cat** - display object contents](#cat) |
|
||||
| [**cp** - copy objects](#cp) | [**rb** - remove a bucket](#rb) | [**pipe** - stream STDIN to an object](#pipe) | [**version** - manage bucket version](#version) |
|
||||
| [**share** - generate URL for temporary access to an object](#share) | [**rm** - remove objects](#rm) | [**find** - find files and objects](#find) | |
|
||||
| [**diff** - list differences in object name, size, and date between two buckets](#diff) | [**mirror** - synchronize object(s) to a remote site](#mirror) | [**ilm** - manage bucket lifecycle policies](#ilm) | |
|
||||
| [**alias** - manage aliases](#alias) | [**policy** - set public policy on bucket or prefix](#policy) | [**event** - manage events on your buckets](#event) | |
|
||||
| [**update** - manage software updates](#update) | [**watch** - watch for events](#watch) | [**stat** - stat contents of objects and folders](#stat) | [**encrypt** - manage bucket encryption](#encrypt) |
|
||||
| [**head** - display first 'n' lines of an object](#head) | [**lock** - manage default bucket object lock configuration](#lock) | [**retention** - set retention for object(s)](#retention) | |
|
||||
| [**mv** - move objects](#mv) | [**sql** - run sql queries on objects](#sql) | [**legalhold** - set legal hold for object(s)](#legalhold) | |
|
||||
|
||||
|
||||
### Command `ls`
|
||||
@@ -597,7 +597,7 @@ Hello!!
|
||||
|
||||
```
|
||||
USAGE:
|
||||
mc bucket lock TARGET [info | clear ] | [[governance | compliance] [VALIDITY]]
|
||||
mc lock TARGET [info | clear ] | [[governance | compliance] [VALIDITY]]
|
||||
|
||||
FLAGS:
|
||||
--json enable JSON formatted output
|
||||
@@ -613,13 +613,13 @@ mc lock myminio/mybucket compliance 30d
|
||||
*Example: Display the object lock configuration for bucket `mybucket`*
|
||||
|
||||
```
|
||||
mc bucket lock myminio/mybucket info
|
||||
mc lock myminio/mybucket info
|
||||
COMPLIANCE mode is enabled for 30d
|
||||
```
|
||||
*Example: Clear object lock configuration for bucket `mybucket`*
|
||||
|
||||
```
|
||||
mc bucket lock myminio/mybucket clear
|
||||
mc lock myminio/mybucket clear
|
||||
Object lock configuration cleared successfully
|
||||
```
|
||||
|
||||
@@ -1233,7 +1233,7 @@ mc event remove play/andoria arn:minio:sqs:us-east-1:1:your-queue
|
||||
|
||||
```
|
||||
USAGE:
|
||||
mc bucket ilm COMMAND [COMMAND FLAGS | -h] [ARGUMENTS...]
|
||||
mc ilm COMMAND [COMMAND FLAGS | -h] [ARGUMENTS...]
|
||||
|
||||
COMMANDS:
|
||||
list pretty print bucket lifecycle configuration
|
||||
@@ -1250,7 +1250,7 @@ FLAGS:
|
||||
*Example: List the lifecycle management rules*
|
||||
|
||||
```
|
||||
mc bucket ilm list myminio/testbucket
|
||||
mc ilm list myminio/testbucket
|
||||
ID | Prefix | Enabled | Expiry | Date/Days | Transition | Date/Days | Storage-Class | Tags
|
||||
---------|--------|---------|--------|--------------|------------|-----------|---------------|------
|
||||
Devices | dev/ | ✓ | ✓ | 17 Sep 2020 | ✗ | | |
|
||||
@@ -1262,13 +1262,13 @@ For more details about the lifecycle configuration, refer to official AWS S3 doc
|
||||
|
||||
*Example: Add rule for testbucket on play*
|
||||
```
|
||||
mc bucket ilm add --id "Devices" --prefix "dev/" --expiry-date "2020-09-17" play/testbucket
|
||||
mc ilm add --id "Devices" --prefix "dev/" --expiry-date "2020-09-17" play/testbucket
|
||||
Lifecycle configuration rule added with ID `Devices` to play/testbucket.
|
||||
```
|
||||
|
||||
*Example: Remove the lifecycle management configuration rule given by ID "Documents"*
|
||||
```
|
||||
mc bucket ilm remove --id "Documents" play/testbucket
|
||||
mc ilm remove --id "Documents" play/testbucket
|
||||
Rule ID `Documents` from target play/testbucket removed.
|
||||
```
|
||||
|
||||
@@ -1375,82 +1375,6 @@ mc tag remove s3/testbucket/testobject
|
||||
Tags removed for s3/testbucket/testobject.
|
||||
```
|
||||
|
||||
<a name="replicate"></a>
|
||||
### Command `replicate`
|
||||
`replicate` - A convenient way to manage bucket replication configuration.
|
||||
|
||||
```
|
||||
USAGE:
|
||||
mc bucket replicate [COMMAND FLAGS | -h] TARGET
|
||||
|
||||
FLAGS:
|
||||
--config value add a config.json with replication configuration
|
||||
--clear remove replication configuration
|
||||
--help, -h show help
|
||||
--json enable JSON formatted output
|
||||
--debug enable debug output
|
||||
```
|
||||
|
||||
*Example : Set replication configuration on a bucket. The replication configuration needs to be in json format. If replication configuration is being set on MinIO, the config json should have a ReplicationArn tag. An admin user should have configured a replication target for the replication endpoint and provided a ARN via `mc admin bucket replication set` and `mc admin bucket remote` commands*
|
||||
|
||||
Set replication configuration in `config.json` with replication ARN `arn:minio:s3::598361bf-3cec-49a7-b529-ce870a34d759:*` on `testbucket` in alias `myminio`
|
||||
```
|
||||
$ cat config.json
|
||||
{
|
||||
"ReplicationArn":"arn:minio:s3::598361bf-3cec-49a7-b529-ce870a34d759:*",
|
||||
"Rules": [
|
||||
{
|
||||
"Status": "Enabled",
|
||||
"Priority": 1,
|
||||
"DeleteMarkerReplication": { "Status": "Disabled" },
|
||||
"Filter" : { "Prefix": "Tax"},
|
||||
"Destination": {
|
||||
"Bucket": "arn:aws:s3:::destbucket",
|
||||
"StorageClass":"STANDARD"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
mc bucket replicate myminio/testbucket --config "config.json"
|
||||
Replication configuration added successfully to myminio/testbucket.
|
||||
```
|
||||
|
||||
*Example : List replication configuration for a bucket*
|
||||
|
||||
List replication configuration for `testbucket` in alias `myminio`
|
||||
```
|
||||
mc bucket replicate myminio/testbucket
|
||||
{
|
||||
"ReplicationArn": "arn:minio:s3::95e989fc-3d02-49f1-8d92-9c024926ce30:*",
|
||||
"Rules": [
|
||||
{
|
||||
"ID": "",
|
||||
"Status": "Enabled",
|
||||
"Priority": 1,
|
||||
"DeleteMarkerReplication": {
|
||||
"Status": "Disabled"
|
||||
},
|
||||
"Destination": {
|
||||
"Bucket": "arn:aws:s3:::destbucket",
|
||||
"StorageClass": "STANDARD"
|
||||
},
|
||||
"Filter": {
|
||||
"Prefix": "Tax",
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
*Example : Remove replication configuration on a bucket*
|
||||
|
||||
Remove replication configuration on `testbucket` in alias `myminio`
|
||||
```
|
||||
mc bucket replicate myminio/testbucket --clear
|
||||
Replication configuration removed successfully from myminio/testbucket.
|
||||
```
|
||||
|
||||
<a name="admin"></a>
|
||||
### Command `admin`
|
||||
Please visit [here](https://docs.min.io/docs/minio-admin-complete-guide) for a more comprehensive admin guide.
|
||||
@@ -1580,42 +1504,43 @@ Metadata :
|
||||
Content-Type: application/octet-stream
|
||||
```
|
||||
|
||||
<a name="version"></a>
|
||||
<a name="versioning"></a>
|
||||
### Command `version`
|
||||
`version` manages bucket versioning
|
||||
`versioning` manage bucket versioning
|
||||
|
||||
```
|
||||
NAME:
|
||||
mc version - manage bucket versioning
|
||||
mc versioning - manage bucket versioning
|
||||
|
||||
USAGE:
|
||||
mc version COMMAND [COMMAND FLAGS | -h] [ARGUMENTS...]
|
||||
mc versioning TARGET [enable | suspend | info]
|
||||
|
||||
COMMANDS:
|
||||
enable Enable bucket versioning
|
||||
suspend Suspend bucket versioning
|
||||
info Show bucket versioning status
|
||||
info Show bucket versioning status
|
||||
```
|
||||
|
||||
*Example: Enable versioning on bucket `mybucket`*
|
||||
|
||||
```
|
||||
mc version enable myminio/mybucket
|
||||
mc versioning enable myminio/mybucket
|
||||
myminio/mybucket versioning is enabled
|
||||
```
|
||||
|
||||
*Example: Display the versioning configuration for bucket `mybucket`*
|
||||
|
||||
```
|
||||
mc version info myminio/mybucket
|
||||
mc versioning info myminio/mybucket
|
||||
myminio/mybucket versioning status is enabled
|
||||
|
||||
```
|
||||
*Example: Suspend versioning for bucket `mybucket`*
|
||||
```
|
||||
mc version suspend myminio/mybucket
|
||||
mc versioning suspend myminio/mybucket
|
||||
myminio/mybucket versioning is suspended
|
||||
```
|
||||
|
||||
<a name="encrypt"></a>
|
||||
### Command `encrypt`
|
||||
`encrypt` manages bucket encryption config
|
||||
@@ -1661,4 +1586,4 @@ Auto encryption has been set successfully for myminio/source
|
||||
```
|
||||
mc encrypt clear myminio/mybucket
|
||||
Auto encryption configuration has been cleared successfully.
|
||||
```
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user