iam export:designate zip file name (#4995)

Co-authored-by: Harshavardhana <harsha@minio.io>


---------

Co-authored-by: Harshavardhana <harsha@minio.io>
Co-authored-by: Klaus Post <klauspost@gmail.com>
Co-authored-by: Aditya Manthramurthy <donatello@users.noreply.github.com>
This commit is contained in:
dorman
2024-09-16 10:43:14 -07:00
committed by GitHub
co-authored by Harshavardhana Klaus Post Aditya Manthramurthy
parent 37095dadcc
commit 11ebe952ea
+17 -1
View File
@@ -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))