Introduce Helmfile's own filesystem abstraction to correctly unit test some components (#307)

Use abstracted FS

Signed-off-by: Arkaitz Jimenez <arkaitzj@gmail.com>

Signed-off-by: Arkaitz Jimenez <arkaitzj@gmail.com>
This commit is contained in:
Arkaitz Jimenez
2022-08-24 12:58:43 +09:00
committed by GitHub
parent a626664f46
commit cc33e7b7d8
44 changed files with 513 additions and 425 deletions
+6 -9
View File
@@ -1,12 +1,13 @@
package tmpl
import "io/fs"
import (
"github.com/helmfile/helmfile/pkg/filesystem"
)
type Context struct {
preRender bool
basePath string
readFile func(string) ([]byte, error)
readDir func(string) ([]fs.DirEntry, error)
fs *filesystem.FileSystem
}
// SetBasePath sets the base path for the template
@@ -14,10 +15,6 @@ func (c *Context) SetBasePath(path string) {
c.basePath = path
}
func (c *Context) SetReadFile(f func(string) ([]byte, error)) {
c.readFile = f
}
func (c *Context) SetReadDir(f func(string) ([]fs.DirEntry, error)) {
c.readDir = f
func (c *Context) SetFileSystem(fs *filesystem.FileSystem) {
c.fs = fs
}