From f8a489be9d1d87fff74377640a03f6a03b03c95b Mon Sep 17 00:00:00 2001 From: Krishnan Parthasarathi Date: Mon, 19 Dec 2022 16:48:28 -0800 Subject: [PATCH] reorganize ILM tier commands (#4385) --- cmd/admin-tier-deprecated.go | 208 ++++++++++++++++ cmd/admin-tier-main.go | 19 +- cmd/auto-complete.go | 15 ++ cmd/ilm-deprecated-cmds.go | 224 ++++++++++++++++++ cmd/ilm-main.go | 10 +- cmd/ilm-restore.go | 5 +- cmd/{ilm-add.go => ilm-rule-add.go} | 20 +- cmd/{ilm-edit.go => ilm-rule-edit.go} | 0 cmd/{ilm-export.go => ilm-rule-export.go} | 0 cmd/{ilm-import.go => ilm-rule-import.go} | 0 cmd/{ilm-ls.go => ilm-rule-ls.go} | 0 cmd/ilm-rule-main.go | 44 ++++ cmd/{admin-tier-add.go => ilm-tier-add.go} | 3 + cmd/ilm-tier-check.go | 45 ++++ cmd/{admin-tier-edit.go => ilm-tier-edit.go} | 1 + ...in-tier-info-ui.go => ilm-tier-info-ui.go} | 0 cmd/{admin-tier-info.go => ilm-tier-info.go} | 0 ...in-tier-listing.go => ilm-tier-listing.go} | 0 cmd/{admin-tier-ls.go => ilm-tier-ls.go} | 2 +- cmd/ilm-tier-main.go | 46 ++++ cmd/{admin-tier-rm.go => ilm-tier-rm.go} | 2 +- cmd/ilm-tier-update.go | 51 ++++ ...dmin-tier-verify.go => ilm-tier-verify.go} | 1 + 23 files changed, 661 insertions(+), 35 deletions(-) create mode 100644 cmd/admin-tier-deprecated.go create mode 100644 cmd/ilm-deprecated-cmds.go rename cmd/{ilm-add.go => ilm-rule-add.go} (93%) rename cmd/{ilm-edit.go => ilm-rule-edit.go} (100%) rename cmd/{ilm-export.go => ilm-rule-export.go} (100%) rename cmd/{ilm-import.go => ilm-rule-import.go} (100%) rename cmd/{ilm-ls.go => ilm-rule-ls.go} (100%) create mode 100644 cmd/ilm-rule-main.go rename cmd/{admin-tier-add.go => ilm-tier-add.go} (98%) create mode 100644 cmd/ilm-tier-check.go rename cmd/{admin-tier-edit.go => ilm-tier-edit.go} (99%) rename cmd/{admin-tier-info-ui.go => ilm-tier-info-ui.go} (100%) rename cmd/{admin-tier-info.go => ilm-tier-info.go} (100%) rename cmd/{admin-tier-listing.go => ilm-tier-listing.go} (100%) rename cmd/{admin-tier-ls.go => ilm-tier-ls.go} (98%) create mode 100644 cmd/ilm-tier-main.go rename cmd/{admin-tier-rm.go => ilm-tier-rm.go} (97%) create mode 100644 cmd/ilm-tier-update.go rename cmd/{admin-tier-verify.go => ilm-tier-verify.go} (99%) diff --git a/cmd/admin-tier-deprecated.go b/cmd/admin-tier-deprecated.go new file mode 100644 index 00000000..ae4f025a --- /dev/null +++ b/cmd/admin-tier-deprecated.go @@ -0,0 +1,208 @@ +// Copyright (c) 2022 MinIO, Inc. +// +// This file is part of MinIO Object Storage stack +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package cmd + +import "github.com/minio/cli" + +var adminTierDepCmds = []cli.Command{ + adminTierDepInfoCmd, + adminTierDepListCmd, + adminTierDepAddCmd, + adminTierDepEditCmd, + adminTierDepVerifyCmd, + adminTierDepRmCmd, +} + +var ( + adminTierDepInfoCmd = cli.Command{ + Name: "info", + Usage: "display tier statistics", + Action: mainAdminTierInfo, + Hidden: true, + OnUsageError: onUsageError, + Before: setGlobalsFromContext, + Flags: globalFlags, + CustomHelpTemplate: `NAME: + {{.HelpName}} - {{.Usage}} + +USAGE: + {{.HelpName}} ALIAS [NAME] + +FLAGS: + {{range .VisibleFlags}}{{.}} + {{end}} + +EXAMPLES: + 1. Prints per-tier statistics of all remote tier targets configured on 'myminio': + {{.Prompt}} {{.HelpName}} myminio + + 2. Print per-tier statistics of given tier name 'MINIOTIER-1': + {{.Prompt}} {{.HelpName}} myminio MINIOTIER-1 +`, + } + + adminTierDepListCmd = cli.Command{ + Name: "ls", + Usage: "lists configured remote tier targets", + Action: mainAdminTierList, + Hidden: true, + OnUsageError: onUsageError, + Before: setGlobalsFromContext, + Flags: globalFlags, + CustomHelpTemplate: `NAME: + {{.HelpName}} - {{.Usage}} + +USAGE: + {{.HelpName}} ALIAS + +FLAGS: + {{range .VisibleFlags}}{{.}} + {{end}} + +EXAMPLES: + 1. List remote tier targets configured on 'myminio': + {{.Prompt}} {{.HelpName}} myminio +`, + } + + adminTierDepAddCmd = cli.Command{ + Name: "add", + Usage: "add a new remote tier target", + Action: mainAdminTierAdd, + Hidden: true, + OnUsageError: onUsageError, + Before: setGlobalsFromContext, + Flags: append(globalFlags, adminTierAddFlags...), + CustomHelpTemplate: `NAME: + {{.HelpName}} - {{.Usage}} + +USAGE: + {{.HelpName}} TYPE ALIAS NAME [FLAGS] + +TYPE: + Type of the cloud storage backend to add. Supported values are minio, s3, azure and gcs. + +NAME: + Name of the remote tier target. e.g WARM-TIER + +FLAGS: + {{range .VisibleFlags}}{{.}} + {{end}} +EXAMPLES: + 1. Configure a new remote tier which transitions objects to a bucket in a MinIO deployment: + {{.Prompt}} {{.HelpName}} minio myminio WARM-MINIO-TIER --endpoint https://warm-minio.com \ + --access-key ACCESSKEY --secret-key SECRETKEY --bucket mybucket --prefix myprefix/ + + 2. Configure a new remote tier which transitions objects to a bucket in Azure Blob Storage: + {{.Prompt}} {{.HelpName}} azure myminio AZTIER --account-name ACCOUNT-NAME --account-key ACCOUNT-KEY \ + --bucket myazurebucket --prefix myazureprefix/ + + 3. Configure a new remote tier which transitions objects to a bucket in AWS S3 with STANDARD storage class: + {{.Prompt}} {{.HelpName}} s3 myminio S3TIER --endpoint https://s3.amazonaws.com \ + --access-key ACCESSKEY --secret-key SECRETKEY --bucket mys3bucket --prefix mys3prefix/ \ + --storage-class "STANDARD" --region us-west-2 + + 4. Configure a new remote tier which transitions objects to a bucket in Google Cloud Storage: + {{.Prompt}} {{.HelpName}} gcs myminio GCSTIER --credentials-file /path/to/credentials.json \ + --bucket mygcsbucket --prefix mygcsprefix/ +`, + } + adminTierDepEditCmd = cli.Command{ + Name: "edit", + Usage: "update an existing remote tier configuration", + Action: mainAdminTierEdit, + Hidden: true, + OnUsageError: onUsageError, + Before: setGlobalsFromContext, + Flags: append(globalFlags, adminTierEditFlags...), + CustomHelpTemplate: `NAME: + {{.HelpName}} - {{.Usage}} + +USAGE: + {{.HelpName}} ALIAS NAME + +NAME: + Name of remote tier. e.g WARM-TIER + +FLAGS: + {{range .VisibleFlags}}{{.}} + {{end}} +EXAMPLES: + 1. Update credentials for an existing Azure Blob Storage remote tier: + {{.Prompt}} {{.HelpName}} myminio AZTIER --account-key ACCOUNT-KEY + + 2. Update credentials for an existing AWS S3 compatible remote tier: + {{.Prompt}} {{.HelpName}} myminio S3TIER --access-key ACCESS-KEY --secret-key SECRET-KEY + + 3. Update credentials for an existing Google Cloud Storage remote tier: + {{.Prompt}} {{.HelpName}} myminio GCSTIER --credentials-file /path/to/credentials.json +`, + } + + adminTierDepVerifyCmd = cli.Command{ + Name: "verify", + Usage: "verifies if remote tier configuration is valid", + Action: mainAdminTierVerify, + Hidden: true, + OnUsageError: onUsageError, + Before: setGlobalsFromContext, + Flags: globalFlags, + CustomHelpTemplate: `NAME: + {{.HelpName}} - {{.Usage}} + +USAGE: + {{.HelpName}} TARGET NAME + +NAME: + Name of remote tier target. e.g WARM-TIER + +FLAGS: + {{range .VisibleFlags}}{{.}} + {{end}} +EXAMPLES: + 1. Verify if a tier config is valid. + {{.Prompt}} {{.HelpName}} myminio WARM-TIER +`, + } + + adminTierDepRmCmd = cli.Command{ + Name: "rm", + Usage: "removes an empty remote tier", + Action: mainAdminTierRm, + Hidden: true, + OnUsageError: onUsageError, + Before: setGlobalsFromContext, + Flags: globalFlags, + CustomHelpTemplate: `NAME: + {{.HelpName}} - {{.Usage}} + +USAGE: + {{.HelpName}} ALIAS NAME + +NAME: + Name of remote tier target. e.g WARM-TIER + +FLAGS: + {{range .VisibleFlags}}{{.}} + {{end}} +EXAMPLES: + 1. Remove an empty tier by name 'WARM-TIER': + {{.Prompt}} {{.HelpName}} myminio WARM-TIER +`, + } +) diff --git a/cmd/admin-tier-main.go b/cmd/admin-tier-main.go index d7ced304..027aee6b 100644 --- a/cmd/admin-tier-main.go +++ b/cmd/admin-tier-main.go @@ -17,16 +17,10 @@ package cmd -import "github.com/minio/cli" - -var adminTierSubCommands = []cli.Command{ - adminTierAddCmd, - adminTierListCmd, - adminTierEditCmd, - adminTierRmCmd, - adminTierVerifyCmd, - adminTierInfoCmd, -} +import ( + "github.com/minio/cli" + "github.com/minio/pkg/console" +) var adminTierCmd = cli.Command{ Name: "tier", @@ -34,13 +28,12 @@ var adminTierCmd = cli.Command{ Action: mainAdminTier, Before: setGlobalsFromContext, Flags: globalFlags, - Subcommands: adminTierSubCommands, HideHelpCommand: true, + Subcommands: adminTierDepCmds, } // mainAdminTier is the handle for "mc admin tier" command. func mainAdminTier(ctx *cli.Context) error { - commandNotFound(ctx, adminTierSubCommands) + console.Println("Please use 'mc ilm tier' instead.") return nil - // Sub-commands like "add", "ls", "edit", "rm" and "verify" have their own main. } diff --git a/cmd/auto-complete.go b/cmd/auto-complete.go index 4f61935c..061d001d 100644 --- a/cmd/auto-complete.go +++ b/cmd/auto-complete.go @@ -304,6 +304,14 @@ var completeCmds = map[string]complete.Predictor{ "/ilm/import": s3Complete{deepLevel: 2}, "/ilm/restore": s3Completer, + "/ilm/rule/ls": s3Complete{deepLevel: 2}, + "/ilm/rule/add": s3Complete{deepLevel: 2}, + "/ilm/rule/edit": s3Complete{deepLevel: 2}, + "/ilm/rule/rm": s3Complete{deepLevel: 2}, + "/ilm/rule/export": s3Complete{deepLevel: 2}, + "/ilm/rule/import": s3Complete{deepLevel: 2}, + "/ilm/rule/restore": s3Completer, + "/undo": s3Completer, // Admin API commands MinIO only. @@ -432,6 +440,13 @@ var completeCmds = map[string]complete.Predictor{ "/admin/tier/rm": nil, "/admin/tier/verify": nil, + "/ilm/tier/info": nil, + "/ilm/tier/ls": nil, + "/ilm/tier/add": nil, + "/ilm/tier/update": nil, + "/ilm/tier/check": nil, + "/ilm/tier/rm": nil, + "/admin/replicate/add": aliasCompleter, "/admin/replicate/edit": aliasCompleter, "/admin/replicate/info": aliasCompleter, diff --git a/cmd/ilm-deprecated-cmds.go b/cmd/ilm-deprecated-cmds.go new file mode 100644 index 00000000..8cdb6015 --- /dev/null +++ b/cmd/ilm-deprecated-cmds.go @@ -0,0 +1,224 @@ +// Copyright (c) 2022 MinIO, Inc. +// +// This file is part of MinIO Object Storage stack +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package cmd + +import "github.com/minio/cli" + +var ilmDepCmds = []cli.Command{ + ilmDepAddCmd, + ilmDepEditCmd, + ilmDepLsCmd, + ilmDepRmCmd, + ilmDepExportCmd, + ilmDepImportCmd, +} + +var ( + ilmDepAddCmd = cli.Command{ + Name: "add", + Usage: "add a lifecycle configuration rule for a bucket", + Action: mainILMAdd, + Hidden: true, // to avoid being listed in `mc ilm` + OnUsageError: onUsageError, + Before: setGlobalsFromContext, + Flags: append(ilmAddFlags, globalFlags...), + CustomHelpTemplate: `NAME: + {{.HelpName}} - {{.Usage}} + +USAGE: + {{.HelpName}} [COMMAND FLAGS] TARGET + +FLAGS: + {{range .VisibleFlags}}{{.}} + {{end}} +DESCRIPTION: + Add a lifecycle configuration rule. + +EXAMPLES: + 1. Add a lifecycle rule with an expiration action for all objects in mybucket. + {{.Prompt}} {{.HelpName}} --expire-days "200" myminio/mybucket + + 2. Add a lifecycle rule with a transition and a noncurrent version transition action for objects with prefix doc/ in mybucket. + Tiers must exist in MinIO. Use existing tiers or add new tiers. + {{.Prompt}} mc tier add minio myminio MINIOTIER-1 --endpoint https://warm-minio-1.com \ + --access-key ACCESSKEY --secret-key SECRETKEY --bucket bucket1 --prefix prefix1 + + {{.Prompt}} mc tier add minio myminio MINIOTIER-2 --endpoint https://warm-minio-2.com \ + --access-key ACCESSKEY --secret-key SECRETKEY --bucket bucket2 --prefix prefix2 + + {{.Prompt}} {{.HelpName}} --prefix "doc/" --transition-days "90" --transition-tier "MINIOTIER-1" \ + --noncurrent-transition-days "45" --noncurrent-transition-tier "MINIOTIER-2" \ + myminio/mybucket/ + + 3. Add a lifecycle rule with an expiration and a noncurrent version expiration action for all objects with prefix doc/ in mybucket. + {{.Prompt}} {{.HelpName}} --prefix "doc/" --expire-days "300" --noncurrent-expire-days "100" \ + myminio/mybucket/ +`, + } + ilmDepRmCmd = cli.Command{ + Name: "rm", + Usage: "remove (if any) existing lifecycle configuration rule", + Action: mainILMRemove, + Hidden: true, // to avoid being listed in `mc ilm` + OnUsageError: onUsageError, + Before: setGlobalsFromContext, + Flags: append(ilmRemoveFlags, globalFlags...), + CustomHelpTemplate: `NAME: + {{.HelpName}} - {{.Usage}} + +USAGE: + {{.HelpName}} [FLAGS] TARGET + +FLAGS: + {{range .VisibleFlags}}{{.}} + {{end}} +DESCRIPTION: + Remove a lifecycle configuration rule for the bucket by ID, optionally you can remove + all the lifecycle rules on a bucket with '--all --force' option. + +EXAMPLES: + 1. Remove the lifecycle management configuration rule given by ID "bgrt1ghju" for mybucket on alias 'myminio'. ID is case sensitive. + {{.Prompt}} {{.HelpName}} --id "bgrt1ghju" myminio/mybucket + + 2. Remove ALL the lifecycle management configuration rules for mybucket on alias 'myminio'. + Because the result is complete removal, the use of --force flag is enforced. + {{.Prompt}} {{.HelpName}} --all --force myminio/mybucket +`, + } + + ilmDepEditCmd = cli.Command{ + Name: "edit", + Usage: "modify a lifecycle configuration rule with given id", + Action: mainILMEdit, + Hidden: true, // to avoid being listed in `mc ilm` + OnUsageError: onUsageError, + Before: setGlobalsFromContext, + Flags: append(ilmEditFlags, globalFlags...), + CustomHelpTemplate: `NAME: + {{.HelpName}} - {{.Usage}} + +USAGE: + {{.HelpName}} [COMMAND FLAGS] TARGET + +FLAGS: + {{range .VisibleFlags}}{{.}} + {{end}} +DESCRIPTION: + Modify a lifecycle configuration rule with given id. + +EXAMPLES: + 1. Modify the expiration date for an existing rule with id "rHTY.a123". + {{.Prompt}} {{.HelpName}} --id "rHTY.a123" --expiry-date "2020-09-17" s3/mybucket + + 2. Modify the expiration and transition days for an existing rule with id "hGHKijqpo123". + {{.Prompt}} {{.HelpName}} --id "hGHKijqpo123" --expiry-days "300" \ + --transition-days "200" --storage-class "GLACIER" s3/mybucket + + 3. Disable the rule with id "rHTY.a123". + {{.Prompt}} {{.HelpName}} --id "rHTY.a123" --disable s3/mybucket + +`, + } + + ilmDepLsCmd = cli.Command{ + Name: "ls", + Usage: "lists lifecycle configuration rules set on a bucket", + Action: mainILMList, + Hidden: true, // to avoid being listed in `mc ilm` + OnUsageError: onUsageError, + Before: setGlobalsFromContext, + Flags: append(ilmListFlags, globalFlags...), + CustomHelpTemplate: `NAME: + {{.HelpName}} - {{.Usage}} + +USAGE: + {{.HelpName}} [FLAGS] TARGET + +FLAGS: + {{range .VisibleFlags}}{{.}} + {{end}} +DESCRIPTION: + List lifecycle configuration rules set on a bucket. + +EXAMPLES: + 1. List the lifecycle management rules (all fields) for mybucket on alias 'myminio'. + {{.Prompt}} {{.HelpName}} myminio/mybucket + + 2. List the lifecycle management rules (expration date/days fields) for mybucket on alias 'myminio'. + {{.Prompt}} {{.HelpName}} --expiry myminio/mybucket + + 3. List the lifecycle management rules (transition date/days, storage class fields) for mybucket on alias 'myminio'. + {{.Prompt}} {{.HelpName}} --transition myminio/mybucket + + 4. List the lifecycle management rules in JSON format for mybucket on alias 'myminio'. + {{.Prompt}} {{.HelpName}} --json myminio/mybucket +`, + } + + ilmDepExportCmd = cli.Command{ + Name: "export", + Usage: "export lifecycle configuration in JSON format", + Action: mainILMExport, + Hidden: true, // to avoid being listed in `mc ilm` + OnUsageError: onUsageError, + Before: setGlobalsFromContext, + Flags: globalFlags, + CustomHelpTemplate: `NAME: + {{.HelpName}} - {{.Usage}} + +USAGE: + {{.HelpName}} TARGET + +DESCRIPTION: + Exports lifecycle configuration in JSON format to STDOUT. + +EXAMPLES: + 1. Export lifecycle configuration for 'mybucket' to 'lifecycle.json' file. + {{.Prompt}} {{.HelpName}} myminio/mybucket > lifecycle.json + + 2. Print lifecycle configuration for 'mybucket' to STDOUT. + {{.Prompt}} {{.HelpName}} play/mybucket +`, + } + + ilmDepImportCmd = cli.Command{ + Name: "import", + Usage: "import lifecycle configuration in JSON format", + Action: mainILMImport, + Hidden: true, // to avoid being listed in `mc ilm` + OnUsageError: onUsageError, + Before: setGlobalsFromContext, + Flags: globalFlags, + CustomHelpTemplate: `NAME: + {{.HelpName}} - {{.Usage}} + +USAGE: + {{.HelpName}} TARGET + +DESCRIPTION: + Import entire lifecycle configuration from STDIN, input file is expected to be in JSON format. + +EXAMPLES: + 1. Set lifecycle configuration for the mybucket on alias 'myminio' to the rules imported from lifecycle.json + {{.Prompt}} {{.HelpName}} myminio/mybucket < lifecycle.json + + 2. Set lifecycle configuration for the mybucket on alias 'myminio'. User is expected to enter the JSON contents on STDIN + {{.Prompt}} {{.HelpName}} myminio/mybucket +`, + } +) diff --git a/cmd/ilm-main.go b/cmd/ilm-main.go index f9bf668e..772fb47c 100644 --- a/cmd/ilm-main.go +++ b/cmd/ilm-main.go @@ -24,12 +24,8 @@ import ( ) var ilmSubcommands = []cli.Command{ - ilmAddCmd, - ilmEditCmd, - ilmLsCmd, - ilmRmCmd, - ilmExportCmd, - ilmImportCmd, + ilmRuleCmd, + ilmTierCmd, ilmRestoreCmd, } @@ -40,7 +36,7 @@ var ilmCmd = cli.Command{ Before: setGlobalsFromContext, Flags: globalFlags, HideHelpCommand: true, - Subcommands: ilmSubcommands, + Subcommands: append(ilmSubcommands, ilmDepCmds...), } const ( diff --git a/cmd/ilm-restore.go b/cmd/ilm-restore.go index 05747c04..d488b1b3 100644 --- a/cmd/ilm-restore.go +++ b/cmd/ilm-restore.go @@ -65,8 +65,8 @@ USAGE: {{.HelpName}} TARGET DESCRIPTION: - Create a restored copy of one or more objects archived on a remote tier. The copy automatically expires - after the specified number of days (Default 1 day). + Restore a copy of one or more objects from its remote tier. This copy automatically expires + after the specified number of days (Default 1 day). FLAGS: {{range .VisibleFlags}}{{.}} @@ -84,7 +84,6 @@ EXAMPLES: 4. Restore all objects with all versions under a specific prefix {{.Prompt}} {{.HelpName}} --recursive --versions myminio/mybucket/dir/ - `, } diff --git a/cmd/ilm-add.go b/cmd/ilm-rule-add.go similarity index 93% rename from cmd/ilm-add.go rename to cmd/ilm-rule-add.go index 2e7f4fdf..5ddd1818 100644 --- a/cmd/ilm-add.go +++ b/cmd/ilm-rule-add.go @@ -49,20 +49,20 @@ DESCRIPTION: Add a lifecycle configuration rule. EXAMPLES: - 1. Add a lifecycle rule with an expiration action for all objects in mybucket. - {{.Prompt}} {{.HelpName}} --expire-days "200" myminio/mybucket - - 2. Add a lifecycle rule with a transition and a noncurrent version transition action for objects with prefix doc/ in mybucket. + 1. Add a lifecycle rule with a transition and a noncurrent version transition action for objects with prefix doc/ in mybucket. Tiers must exist in MinIO. Use existing tiers or add new tiers. - {{.Prompt}} mc tier add minio myminio MINIOTIER-1 --endpoint https://warm-minio-1.com \ + + {{.Prompt}} mc ilm tier add minio myminio MINIOTIER-1 --endpoint https://warm-minio-1.com \ --access-key ACCESSKEY --secret-key SECRETKEY --bucket bucket1 --prefix prefix1 - {{.Prompt}} mc tier add minio myminio MINIOTIER-2 --endpoint https://warm-minio-2.com \ - --access-key ACCESSKEY --secret-key SECRETKEY --bucket bucket2 --prefix prefix2 - {{.Prompt}} {{.HelpName}} --prefix "doc/" --transition-days "90" --transition-tier "MINIOTIER-1" \ - --noncurrent-transition-days "45" --noncurrent-transition-tier "MINIOTIER-2" \ - myminio/mybucket/ + --noncurrent-transition-days "45" --noncurrent-transition-tier "MINIOTIER-1" \ + myminio/mybucket/ + + + 2. Add a lifecycle rule with an expiration action for all objects in mybucket. + {{.Prompt}} {{.HelpName}} --expire-days "200" myminio/mybucket + 3. Add a lifecycle rule with an expiration and a noncurrent version expiration action for all objects with prefix doc/ in mybucket. {{.Prompt}} {{.HelpName}} --prefix "doc/" --expire-days "300" --noncurrent-expire-days "100" \ diff --git a/cmd/ilm-edit.go b/cmd/ilm-rule-edit.go similarity index 100% rename from cmd/ilm-edit.go rename to cmd/ilm-rule-edit.go diff --git a/cmd/ilm-export.go b/cmd/ilm-rule-export.go similarity index 100% rename from cmd/ilm-export.go rename to cmd/ilm-rule-export.go diff --git a/cmd/ilm-import.go b/cmd/ilm-rule-import.go similarity index 100% rename from cmd/ilm-import.go rename to cmd/ilm-rule-import.go diff --git a/cmd/ilm-ls.go b/cmd/ilm-rule-ls.go similarity index 100% rename from cmd/ilm-ls.go rename to cmd/ilm-rule-ls.go diff --git a/cmd/ilm-rule-main.go b/cmd/ilm-rule-main.go new file mode 100644 index 00000000..045d78d5 --- /dev/null +++ b/cmd/ilm-rule-main.go @@ -0,0 +1,44 @@ +// Copyright (c) 2022 MinIO, Inc. +// +// This file is part of MinIO Object Storage stack +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package cmd + +import "github.com/minio/cli" + +var ilmRuleSubcommands = []cli.Command{ + ilmAddCmd, + ilmEditCmd, + ilmLsCmd, + ilmRmCmd, + ilmExportCmd, + ilmImportCmd, +} + +var ilmRuleCmd = cli.Command{ + Name: "rule", + Usage: "manage bucket lifecycle rules", + Before: setGlobalsFromContext, + Action: mainILMRule, + Subcommands: ilmRuleSubcommands, + Flags: globalFlags, + HideHelpCommand: true, +} + +func mainILMRule(ctx *cli.Context) error { + commandNotFound(ctx, ilmRuleSubcommands) + return nil +} diff --git a/cmd/admin-tier-add.go b/cmd/ilm-tier-add.go similarity index 98% rename from cmd/admin-tier-add.go rename to cmd/ilm-tier-add.go index 64910368..c8914196 100644 --- a/cmd/admin-tier-add.go +++ b/cmd/ilm-tier-add.go @@ -325,6 +325,9 @@ func (msg *tierMessage) String() string { case "verify": verifyMsg := fmt.Sprintf("Verified remote tier %s", msg.TierName) return console.Colorize("TierMessage", verifyMsg) + case "check": + checkMsg := fmt.Sprintf("Remote tier connectivity check for %s was successful", msg.TierName) + return console.Colorize("TierMessage", checkMsg) case "edit": editMsg := fmt.Sprintf("Updated remote tier %s", msg.TierName) return console.Colorize("TierMessage", editMsg) diff --git a/cmd/ilm-tier-check.go b/cmd/ilm-tier-check.go new file mode 100644 index 00000000..20d4a113 --- /dev/null +++ b/cmd/ilm-tier-check.go @@ -0,0 +1,45 @@ +// Copyright (c) 2022 MinIO, Inc. +// +// This file is part of MinIO Object Storage stack +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package cmd + +import "github.com/minio/cli" + +var ilmTierCheckCmd = cli.Command{ + Name: "check", + Usage: "validate remote tier configuration", + Action: mainAdminTierVerify, + OnUsageError: onUsageError, + Before: setGlobalsFromContext, + Flags: globalFlags, + CustomHelpTemplate: `NAME: + {{.HelpName}} - {{.Usage}} + +USAGE: + {{.HelpName}} TARGET NAME + +NAME: + Name of remote tier target. e.g WARM-TIER + +FLAGS: + {{range .VisibleFlags}}{{.}} + {{end}} +EXAMPLES: + 1. Validate a tier config given by name. + {{.Prompt}} {{.HelpName}} myminio WARM-TIER +`, +} diff --git a/cmd/admin-tier-edit.go b/cmd/ilm-tier-edit.go similarity index 99% rename from cmd/admin-tier-edit.go rename to cmd/ilm-tier-edit.go index 01f9481d..67993989 100644 --- a/cmd/admin-tier-edit.go +++ b/cmd/ilm-tier-edit.go @@ -58,6 +58,7 @@ var adminTierEditCmd = cli.Command{ Name: "edit", Usage: "update an existing remote tier configuration", Action: mainAdminTierEdit, + Hidden: true, OnUsageError: onUsageError, Before: setGlobalsFromContext, Flags: append(globalFlags, adminTierEditFlags...), diff --git a/cmd/admin-tier-info-ui.go b/cmd/ilm-tier-info-ui.go similarity index 100% rename from cmd/admin-tier-info-ui.go rename to cmd/ilm-tier-info-ui.go diff --git a/cmd/admin-tier-info.go b/cmd/ilm-tier-info.go similarity index 100% rename from cmd/admin-tier-info.go rename to cmd/ilm-tier-info.go diff --git a/cmd/admin-tier-listing.go b/cmd/ilm-tier-listing.go similarity index 100% rename from cmd/admin-tier-listing.go rename to cmd/ilm-tier-listing.go diff --git a/cmd/admin-tier-ls.go b/cmd/ilm-tier-ls.go similarity index 98% rename from cmd/admin-tier-ls.go rename to cmd/ilm-tier-ls.go index 5330659b..e8a0741a 100644 --- a/cmd/admin-tier-ls.go +++ b/cmd/ilm-tier-ls.go @@ -28,7 +28,7 @@ import ( var adminTierListCmd = cli.Command{ Name: "ls", - Usage: "lists configured remote tier targets", + Usage: "list configured remote tier targets", Action: mainAdminTierList, OnUsageError: onUsageError, Before: setGlobalsFromContext, diff --git a/cmd/ilm-tier-main.go b/cmd/ilm-tier-main.go new file mode 100644 index 00000000..a8af944d --- /dev/null +++ b/cmd/ilm-tier-main.go @@ -0,0 +1,46 @@ +// Copyright (c) 2022 MinIO, Inc. +// +// This file is part of MinIO Object Storage stack +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package cmd + +import "github.com/minio/cli" + +var ilmTierSubcommands = []cli.Command{ + adminTierInfoCmd, + adminTierListCmd, + adminTierAddCmd, + adminTierEditCmd, + ilmTierUpdateCmd, + adminTierVerifyCmd, + ilmTierCheckCmd, + adminTierRmCmd, +} + +var ilmTierCmd = cli.Command{ + Name: "tier", + Usage: "manage remote tiers", + Action: mainILMTier, + Before: setGlobalsFromContext, + Flags: globalFlags, + Subcommands: ilmTierSubcommands, + HideHelpCommand: true, +} + +func mainILMTier(ctx *cli.Context) error { + commandNotFound(ctx, ilmTierSubcommands) + return nil +} diff --git a/cmd/admin-tier-rm.go b/cmd/ilm-tier-rm.go similarity index 97% rename from cmd/admin-tier-rm.go rename to cmd/ilm-tier-rm.go index 68423840..12380737 100644 --- a/cmd/admin-tier-rm.go +++ b/cmd/ilm-tier-rm.go @@ -24,7 +24,7 @@ import ( var adminTierRmCmd = cli.Command{ Name: "rm", - Usage: "removes an empty remote tier", + Usage: "remove an empty remote tier", Action: mainAdminTierRm, OnUsageError: onUsageError, Before: setGlobalsFromContext, diff --git a/cmd/ilm-tier-update.go b/cmd/ilm-tier-update.go new file mode 100644 index 00000000..007fab02 --- /dev/null +++ b/cmd/ilm-tier-update.go @@ -0,0 +1,51 @@ +// Copyright (c) 2022 MinIO, Inc. +// +// This file is part of MinIO Object Storage stack +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package cmd + +import "github.com/minio/cli" + +var ilmTierUpdateCmd = cli.Command{ + Name: "update", + Usage: "update an existing remote tier configuration", + Action: mainAdminTierEdit, + OnUsageError: onUsageError, + Before: setGlobalsFromContext, + Flags: append(globalFlags, adminTierEditFlags...), + CustomHelpTemplate: `NAME: + {{.HelpName}} - {{.Usage}} + +USAGE: + {{.HelpName}} ALIAS NAME + +NAME: + Name of remote tier. e.g WARM-TIER + +FLAGS: + {{range .VisibleFlags}}{{.}} + {{end}} +EXAMPLES: + 1. Update credentials for an existing Azure Blob Storage remote tier: + {{.Prompt}} {{.HelpName}} myminio AZTIER --account-key ACCOUNT-KEY + + 2. Update credentials for an existing AWS S3 compatible remote tier: + {{.Prompt}} {{.HelpName}} myminio S3TIER --access-key ACCESS-KEY --secret-key SECRET-KEY + + 3. Update credentials for an existing Google Cloud Storage remote tier: + {{.Prompt}} {{.HelpName}} myminio GCSTIER --credentials-file /path/to/credentials.json +`, +} diff --git a/cmd/admin-tier-verify.go b/cmd/ilm-tier-verify.go similarity index 99% rename from cmd/admin-tier-verify.go rename to cmd/ilm-tier-verify.go index c3ecbe74..0cd044dd 100644 --- a/cmd/admin-tier-verify.go +++ b/cmd/ilm-tier-verify.go @@ -26,6 +26,7 @@ var adminTierVerifyCmd = cli.Command{ Name: "verify", Usage: "verifies if remote tier configuration is valid", Action: mainAdminTierVerify, + Hidden: true, OnUsageError: onUsageError, Before: setGlobalsFromContext, Flags: globalFlags,