From 19200e5cf35f8228f2ad3f811034eac99832ac0c Mon Sep 17 00:00:00 2001 From: Brayan Trejo <117423453+brayan-trejo@users.noreply.github.com> Date: Thu, 19 Mar 2026 11:32:42 -0600 Subject: [PATCH 1/2] Add dry run before letting user go in tui config (#717) * change config.aes to config.yaml.aes * add initial implementation of dry run feature in tui config * add comment to dry run function --------- Signed-off-by: Brayan Trejo <117423453+brayan-trejo@users.noreply.github.com> --- cmd/config.go | 80 ++++++++++++++++++++++++++++++++++++++---------- config.yaml.aes | Bin 0 -> 508 bytes 2 files changed, 63 insertions(+), 17 deletions(-) create mode 100644 config.yaml.aes diff --git a/cmd/config.go b/cmd/config.go index 83c935e4c..12de057c0 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -26,9 +26,11 @@ package cmd import ( + "bytes" "fmt" "net/url" "os" + "os/exec" "path/filepath" "slices" "strconv" @@ -929,13 +931,10 @@ func (tui *appContext) buildCachingPage() tview.Primitive { tui.showCacheConfirmationModal(cacheSizeText, // Callback function if the user selects Finish func() { - if err := tui.createYAMLConfig(); err != nil { - tui.showErrorModal( - "[red::b]ERROR:[-::-] Failed to create YAML config:\n"+err.Error(), - func() { - tui.pages.SwitchToPage("page5") - }, - ) + if err := tui.exitConfig(); err != nil { + tui.showErrorModal("[red::b]ERROR:[-::-]\n"+err.Error(), func() { + tui.pages.SwitchToPage("page5") + }) return } tui.showExitModal(func() { @@ -949,13 +948,10 @@ func (tui *appContext) buildCachingPage() tview.Primitive { } else { // If caching is disabled, just finish the configuration - if err := tui.createYAMLConfig(); err != nil { - tui.showErrorModal( - "[red::b]ERROR:[-::-] Failed to create YAML config:\n"+err.Error(), - func() { - tui.pages.SwitchToPage("page5") - }, - ) + if err := tui.exitConfig(); err != nil { + tui.showErrorModal("[red::b]ERROR:[-::-]\n"+err.Error(), func() { + tui.pages.SwitchToPage("page5") + }) return } tui.showExitModal(func() { @@ -1218,6 +1214,56 @@ func (tui *appContext) showExitModal(onConfirm func()) { }() } +// Function to handle exiting the configuration process. +// Creates the YAML config file and executes a dry run. +func (tui *appContext) exitConfig() error { + if err := tui.createYAMLConfig(); err != nil { + return fmt.Errorf("Failed to create YAML config:\n%v", err) + } + if err := tui.dryRun(); err != nil { + return fmt.Errorf("Configuration validation failed:\n%v", err) + } + return nil +} + +// Function to perform a dry run of cloudfuse with the generated config file. +func (tui *appContext) dryRun() error { + // Create /tmp/mnt-test directory if it doesn't exist. Needs to be empty for dry run. + mountPoint := filepath.Join(os.TempDir(), "mnt-test") + if _, err := os.Stat(mountPoint); os.IsNotExist(err) { + if err := os.MkdirAll(mountPoint, 0700); err != nil { + return fmt.Errorf( + "Failed to create test mount point '%s' for dry run: %v", + mountPoint, + err, + ) + } + } + + // Spawn child process to run cloudfuse with the generated config file and --dry-run flag + cmd := exec.Command( + "cloudfuse", + "mount", + mountPoint, + "--config-file", + tui.config.configFilePath, + "--dry-run", + "--passphrase", + tui.config.configEncryptionPassphrase, + ) + + // Capture stdout and stderr + 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()) + } + + return nil +} + // Helper function to center lines of text within a specified width. // It is used to format text views and other UI elements in the TUI. func centerText(text string, width int) string { @@ -1498,8 +1544,8 @@ func (tui *appContext) createYAMLConfig() error { } // Write the encrypted YAML config data to a file - if err := os.WriteFile("config.aes", cipherText, 0600); err != nil { - return fmt.Errorf("Failed to create encrypted config.aes file: %v", err) + if err := os.WriteFile("config.yaml.aes", cipherText, 0600); err != nil { + return fmt.Errorf("Failed to create encrypted config.yaml.aes file: %v", err) } // Update configFilePath member to point to the created config file @@ -1508,7 +1554,7 @@ func (tui *appContext) createYAMLConfig() error { return fmt.Errorf("Failed to get current working directory: %v", err) } - tui.config.configFilePath = filepath.Join(currDir, "config.aes") + tui.config.configFilePath = filepath.Join(currDir, "config.yaml.aes") return nil } diff --git a/config.yaml.aes b/config.yaml.aes new file mode 100644 index 0000000000000000000000000000000000000000..cd5611d74ffd6a9fce7db9bec3e7b7f112aa6d99 GIT binary patch literal 508 zcmVHWquSL28vJ3#Qzqe6i`|@A$gp>We$Cs9v!lyWdZrijM zj(B*Im25NW53@}&t^6xUq)z{8I83(0-!AruiawfyZ*|%&^oPp>x7QtPwepx08wL*O z1417-jY6ej0)4do4@*gnJ&KO;|D_hbF+HFjm95}`XB_=w|DA}pp#4(C-fTm=I>-(r zK+`-lz^*)WZ33lp3-w90FvJ{V*Qkj+Qd1GR5X-22N z4ZI9}lPwhRuI_pj?k?LMdPJDe(=h3y3ZWz_YD&~)9+TOO=QvV@qaW3hB@jaiB5u48 z#6FLD*j2}9AMu=8Zov>){A~q|fYsq=ppbb1t!q_QU0 zAS5)Qg!{Wjydf4G3q(jiuo~79UU&m6W9G?rm?p;S4CAvWQA@3)a|dEC&F59 z#fgxLr(2fckA);K5Z_Jsx7{?6-{Kto`7Sd;TZ)xi_9wUhI@n)r*vZJ$bM@XGODg}%i!&`!-~M;@S3LjBPI literal 0 HcmV?d00001 From 7d26ebc58b2cf02715f43861075d46b76ba04f6e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Mar 2026 23:35:35 +0000 Subject: [PATCH 2/2] Bump astral-sh/setup-uv from 7.3.1 to 7.6.0 Bumps [astral-sh/setup-uv](https://github.com/astral-sh/setup-uv) from 7.3.1 to 7.6.0. - [Release notes](https://github.com/astral-sh/setup-uv/releases) - [Commits](https://github.com/astral-sh/setup-uv/compare/5a095e7a2014a4212f075830d4f7277575a9d098...37802adc94f370d6bfd71619e3f0bf239e1f3b78) --- updated-dependencies: - dependency-name: astral-sh/setup-uv dependency-version: 7.6.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/zizmor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/zizmor.yml b/.github/workflows/zizmor.yml index 61c8a0c30..5396ef3c0 100644 --- a/.github/workflows/zizmor.yml +++ b/.github/workflows/zizmor.yml @@ -24,7 +24,7 @@ jobs: persist-credentials: false - name: Install the latest version of uv - uses: astral-sh/setup-uv@5a095e7a2014a4212f075830d4f7277575a9d098 # v7.3.1 + uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0 - name: Run zizmor 🌈 run: uvx zizmor --pedantic --format sarif . > results.sarif