diff --git a/pkg/app/app.go b/pkg/app/app.go index 5073a82d..aace620f 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -103,6 +103,12 @@ func New(conf ConfigProvider) *App { }) } +// WithFileSystem swaps the FileSystem this App reads through while loading state. +func (a *App) WithFileSystem(fs *filesystem.FileSystem) *App { + a.fs = fs + return a +} + func Init(app *App) *App { var err error app.valsRuntime, err = plugins.ValsInstance() diff --git a/pkg/app/app_test.go b/pkg/app/app_test.go index 03582cad..132438d4 100644 --- a/pkg/app/app_test.go +++ b/pkg/app/app_test.go @@ -48,6 +48,16 @@ func injectFs(app *App, fs *testhelper.TestFs) *App { return app } +func TestAppWithFileSystem(t *testing.T) { + app := &App{} + fs := ffs.DefaultFileSystem() + + got := app.WithFileSystem(fs) + + require.Same(t, app, got) + require.Same(t, fs, app.fs) +} + func expectNoCallsToHelm(app *App) { expectNoCallsToHelmVersion(app) }