Files
s3-cli/cmd/alias-export.go
zeekay a3245a76f4 Rebrand: Hanzo S3 CLI -- remove all MinIO branding
- Replace copyright headers: "MinIO, Inc." -> "Hanzo AI, Inc." across 411+ Go files
- Replace "MinIO Object Storage stack" -> "Hanzo S3 stack" in all file headers
- Replace all user-facing "MinIO" references -> "Hanzo S3" in Usage, help text, examples
- Replace example alias "myminio" -> "mys3" throughout
- Replace example endpoints play.min.io -> s3.hanzo.ai, dl.min.io -> s3.hanzo.ai
- Replace doc URLs min.io -> hanzo.space
- Rewrite README.md/README_zh_CN.md: product is "Hanzo S3 CLI" (the s3 command)
- Update CONTRIBUTING.md, CONFLICT.md, NOTICE, code_of_conduct.md
- Update all Dockerfiles: labels, entrypoints, image refs -> ghcr.io/hanzos3/cli
- Update Makefile: build output, docker tags, install paths -> s3
- Update docker-buildx.sh: image tags -> ghcr.io/hanzos3/cli
- DO NOT change go.mod module path or import paths (github.com/minio/mc preserved)
- DO NOT change Go identifiers, SDK types, or wire protocol constants
- All unit tests pass
2026-02-21 14:19:07 -08:00

89 lines
2.2 KiB
Go

package cmd
import (
"github.com/minio/cli"
json "github.com/minio/colorjson"
"github.com/minio/mc/pkg/probe"
"github.com/minio/pkg/v3/console"
)
var aliasExportCmd = cli.Command{
Name: "export",
ShortName: "e",
Usage: "export configuration info to stdout",
Action: mainAliasExport,
OnUsageError: onUsageError,
Before: setGlobalsFromContext,
Flags: globalFlags,
HideHelpCommand: true,
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
USAGE:
{{.HelpName}} ALIAS
Credentials to be exported will be in the following JSON format:
{
"url": "http://localhost:9000",
"accessKey": "YJ0RI0F4R5HWY38MD873",
"secretKey": "OHz5CT7xdMHiXnKZP0BmZ5P4G5UvWvVaxR8gljLG",
"api": "s3v4",
"path": "auto"
}
FLAGS:
{{range .VisibleFlags}}{{.}}
{{end}}
EXAMPLES:
1. Export the provided 'alias' to credentials.json file:
{{ .Prompt }} {{ .HelpName }} mys3/ > credentials.json
2. Export the credentials to standard output and pipe it to import command
{{ .Prompt }} {{ .HelpName }} alias1/ | mc alias import alias2/
`,
}
// checkAliasExportSyntax - verifies input arguments to 'alias export'.
func checkAliasExportSyntax(ctx *cli.Context) {
args := ctx.Args()
if ctx.NArg() == 0 {
showCommandHelpAndExit(ctx, 1)
}
if ctx.NArg() > 1 {
fatalIf(errInvalidArgument().Trace(ctx.Args().Tail()...),
"Incorrect number of arguments for alias export command.")
}
alias := cleanAlias(args.Get(0))
if !isValidAlias(alias) {
fatalIf(errInvalidAlias(alias), "Unable to validate alias")
}
}
// exportAlias - get an alias config
func exportAlias(alias string) {
mcCfgV10, err := loadMcConfig()
fatalIf(err.Trace(globalMCConfigVersion), "Unable to load config `"+mustGetMcConfigPath()+"`.")
cfg, ok := mcCfgV10.Aliases[alias]
if !ok {
fatalIf(errInvalidArgument().Trace(alias), "Unable to export credentials")
}
buf, e := json.Marshal(cfg)
fatalIf(probe.NewError(e).Trace(alias), "Unable to export credentials")
console.Println(string(buf))
}
func mainAliasExport(cli *cli.Context) error {
args := cli.Args()
checkAliasExportSyntax(cli)
exportAlias(cleanAlias(args.Get(0)))
return nil
}