Improve command package isolation.

This commit is contained in:
Jeffrey Regan
2018-10-03 15:04:57 -07:00
parent f5fee4decf
commit bb9fafa6cc
104 changed files with 301 additions and 212 deletions

View File

@@ -20,6 +20,8 @@ import (
"fmt"
"path/filepath"
"sort"
"sigs.k8s.io/kustomize/pkg/constants"
)
var _ FileSystem = &FakeFS{}
@@ -34,6 +36,31 @@ func MakeFakeFS() *FakeFS {
return &FakeFS{m: map[string]*FakeFile{}}
}
// kustomizationContent is used in tests.
const kustomizationContent = `namePrefix: some-prefix
# 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: []
`
// WriteTestKustomization writes a standard test file.
func (fs *FakeFS) WriteTestKustomization() {
fs.WriteFile(
constants.KustomizationFileName,
[]byte(kustomizationContent))
}
// Create assures a fake file appears in the in-memory file system.
func (fs *FakeFS) Create(name string) (File, error) {
f := &FakeFile{}