mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 10:15:22 +00:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user