diff --git a/loadertest/fake_loader.go b/loadertest/fake_loader.go index 1dd0b6369..0b1ca2ed5 100644 --- a/loadertest/fake_loader.go +++ b/loadertest/fake_loader.go @@ -18,6 +18,7 @@ package loadertest import ( "os" + "strings" "k8s.io/kubectl/pkg/kinflate/util/fs" "k8s.io/kubectl/pkg/loader" @@ -30,11 +31,15 @@ type FakeLoader struct { } // NewFakeLoader returns a Loader that delegates calls, and encapsulates -// a fake file system that the Loader reads from . "initialFilePath" parameter -// must be an absolute path. +// a fake file system that the Loader reads from. "initialFilePath" parameter +// must be an absolute path, and it can be a directory if it has a +// trailing slash: "/home/seans/project/" (dir) -- "/home/seans/project" (file) func NewFakeLoader(initialFilePath string) FakeLoader { // Create fake filesystem and inject it into initial Loader. fakefs := fs.MakeFakeFS() + if strings.HasSuffix(initialFilePath, "/") { + fakefs.Mkdir(initialFilePath, 0x777) + } var schemes []loader.SchemeLoader schemes = append(schemes, loader.NewFileLoader(fakefs)) rootLoader := loader.Init(schemes)