diff --git a/cmd/admin-main.go b/cmd/admin-main.go
index b78a9e3a..dc07c7cd 100644
--- a/cmd/admin-main.go
+++ b/cmd/admin-main.go
@@ -48,6 +48,7 @@ var adminCmdSubcommands = []cli.Command{
adminHealthCmd,
adminSubnetCmd,
adminBucketCmd,
+ adminTierCmd,
}
var adminCmd = cli.Command{
diff --git a/cmd/admin-tier-add.go b/cmd/admin-tier-add.go
new file mode 100644
index 00000000..ecd10c92
--- /dev/null
+++ b/cmd/admin-tier-add.go
@@ -0,0 +1,342 @@
+// Copyright (c) 2015-2021 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 (
+ "fmt"
+ "io/ioutil"
+
+ "github.com/fatih/color"
+ "github.com/minio/cli"
+ json "github.com/minio/colorjson"
+ madmin "github.com/minio/madmin-go"
+ "github.com/minio/mc/pkg/probe"
+ "github.com/minio/minio/pkg/console"
+)
+
+var adminTierAddFlags = []cli.Flag{
+ cli.StringFlag{
+ Name: "endpoint",
+ Value: "",
+ Usage: "remote tier endpoint. e.g https://s3.amazonaws.com",
+ },
+ cli.StringFlag{
+ Name: "region",
+ Value: "",
+ Usage: "remote tier region. e.g us-west-2",
+ },
+ cli.StringFlag{
+ Name: "access-key",
+ Value: "",
+ Usage: "AWS s3 or compatible object storage access-key",
+ },
+ cli.StringFlag{
+ Name: "secret-key",
+ Value: "",
+ Usage: "AWS s3 or compatible object storage secret-key",
+ },
+ cli.StringFlag{
+ Name: "account-name",
+ Value: "",
+ Usage: "Azure Blob Storage account name",
+ },
+ cli.StringFlag{
+ Name: "account-key",
+ Value: "",
+ Usage: "Azure Blob Storage account key",
+ },
+ cli.StringFlag{
+ Name: "credentials-file",
+ Value: "",
+ Usage: "Google Cloud Storage credentials file used to access/transition objects to GCS",
+ },
+ cli.StringFlag{
+ Name: "bucket",
+ Value: "",
+ Usage: "remote tier bucket",
+ },
+ cli.StringFlag{
+ Name: "prefix",
+ Value: "",
+ Usage: "remote tier prefix",
+ },
+ cli.StringFlag{
+ Name: "storage-class",
+ Value: "",
+ Usage: "remote tier storage-class",
+ },
+}
+
+var adminTierAddCmd = cli.Command{
+ Name: "add",
+ Usage: "add a new remote tier target",
+ Action: mainAdminTierAdd,
+ OnUsageError: onUsageError,
+ Before: setGlobalsFromContext,
+ Flags: append(globalFlags, adminTierAddFlags...),
+ CustomHelpTemplate: `NAME:
+ {{.HelpName}} - {{.Usage}}
+
+USAGE:
+ {{.HelpName}} TIER_TYPE TARGET NAME [TIER_FLAGS]
+
+NAME:
+ Name of remote tier target. e.g WARM-TIER
+
+TIER_TYPE:
+ Cloud storage backend where objects specified by bucket lifecycle configuration can be transitioned to.
+ Supported values are s3, azure and gcs.
+
+TIER_FLAGS:
+ Tier type specific flags.
+
+FLAGS:
+ {{range .VisibleFlags}}{{.}}
+ {{end}}
+EXAMPLES:
+ 1. Configure a new remote tier which transitions objects to a bucket in Azure Blob Storage.
+ {{.Prompt}} {{.HelpName}} azure myminio AZTIER --account-name foobar --account-key foobar123 --region us-east-1 --bucket testbucket --prefix testprefix/
+
+ 2. 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 foobar --secret-key foobar123 --region us-east-1 --bucket testbucket --prefix testprefix/ --storage-class "STANDARD"
+
+ 3. Configure a new remote tier which transitions objects to a bucket in Google Cloud Storage.
+ {{.Prompt}} {{.HelpName}} s3 myminio GCSTIER --credentials-file --region us-east-1 --bucket testbucket --prefix testprefix/
+
+`,
+}
+
+// checkAdminTierAddSyntax validates all the positional arguments
+func checkAdminTierAddSyntax(ctx *cli.Context) {
+ argsNr := len(ctx.Args())
+ if argsNr < 3 {
+ cli.ShowCommandHelpAndExit(ctx, ctx.Command.Name, 1) // last argument is exit code
+ }
+ if argsNr > 3 {
+ fatalIf(errInvalidArgument().Trace(ctx.Args().Tail()...),
+ "Incorrect number of arguments for tier add command.")
+ }
+}
+
+const (
+ s3Standard = "STANDARD"
+ s3ReducedRedundancy = "REDUCED_REDUNDANCY"
+)
+
+// fetchTierConfig returns a TierConfig given a tierName, a tierType and ctx to
+// lookup command-line flags from. It exits with non-zero error code if any of
+// the flags contain invalid values.
+func fetchTierConfig(ctx *cli.Context, tierName string, tierType madmin.TierType) *madmin.TierConfig {
+ switch tierType {
+ case madmin.S3:
+ accessKey := ctx.String("access-key")
+ secretKey := ctx.String("secret-key")
+ if accessKey == "" || secretKey == "" {
+ fatalIf(errInvalidArgument().Trace(), fmt.Sprintf("%s remote tier requires access credentials", tierType))
+ }
+
+ bucket := ctx.String("bucket")
+ if bucket == "" {
+ fatalIf(errInvalidArgument().Trace(), fmt.Sprintf("%s remote tier requires target bucket", tierType))
+ }
+
+ s3Opts := []madmin.S3Options{}
+ prefix := ctx.String("prefix")
+ if prefix != "" {
+ s3Opts = append(s3Opts, madmin.S3Prefix(prefix))
+ }
+
+ endpoint := ctx.String("endpoint")
+ if endpoint != "" {
+ s3Opts = append(s3Opts, madmin.S3Endpoint(endpoint))
+ }
+
+ region := ctx.String("region")
+ if region != "" {
+ s3Opts = append(s3Opts, madmin.S3Region(region))
+ }
+
+ s3SC := ctx.String("storage-class")
+ if s3SC != "" {
+ if s3SC != s3Standard && s3SC != s3ReducedRedundancy {
+ fatalIf(errInvalidArgument().Trace(), fmt.Sprintf("unsupported storage-class type %s", s3SC))
+ }
+ s3Opts = append(s3Opts, madmin.S3StorageClass(s3SC))
+ }
+
+ s3Cfg, err := madmin.NewTierS3(tierName, accessKey, secretKey, bucket, s3Opts...)
+ if err != nil {
+ fatalIf(probe.NewError(err), "Invalid configuration for AWS S3 compatible remote tier")
+ }
+
+ return s3Cfg
+ case madmin.Azure:
+ accountName := ctx.String("account-name")
+ accountKey := ctx.String("account-key")
+ if accountName == "" || accountKey == "" {
+ fatalIf(errInvalidArgument().Trace(), fmt.Sprintf("%s remote tier requires access credentials", tierType))
+ }
+
+ bucket := ctx.String("bucket")
+ if bucket == "" {
+ fatalIf(errInvalidArgument().Trace(), fmt.Sprintf("%s remote tier requires target bucket", tierType))
+ }
+
+ azOpts := []madmin.AzureOptions{}
+ endpoint := ctx.String("endpoint")
+ if endpoint != "" {
+ azOpts = append(azOpts, madmin.AzureEndpoint(endpoint))
+ }
+
+ region := ctx.String("region")
+ if region != "" {
+ azOpts = append(azOpts, madmin.AzureRegion(region))
+ }
+
+ prefix := ctx.String("prefix")
+ if prefix != "" {
+ azOpts = append(azOpts, madmin.AzurePrefix(prefix))
+ }
+
+ azCfg, err := madmin.NewTierAzure(tierName, accountName, accountKey, bucket, azOpts...)
+ if err != nil {
+ fatalIf(probe.NewError(err), "Invalid configuration for Azure Blob Storage remote tier")
+ }
+
+ return azCfg
+ case madmin.GCS:
+ bucket := ctx.String("bucket")
+ if bucket == "" {
+ fatalIf(errInvalidArgument().Trace(), fmt.Sprintf("%s remote requires target bucket", tierType))
+ }
+
+ gcsOpts := []madmin.GCSOptions{}
+ prefix := ctx.String("prefix")
+ if prefix != "" {
+ gcsOpts = append(gcsOpts, madmin.GCSPrefix(prefix))
+ }
+
+ region := ctx.String("region")
+ if region != "" {
+ gcsOpts = append(gcsOpts, madmin.GCSRegion(region))
+ }
+
+ credsPath := ctx.String("credentials-file")
+ credsBytes, err := ioutil.ReadFile(credsPath)
+ if err != nil {
+ fatalIf(probe.NewError(err), "Failed to read credentials file")
+ }
+
+ gcsCfg, err := madmin.NewTierGCS(tierName, credsBytes, bucket, gcsOpts...)
+ if err != nil {
+ fatalIf(probe.NewError(err), "Invalid configuration for Google Cloud Storage remote tier")
+ }
+
+ return gcsCfg
+ }
+ fatalIf(errInvalidArgument().Trace(), fmt.Sprintf("Invalid remote tier type %s", tierType))
+ return nil
+}
+
+type tierMessage struct {
+ op string
+ Status string `json:"status"`
+ TierName string `json:"tierName"`
+ TierType string `json:"tierType"`
+ Endpoint string `json:"tierEndpoint"`
+ Bucket string `json:"bucket"`
+ Prefix string `json:"prefix,omitempty"`
+ Region string `json:"region,omitempty"`
+ TierParams map[string]string `json:"tierParams,omitempty"`
+}
+
+// String returns string representation of msg
+func (msg *tierMessage) String() string {
+ switch msg.op {
+ case "add":
+ addMsg := fmt.Sprintf("Added remote tier %s of type %s", msg.TierName, msg.TierType)
+ return console.Colorize("TierMessage", addMsg)
+ case "ls":
+ // nothing to do here; ls has its own type to use with printMsg
+ case "rm":
+ rmMsg := fmt.Sprintf("Removed remote tier %s", msg.TierName)
+ return console.Colorize("TierMessage", rmMsg)
+ case "edit":
+ editMsg := fmt.Sprintf("Updated remote tier %s", msg.TierName)
+ return console.Colorize("TierMessage", editMsg)
+ }
+ return ""
+}
+
+// JSON returns json encoded msg
+func (msg *tierMessage) JSON() string {
+ jsonMessageBytes, e := json.MarshalIndent(msg, "", " ")
+ fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
+
+ return string(jsonMessageBytes)
+}
+
+// SetTierConfig sets TierConfig related fields
+func (msg *tierMessage) SetTierConfig(sCfg *madmin.TierConfig) {
+ msg.TierName = sCfg.Name
+ msg.TierType = sCfg.Type.String()
+ msg.Endpoint = sCfg.Endpoint()
+ msg.Bucket = sCfg.Bucket()
+ msg.Prefix = sCfg.Prefix()
+ msg.Region = sCfg.Region()
+ switch sCfg.Type {
+ case madmin.S3:
+ msg.TierParams = map[string]string{
+ "storageClass": sCfg.S3.StorageClass,
+ }
+ }
+}
+
+func mainAdminTierAdd(ctx *cli.Context) error {
+ checkAdminTierAddSyntax(ctx)
+
+ console.SetColor("TierMessage", color.New(color.FgGreen))
+
+ args := ctx.Args()
+ tierTypeStr := args.Get(0)
+ tierType, err := madmin.NewTierType(tierTypeStr)
+ fatalIf(probe.NewError(err), "Unsupported tier type")
+
+ aliasedURL := args.Get(1)
+ tierName := args.Get(2)
+ if tierName == "" {
+ fatalIf(errInvalidArgument(), "Tier name can't be empty")
+ }
+
+ // Create a new MinIO Admin Client
+ client, cerr := newAdminClient(aliasedURL)
+ fatalIf(cerr, "Unable to initialize admin connection.")
+
+ tCfg := fetchTierConfig(ctx, tierName, tierType)
+ if err = client.AddTier(globalContext, tCfg); err != nil {
+ fatalIf(probe.NewError(err).Trace(args...), "Unable to configure remote tier target")
+ }
+
+ msg := &tierMessage{
+ op: "add",
+ Status: "success",
+ }
+ msg.SetTierConfig(tCfg)
+ printMsg(msg)
+ return nil
+}
diff --git a/cmd/admin-tier-edit.go b/cmd/admin-tier-edit.go
new file mode 100644
index 00000000..ecd7cc9b
--- /dev/null
+++ b/cmd/admin-tier-edit.go
@@ -0,0 +1,149 @@
+// Copyright (c) 2015-2021 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 (
+ "io/ioutil"
+
+ "github.com/fatih/color"
+ "github.com/minio/cli"
+ madmin "github.com/minio/madmin-go"
+ "github.com/minio/mc/pkg/probe"
+ "github.com/minio/minio/pkg/console"
+)
+
+var adminTierEditFlags = []cli.Flag{
+ cli.StringFlag{
+ Name: "access-key",
+ Value: "",
+ Usage: "AWS s3 or compatible object storage access-key",
+ },
+ cli.StringFlag{
+ Name: "secret-key",
+ Value: "",
+ Usage: "AWS s3 or compatible object storage secret-key",
+ },
+ cli.StringFlag{
+ Name: "account-name",
+ Value: "",
+ Usage: "Azure Blob Storage account name",
+ },
+ cli.StringFlag{
+ Name: "account-key",
+ Value: "",
+ Usage: "Azure Blob Storage account key",
+ },
+ cli.StringFlag{
+ Name: "credentials-file",
+ Value: "",
+ Usage: "gcs credentials file used to access/transition objects to GCS",
+ },
+}
+
+var adminTierEditCmd = cli.Command{
+ Name: "edit",
+ Usage: "edits a remote tier",
+ Action: mainAdminTierEdit,
+ OnUsageError: onUsageError,
+ Before: setGlobalsFromContext,
+ Flags: adminTierEditFlags,
+ CustomHelpTemplate: `NAME:
+ {{.HelpName}} - {{.Usage}}
+
+USAGE:
+ {{.HelpName}} TARGET 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-name foobar-new --account-key foobar-new123
+
+ 2. Update credentials for an existing AWS S3 compatible remote tier.
+ {{.Prompt}} {{.HelpName}} myminio S3TIER --access-key foobar-new --secret-key foobar-new123
+
+ 3. Update credentials for an existing Google Cloud Storage remote tier.
+ {{.Prompt}} {{.HelpName}} myminio GCSTIER --credentials-file /path/to/updated-creds.json
+`,
+}
+
+// checkAdminTierEditSyntax - validate all the postitional arguments
+func checkAdminTierEditSyntax(ctx *cli.Context) {
+ argsNr := len(ctx.Args())
+ if argsNr < 2 {
+ cli.ShowCommandHelpAndExit(ctx, ctx.Command.Name, 1) // last argument is exit code
+ }
+ if argsNr > 2 {
+ fatalIf(errInvalidArgument().Trace(ctx.Args().Tail()...),
+ "Incorrect number of arguments for tier-edit subcommand.")
+ }
+}
+
+func mainAdminTierEdit(ctx *cli.Context) error {
+ checkAdminTierEditSyntax(ctx)
+
+ console.SetColor("TierMessage", color.New(color.FgGreen))
+
+ args := ctx.Args()
+ aliasedURL := args.Get(0)
+ tierName := args.Get(1)
+
+ // Create a new MinIO Admin Client
+ client, cerr := newAdminClient(aliasedURL)
+ fatalIf(cerr, "Unable to initialize admin connection.")
+
+ var creds madmin.TierCreds
+ accessKey := ctx.String("access-key")
+ secretKey := ctx.String("secret-key")
+ accountName := ctx.String("account-name")
+ accountKey := ctx.String("account-key")
+ credsPath := ctx.String("credentials-file")
+
+ switch {
+ case accessKey != "" && secretKey != "": // S3 tier
+ creds.AccessKey = accessKey
+ creds.SecretKey = secretKey
+ case accountName != "" && accountKey != "": // Azure tier
+ creds.AccessKey = accountName
+ creds.SecretKey = accountKey
+ case credsPath != "": // GCS tier
+ credsBytes, err := ioutil.ReadFile(credsPath)
+ if err != nil {
+ fatalIf(probe.NewError(err), "Failed to read credentials file")
+ }
+ creds.CredsJSON = credsBytes
+ default:
+ fatalIf(errInvalidArgument().Trace(args.Tail()...), "Insufficient credential information supplied to update remote tier target credentials")
+ }
+
+ if err := client.EditTier(globalContext, tierName, creds); err != nil {
+ fatalIf(probe.NewError(err).Trace(args...), "Unable to edit remote tier")
+ }
+
+ printMsg(&tierMessage{
+ op: "edit",
+ Status: "success",
+ TierName: tierName,
+ })
+ return nil
+}
diff --git a/cmd/admin-tier-ls.go b/cmd/admin-tier-ls.go
new file mode 100644
index 00000000..f7e1ca04
--- /dev/null
+++ b/cmd/admin-tier-ls.go
@@ -0,0 +1,211 @@
+// Copyright (c) 2015-2021 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 (
+ "fmt"
+
+ "github.com/fatih/color"
+ "github.com/minio/cli"
+ json "github.com/minio/colorjson"
+ madmin "github.com/minio/madmin-go"
+ "github.com/minio/mc/pkg/probe"
+ "github.com/minio/minio/pkg/console"
+)
+
+var adminTierListCmd = cli.Command{
+ Name: "ls",
+ Usage: "lists remote tier targets",
+ Action: mainAdminTierList,
+ OnUsageError: onUsageError,
+ Before: setGlobalsFromContext,
+ Flags: globalFlags,
+ CustomHelpTemplate: `NAME:
+ {{.HelpName}} - {{.Usage}}
+
+USAGE:
+ {{.HelpName}} TARGET
+
+FLAGS:
+ {{range .VisibleFlags}}{{.}}
+ {{end}}
+
+EXAMPLES:
+ 1. List remote tier targets configured in myminio
+ {{.Prompt}} {{.HelpName}} myminio
+`,
+}
+
+// checkAdminTierListSyntax - validate all the passed arguments
+func checkAdminTierListSyntax(ctx *cli.Context) {
+ argsNr := len(ctx.Args())
+ if argsNr < 1 {
+ cli.ShowCommandHelpAndExit(ctx, ctx.Command.Name, 1) // last argument is exit code
+ }
+ if argsNr > 1 {
+ fatalIf(errInvalidArgument().Trace(ctx.Args().Tail()...),
+ "Incorrect number of arguments for tier-ls subcommand.")
+ }
+}
+
+type tierRowHdr int
+
+const (
+ tierNameHdr tierRowHdr = iota
+ tierTypeHdr
+ tierEndpointHdr
+ tierBucketHdr
+ tierPrefixHdr
+ tierRegionHdr
+ tierStorageClassHdr
+)
+
+var tierRowNames = []string{
+ "Name",
+ "Type",
+ "Endpoint",
+ "Bucket",
+ "Prefix",
+ "Region",
+ "Storage-Class",
+}
+
+var tierColorScheme = []*color.Color{
+ color.New(color.FgYellow),
+ color.New(color.FgCyan),
+ color.New(color.FgGreen),
+ color.New(color.FgHiWhite),
+ color.New(color.FgHiWhite),
+ color.New(color.FgHiWhite),
+ color.New(color.FgCyan),
+}
+
+func storageClass(t *madmin.TierConfig) string {
+ switch t.Type {
+ case madmin.S3:
+ return t.S3.StorageClass
+ case madmin.Azure:
+ return t.Azure.StorageClass
+ case madmin.GCS:
+ return t.GCS.StorageClass
+ default:
+ return ""
+ }
+}
+
+type tierCfg struct {
+ *madmin.TierConfig
+}
+
+func (tc *tierCfg) toRow(lengths []int) []string {
+ row := make([]string, len(tierRowNames))
+ row[tierNameHdr] = tc.Name
+ row[tierTypeHdr] = tc.Type.String()
+ row[tierEndpointHdr] = tc.Endpoint()
+ row[tierBucketHdr] = tc.Bucket()
+ row[tierPrefixHdr] = tc.Prefix()
+ row[tierRegionHdr] = tc.Region()
+ row[tierStorageClassHdr] = storageClass(tc.TierConfig)
+ for i := range tierRowNames {
+ if lengths[i] < len(row[i]) {
+ lengths[i] = len(row[i])
+ }
+ }
+ return row
+}
+
+// getTierListRowsAndCols returns a list of rows and a list of column header
+// metadata like color theme and max cell length, given a list of tiers. Each
+// row is represented by a list of cells in that row.
+func getTierListRowsAndCols(tiers []*madmin.TierConfig) ([][]string, []Field) {
+ rows := make([][]string, len(tiers))
+ rows[0] = tierRowNames
+ lengths := make([]int, len(rows[0]))
+ for i := range lengths {
+ lengths[i] = len(rows[0][i])
+ }
+ for _, tier := range tiers {
+ tierCfg := tierCfg{tier}
+ rows = append(rows, tierCfg.toRow(lengths))
+ }
+ // add 2 spaces to each column's max length to improve readability of
+ // each cell
+ cols := make([]Field, len(tierRowNames))
+ for i, hdr := range rows[0] {
+ cols[i] = Field{
+ colorTheme: hdr,
+ maxLen: lengths[i] + 2,
+ }
+ }
+ return rows, cols
+}
+
+type tierListMessage struct {
+ Status string `json:"status"`
+ Context *cli.Context `json:"-"`
+ Tiers []*madmin.TierConfig `json:"tiers"`
+}
+
+// String method returns a tabular listing of remote tier configurations.
+func (msg *tierListMessage) String() string {
+ if len(msg.Tiers) == 0 {
+ return "No remote tier has been configured"
+ }
+
+ const tableSeparator = "|"
+ rows, cols := getTierListRowsAndCols(msg.Tiers)
+ tbl := newPrettyTable(tableSeparator, cols...)
+ var contents string
+ for _, row := range rows {
+ contents += fmt.Sprintf("%s\n", tbl.buildRow(row...))
+ }
+ return contents
+}
+
+// JSON method returns JSON encoding of msg.
+func (msg *tierListMessage) JSON() string {
+ b, _ := json.Marshal(msg)
+ return string(b)
+}
+
+func mainAdminTierList(ctx *cli.Context) error {
+ checkAdminTierListSyntax(ctx)
+
+ for i, color := range tierColorScheme {
+ console.SetColor(tierRowNames[i], color)
+ }
+
+ args := ctx.Args()
+ aliasedURL := args.Get(0)
+
+ // Create a new MinIO Admin Client
+ client, cerr := newAdminClient(aliasedURL)
+ fatalIf(cerr, "Unable to initialize admin connection.")
+
+ tiers, err := client.ListTiers(globalContext)
+ if err != nil {
+ fatalIf(probe.NewError(err).Trace(args...), "Unable to list configured remote tier targets")
+ }
+
+ printMsg(&tierListMessage{
+ Status: "success",
+ Context: ctx,
+ Tiers: tiers,
+ })
+ return nil
+}
diff --git a/cmd/admin-tier-main.go b/cmd/admin-tier-main.go
new file mode 100644
index 00000000..09464714
--- /dev/null
+++ b/cmd/admin-tier-main.go
@@ -0,0 +1,43 @@
+// Copyright (c) 2015-2021 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 adminTierSubCommands = []cli.Command{
+ adminTierAddCmd,
+ adminTierListCmd,
+ adminTierEditCmd,
+}
+
+var adminTierCmd = cli.Command{
+ Name: "tier",
+ Usage: "configure remote tier targets for ILM transition",
+ Action: mainAdminTier,
+ Before: setGlobalsFromContext,
+ Flags: globalFlags,
+ Subcommands: adminTierSubCommands,
+ HideHelpCommand: true,
+}
+
+// mainAdminTier is the handle for "mc admin tier" command.
+func mainAdminTier(ctx *cli.Context) error {
+ commandNotFound(ctx, adminTierSubCommands)
+ return nil
+ // Sub-commands like "add", "ls" and "edit" have their own main.
+}
diff --git a/cmd/auto-complete.go b/cmd/auto-complete.go
index e49a4d1e..35950a9c 100644
--- a/cmd/auto-complete.go
+++ b/cmd/auto-complete.go
@@ -368,6 +368,10 @@ var completeCmds = map[string]complete.Predictor{
"/admin/subnet/health": aliasCompleter,
+ "/admin/tier/add": nil,
+ "/admin/tier/edit": nil,
+ "/admin/tier/ls": nil,
+
"/alias/set": nil,
"/alias/list": aliasCompleter,
"/alias/remove": aliasCompleter,
diff --git a/go.mod b/go.mod
index 629273e6..97e708a3 100644
--- a/go.mod
+++ b/go.mod
@@ -12,7 +12,6 @@ require (
github.com/klauspost/compress v1.12.2
github.com/mattn/go-ieproxy v0.0.1
github.com/mattn/go-isatty v0.0.12
- github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/minio/cli v1.22.0
github.com/minio/colorjson v1.0.0
github.com/minio/filepath v1.0.0 // indirect
diff --git a/go.sum b/go.sum
index f0d2dfa8..aa0f7d6f 100644
--- a/go.sum
+++ b/go.sum
@@ -308,9 +308,8 @@ github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOA
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
+github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y=
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
-github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
-github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
@@ -776,7 +775,6 @@ honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
-honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
maze.io/x/duration v0.0.0-20160924141736-faac084b6075 h1:4zVed9rL46683x3koxOYLzh8FlLFjnRrzTo2uvgA5D4=
maze.io/x/duration v0.0.0-20160924141736-faac084b6075/go.mod h1:1kfR2ph3CIvtfIQ8D8JhmAgePmnAUnR+AWYWUBo+l08=