Skip to content
This repository was archived by the owner on Feb 16, 2023. It is now read-only.

Commit e143f59

Browse files
committed
Make output summary match number of changes
1 parent 84ece54 commit e143f59

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

internals/secrethub/migrate.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -486,11 +486,11 @@ func (cmd *MigrateApplyCommand) Run() error {
486486
return err
487487
}
488488

489-
createCount := 0
489+
vaultCreateCount := 0
490+
itemCreateCount := 0
491+
fieldUpdateCount := 0
490492
warningCount := 0
491-
updateCount := 0
492493
skipCount := 0
493-
alreadyUpToDateCount := 0
494494

495495
var changes []change
496496

@@ -503,6 +503,7 @@ func (cmd *MigrateApplyCommand) Run() error {
503503
}
504504
if !vaultExists {
505505
changes = append(changes, vaultCreation{vault: vault.Name})
506+
vaultCreateCount++
506507
}
507508

508509
for _, item := range vault.Items {
@@ -522,14 +523,14 @@ func (cmd *MigrateApplyCommand) Run() error {
522523
return err
523524
}
524525
template.AddField(field.Name, value, field.Concealed)
525-
createCount++
526526
}
527527

528528
changes = append(changes, itemCreation{
529529
vault: vault.Name,
530530
item: item.Name,
531531
itemTemplate: template,
532532
})
533+
itemCreateCount++
533534
} else {
534535
opFields, err := onepassword.GetFields(vault.Name, item.Name)
535536
if err != nil {
@@ -551,9 +552,7 @@ func (cmd *MigrateApplyCommand) Run() error {
551552
}
552553
if value != opValue {
553554
fieldsToUpdate[field.Name] = value
554-
updateCount++
555-
} else {
556-
alreadyUpToDateCount++
555+
fieldUpdateCount++
557556
}
558557
}
559558
if len(fieldsToUpdate) > 0 {
@@ -584,10 +583,9 @@ func (cmd *MigrateApplyCommand) Run() error {
584583

585584
fmt.Fprintln(cmd.io.Output())
586585
fmt.Fprintln(cmd.io.Output(), "Summary:")
587-
fmt.Fprintf(cmd.io.Output(), "%d fields will be created\n", createCount)
588-
fmt.Fprintf(cmd.io.Output(), "%d fields will be updated\n", updateCount)
589-
fmt.Fprintf(cmd.io.Output(), "%d fields are already up-to-date\n", alreadyUpToDateCount)
590-
fmt.Fprintf(cmd.io.Output(), "%d fields will be skipped\n", skipCount)
586+
fmt.Fprintf(cmd.io.Output(), "%d vaults will be created\n", vaultCreateCount)
587+
fmt.Fprintf(cmd.io.Output(), "%d items will be created\n", itemCreateCount)
588+
fmt.Fprintf(cmd.io.Output(), "%d fields will be updated\n", fieldUpdateCount)
591589

592590
if !cmd.update {
593591
fmt.Fprintln(cmd.io.Output())

0 commit comments

Comments
 (0)