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
+7 -3
View File
@@ -1,5 +1,9 @@
package tmpl
import (
"github.com/helmfile/helmfile/pkg/filesystem"
)
type templateTextRenderer struct {
ReadText func(string) ([]byte, error)
Context *Context
@@ -11,12 +15,12 @@ type TextRenderer interface {
}
// nolint: golint
func NewTextRenderer(readFile func(filename string) ([]byte, error), basePath string, data interface{}) *templateTextRenderer {
func NewTextRenderer(fs *filesystem.FileSystem, basePath string, data interface{}) *templateTextRenderer {
return &templateTextRenderer{
ReadText: readFile,
ReadText: fs.ReadFile,
Context: &Context{
basePath: basePath,
readFile: readFile,
fs: fs,
},
Data: data,
}