Make fsNode handle correctly consecutive reads and writes (#3820)

* Make fsNode handle correctly consecutive reads and writes

* Check for directories in ReadFile and add some error checks

* Update comment

* Improved docs and added better test

* Move test into its own file protected by built constraint

* Use manual test since iotest.TestReader is only available in Go 1.16
This commit is contained in:
Francesc Campoy
2021-04-22 16:50:01 -07:00
committed by GitHub
parent 06add3ab35
commit 225bae8491
3 changed files with 140 additions and 20 deletions

View File

@@ -42,27 +42,36 @@ func (th Harness) GetFSys() filesys.FileSystem {
}
func (th Harness) WriteK(path string, content string) {
th.fSys.WriteFile(
err := th.fSys.WriteFile(
filepath.Join(
path,
konfig.DefaultKustomizationFileName()), []byte(`
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
`+content))
if err != nil {
th.t.Fatalf("unexpected error while writing Kustomization to %s: %v", path, err)
}
}
func (th Harness) WriteC(path string, content string) {
th.fSys.WriteFile(
err := th.fSys.WriteFile(
filepath.Join(
path,
konfig.DefaultKustomizationFileName()), []byte(`
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component
`+content))
if err != nil {
th.t.Fatalf("unexpected error while writing Component to %s: %v", path, err)
}
}
func (th Harness) WriteF(path string, content string) {
th.fSys.WriteFile(path, []byte(content))
err := th.fSys.WriteFile(path, []byte(content))
if err != nil {
th.t.Fatalf("unexpected error while writing file to %s: %v", path, err)
}
}
func (th Harness) MakeDefaultOptions() krusty.Options {