From 11ebe952ea30e426e564f66e78d178465ae7c432 Mon Sep 17 00:00:00 2001 From: dorman <37854724+dormanze@users.noreply.github.com> Date: Tue, 17 Sep 2024 01:43:14 +0800 Subject: [PATCH] iam export:designate zip file name (#4995) Co-authored-by: Harshavardhana --------- Co-authored-by: Harshavardhana Co-authored-by: Klaus Post Co-authored-by: Aditya Manthramurthy --- cmd/admin-cluster-iam-export.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/cmd/admin-cluster-iam-export.go b/cmd/admin-cluster-iam-export.go index 51209269..068bdde5 100644 --- a/cmd/admin-cluster-iam-export.go +++ b/cmd/admin-cluster-iam-export.go @@ -32,13 +32,23 @@ import ( "github.com/minio/pkg/v3/console" ) +// iam export specific flags. +var ( + iamExportFlags = []cli.Flag{ + cli.StringFlag{ + Name: "output,o", + Usage: "output iam export to a custom file path", + }, + } +) + var adminClusterIAMExportCmd = cli.Command{ Name: "export", Usage: "exports IAM info to zipped file", Action: mainClusterIAMExport, OnUsageError: onUsageError, Before: setGlobalsFromContext, - Flags: globalFlags, + Flags: append(iamExportFlags, globalFlags...), HideHelpCommand: true, CustomHelpTemplate: `NAME: {{.HelpName}} - {{.Usage}} @@ -52,6 +62,9 @@ FLAGS: EXAMPLES: 1. Download all IAM metadata for cluster into zip file. {{.Prompt}} {{.HelpName}} myminio + + 2. Download all IAM metadata to a custom file. + {{.Prompt}} {{.HelpName}} myminio --output /tmp/myminio-iam.zip `, } @@ -97,6 +110,9 @@ func mainClusterIAMExport(ctx *cli.Context) error { tmpFile.Close() downloadPath := fmt.Sprintf("%s-iam-info.%s", aliasedURL, ext) + if ctx.String("output") != "" { + downloadPath = ctx.String("output") + } fi, e := os.Stat(downloadPath) if e == nil && !fi.IsDir() { e = moveFile(downloadPath, downloadPath+"."+time.Now().Format(dateTimeFormatFilename))