From 034fef9a41ac948d7e43eab53f8bebc7f4fc5e28 Mon Sep 17 00:00:00 2001 From: chrislu Date: Wed, 19 Nov 2025 20:28:33 -0800 Subject: [PATCH] Update command_s3_configure.go --- weed/shell/command_s3_configure.go | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/weed/shell/command_s3_configure.go b/weed/shell/command_s3_configure.go index db816d5ef..eb5e15109 100644 --- a/weed/shell/command_s3_configure.go +++ b/weed/shell/command_s3_configure.go @@ -57,33 +57,27 @@ func (c *commandS3Configure) Do(args []string, commandEnv *CommandEnv, writer io return nil } - // Check which account flags were provided - var accountIdSet, accountDisplayNameSet, accountEmailSet bool + // Check which account flags were provided and build update functions + var accountUpdates []func(*iam_pb.Account) s3ConfigureCommand.Visit(func(f *flag.Flag) { switch f.Name { case "account_id": - accountIdSet = true + accountUpdates = append(accountUpdates, func(a *iam_pb.Account) { a.Id = *accountId }) case "account_display_name": - accountDisplayNameSet = true + accountUpdates = append(accountUpdates, func(a *iam_pb.Account) { a.DisplayName = *accountDisplayName }) case "account_email": - accountEmailSet = true + accountUpdates = append(accountUpdates, func(a *iam_pb.Account) { a.EmailAddress = *accountEmail }) } }) // Helper function to update account information on an identity updateAccountInfo := func(account **iam_pb.Account) { - if accountIdSet || accountDisplayNameSet || accountEmailSet { + if len(accountUpdates) > 0 { if *account == nil { *account = &iam_pb.Account{} } - if accountIdSet { - (*account).Id = *accountId - } - if accountDisplayNameSet { - (*account).DisplayName = *accountDisplayName - } - if accountEmailSet { - (*account).EmailAddress = *accountEmail + for _, update := range accountUpdates { + update(*account) } } }