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 32a0d2b9524c7afd03dbf5ab53f59f84b0027e69 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Mar 2026 23:36:00 +0000 Subject: [PATCH 2/2] Bump actions/cache from 5.0.3 to 5.0.4 Bumps [actions/cache](https://github.com/actions/cache) from 5.0.3 to 5.0.4. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/cdf6c1fa76f9f475f3d7449005a359c84ca0f306...668228422ae6a00e4ad889ee87cd7109ec5666a7) --- updated-dependencies: - dependency-name: actions/cache dependency-version: 5.0.4 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/fuzz-test.yml | 4 ++-- .github/workflows/publish-release.yml | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 72f80faf5..df268c78d 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -64,7 +64,7 @@ jobs: - name: Cache Go build cache if: matrix.language == 'go' && runner.os == 'Linux' - uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 + uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 with: path: ~/.cache/go-build key: ${{ runner.os }}-codeql-go-build-${{ hashFiles('**/go.sum') }} diff --git a/.github/workflows/fuzz-test.yml b/.github/workflows/fuzz-test.yml index dc8e5a990..b21de4d18 100644 --- a/.github/workflows/fuzz-test.yml +++ b/.github/workflows/fuzz-test.yml @@ -44,7 +44,7 @@ jobs: check-latest: true - name: Restore fuzz corpus - uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 + uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 with: path: | ~/.cache/go-build/fuzz @@ -98,7 +98,7 @@ jobs: - name: Save fuzz corpus if: always() && github.event_name != 'pull_request' - uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 + uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 with: path: | ~/.cache/go-build/fuzz diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index dd6c7683d..4f5399e42 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -56,7 +56,7 @@ jobs: # Get the WinFSP installer (from cache or download) - name: Get cached WinFSP installer id: restore-winfsp-installer - uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 + uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 with: path: ${{ env.winfsp }} key: ${{ env.winfsp }} @@ -71,7 +71,7 @@ jobs: - name: Cache WinFSP installer if: ${{ ! steps.restore-winfsp-installer.outputs.cache-hit }} - uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 + uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 with: path: ${{ env.winfsp }} key: ${{ env.winfsp }} @@ -97,7 +97,7 @@ jobs: mv build/Output/cloudfuse.exe build/Output/cloudfuse_${{ steps.get_version.outputs.VERSION }}_windows_amd64.exe - name: Cache windows installer - uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 + uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 with: enableCrossOsArchive: true path: build/Output/cloudfuse_${{ steps.get_version.outputs.VERSION }}_windows_amd64.exe @@ -152,7 +152,7 @@ jobs: # Get cached intermediate build products - name: Restore cached Windows installer - uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 + uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 with: enableCrossOsArchive: true path: build/Output/cloudfuse_${{ steps.get_version.outputs.VERSION }}_windows_amd64.exe