Skip to content

Commit af3c89d

Browse files
committed
consistent name printing
1 parent f063ea9 commit af3c89d

2 files changed

Lines changed: 11 additions & 13 deletions

File tree

pkg/cmd/deregister/deregister.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,8 @@ func runDeregister(ctx context.Context, t *terminal.Terminal, s DeregisterStore,
127127
t.Vprint("")
128128
t.Vprint(t.Green(" Please confirm before continuing:"))
129129
t.Vprint("")
130-
t.Vprintf(" %s %s\n", t.Green(fmt.Sprintf("%-14s", "Device name:")), t.BoldBlue(reg.DisplayName))
131-
t.Vprintf(" %s %s\n", t.Green(fmt.Sprintf("%-14s", "Organization:")), t.BoldBlue(orgName))
132-
t.Vprintf(" %s %s\n", t.Green(fmt.Sprintf("%-14s", "Node ID:")), t.BoldBlue(reg.ExternalNodeID))
130+
t.Vprintf(" %s %s\n", t.Green(fmt.Sprintf("%-14s", "Device:")), t.BoldBlue(reg.DisplayName+" ("+reg.ExternalNodeID+")"))
131+
t.Vprintf(" %s %s\n", t.Green(fmt.Sprintf("%-14s", "Organization:")), t.BoldBlue(orgName+" ("+reg.OrgID+")"))
133132
t.Vprintf(" %s %s\n", t.Green(fmt.Sprintf("%-14s", "Linux user:")), t.BoldBlue(linuxUser))
134133
t.Vprint("")
135134
t.Vprint(t.Yellow(" This will:"))

pkg/cmd/register/register.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,6 @@ func runRegisterPromptDriven(ctx context.Context, t *terminal.Terminal, s Regist
305305
if err != nil {
306306
return breverrors.WrapAndTrace(err)
307307
}
308-
osUser, err := user.Current()
309-
if err != nil {
310-
return fmt.Errorf("failed to determine current Linux user: %w", err)
311-
}
312308

313309
t.Vprint("")
314310
t.Vprint(t.White("══════════════════════════════════════════════════"))
@@ -317,9 +313,8 @@ func runRegisterPromptDriven(ctx context.Context, t *terminal.Terminal, s Regist
317313
t.Vprint("")
318314
t.Vprint(t.Green(" Please confirm before continuing:"))
319315
t.Vprint("")
320-
t.Vprintf(" %s %s\n", t.Green(fmt.Sprintf("%-14s", "Device name:")), t.BoldBlue(name))
321-
t.Vprintf(" %s %s\n", t.Green(fmt.Sprintf("%-14s", "Organization:")), t.BoldBlue(org.Name))
322-
t.Vprintf(" %s %s\n", t.Green(fmt.Sprintf("%-14s", "Linux user:")), t.BoldBlue(osUser.Username))
316+
t.Vprintf(" %s %s\n", t.Green(fmt.Sprintf("%-14s", "Device:")), t.BoldBlue(name))
317+
t.Vprintf(" %s %s\n", t.Green(fmt.Sprintf("%-14s", "Organization:")), t.BoldBlue(org.Name+" ("+org.ID+")"))
323318
t.Vprint("")
324319
t.Vprint(t.Yellow(" This will:"))
325320
t.Vprint(" 1. Set up Brev tunnel")
@@ -338,6 +333,10 @@ func runRegisterPromptDriven(ctx context.Context, t *terminal.Terminal, s Regist
338333
}
339334

340335
if deps.prompter.ConfirmYesNo("Would you like to enable SSH access to this device?") {
336+
osUser, err := user.Current()
337+
if err != nil {
338+
return fmt.Errorf("failed to determine current Linux user: %w", err)
339+
}
341340
if err := grantSSHAccessWithPort(ctx, t, deps, s, reg, brevUser, osUser, 0); err != nil {
342341
t.Vprintf(" Warning: SSH access not granted: %v\n", err)
343342
}
@@ -512,9 +511,9 @@ func grantSSHAccessWithPort(ctx context.Context, t *terminal.Terminal, deps regi
512511
t.Vprint("")
513512
t.Vprint(t.Green(" Please confirm before continuing:"))
514513
t.Vprint("")
515-
t.Vprintf(" %s %s\n", t.Green(fmt.Sprintf("%-14s", "Device name:")), t.BoldBlue(reg.DisplayName))
516-
t.Vprintf(" %s %s\n", t.Green(fmt.Sprintf("%-14s", "Node ID:")), t.BoldBlue(reg.ExternalNodeID))
517-
t.Vprintf(" %s %s\n", t.Green(fmt.Sprintf("%-14s", "Brev user:")), t.BoldBlue(brevUser.ID))
514+
t.Vprintf(" %s %s\n", t.Green(fmt.Sprintf("%-14s", "Device:")), t.BoldBlue(reg.DisplayName+" ("+reg.ExternalNodeID+")"))
515+
t.Vprintf(" %s %s\n", t.Green(fmt.Sprintf("%-14s", "Organization:")), t.BoldBlue(reg.OrgName+" ("+reg.OrgID+")"))
516+
t.Vprintf(" %s %s\n", t.Green(fmt.Sprintf("%-14s", "Brev user:")), t.BoldBlue(brevUser.Username+" ("+brevUser.ID+")"))
518517
t.Vprintf(" %s %s\n", t.Green(fmt.Sprintf("%-14s", "Linux user:")), t.BoldBlue(osUser.Username))
519518

520519
var err error

0 commit comments

Comments
 (0)