Skip to content

Add dry run before letting user go in tui config#717

Open
brayan-trejo wants to merge 4 commits intomainfrom
update-tui
Open

Add dry run before letting user go in tui config#717
brayan-trejo wants to merge 4 commits intomainfrom
update-tui

Conversation

@brayan-trejo
Copy link
Contributor

What type of Pull Request is this? (check all applicable)

  • Refactor
  • [X ] Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Describe your changes in brief

  • Executes **cloudfuse mount <test-mnt-point> --config-file <config-file> --dry-run --passphrase <passphrase>** at end of tui configuration to ensure the generated configuration config.yaml.aes file functions correctly.

Checklist

  • [X ] Tested locally
  • Added new dependencies
  • Updated documentation
  • Added tests

Related Issues

  • Related Issue #
  • Closes #

Copy link
Contributor

@jfantinhardesty jfantinhardesty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

Comment on lines +1243 to +1249
var outBuf, errBuf bytes.Buffer
cmd.Stdout = &outBuf
cmd.Stderr = &errBuf
err := cmd.Run()
if err != nil {
return fmt.Errorf("Dry run failed: %v\n%s", err, errBuf.String())
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to capture stdout too?
Maybe you could simplify this and use CombinedOutput instead of Run().

Copy link
Contributor Author

@brayan-trejo brayan-trejo Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stdout is captured but I don't do anything with it for now because at least with the current implementation of --dry-run nothing is printed to stdout when successful, but I figured it's still good practice to capture it.

Copy link
Contributor Author

@brayan-trejo brayan-trejo Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked into it a bit more. With CombinedOutput(), a combined byte slice is returned and you cannot reliably tell where stdout ends and where stderr begins. The intent here is to cleanly separate these two, and print stderr only when an error occurs. Even though stdout doesn't print anything useful now, in the future if that changes, it'd be nice to have this template to conditionally do something with stdout.

Signed-off-by: Brayan Trejo <117423453+brayan-trejo@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants