Break the dep between fs and pgmconfig.

This commit is contained in:
Jeffrey Regan
2019-10-02 12:01:45 -07:00
parent 5372fc6f6c
commit 2d58f8b81c
46 changed files with 600 additions and 419 deletions

View File

@@ -9,8 +9,6 @@ import (
"path/filepath"
"sort"
"strings"
"sigs.k8s.io/kustomize/v3/pkg/pgmconfig"
)
var _ FileSystem = &fsInMemory{}
@@ -31,26 +29,6 @@ func MakeFsInMemory() FileSystem {
const (
separator = string(filepath.Separator)
doubleSep = separator + separator
// kustomizationContent is used in tests.
kustomizationContent = `apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namePrefix: some-prefix
nameSuffix: some-suffix
# Labels to add to all objects and selectors.
# These labels would also be used to form the selector for apply --prune
# Named differently than “labels” to avoid confusion with metadata for this object
commonLabels:
app: helloworld
commonAnnotations:
note: This is an example annotation
resources: []
#- service.yaml
#- ../some-dir/
# There could also be configmaps in Base, which would make these overlays
configMapGenerator: []
# There could be secrets in Base, if just using a fork/rebase workflow
secretGenerator: []
`
)
// Create assures a fake file appears in the in-memory file system.
@@ -150,10 +128,6 @@ func (fs *fsInMemory) ReadFile(name string) ([]byte, error) {
return nil, fmt.Errorf("cannot read file %q", name)
}
func (fs *fsInMemory) ReadTestKustomization() ([]byte, error) {
return fs.ReadFile(pgmconfig.KustomizationFileNames[0])
}
// WriteFile always succeeds and does nothing.
func (fs *fsInMemory) WriteFile(name string, c []byte) error {
ff := &fileInMemory{}
@@ -162,16 +136,6 @@ func (fs *fsInMemory) WriteFile(name string, c []byte) error {
return nil
}
// WriteTestKustomization writes a standard test file.
func (fs *fsInMemory) WriteTestKustomization() {
fs.WriteTestKustomizationWith([]byte(kustomizationContent))
}
// WriteTestKustomizationWith writes a standard test file.
func (fs *fsInMemory) WriteTestKustomizationWith(bytes []byte) {
fs.WriteFile(pgmconfig.KustomizationFileNames[0], bytes)
}
// Walk implements filepath.Walk using the fake filesystem.
func (fs *fsInMemory) Walk(path string, walkFn filepath.WalkFunc) error {
info, err := fs.lstat(path)