@@ -25,7 +25,7 @@ func IsRemoteFile(path string) bool {
2525 return err == nil && (u .Scheme == "http" || u .Scheme == "https" )
2626}
2727
28- // fileLoader is a kustomization's interface to files.
28+ // FileLoader is a kustomization's interface to files.
2929//
3030// The directory in which a kustomization file sits
3131// is referred to below as the kustomization's _root_.
@@ -38,49 +38,48 @@ func IsRemoteFile(path string) bool {
3838//
3939// * supplemental data paths
4040//
41- // `Load` is used to visit these paths.
41+ // `Load` is used to visit these paths.
4242//
43- // These paths refer to resources, patches,
44- // data for ConfigMaps and Secrets, etc.
43+ // These paths refer to resources, patches,
44+ // data for ConfigMaps and Secrets, etc.
4545//
46- // The loadRestrictor may disallow certain paths
47- // or classes of paths.
46+ // The loadRestrictor may disallow certain paths
47+ // or classes of paths.
4848//
4949// * bases (other kustomizations)
5050//
51- // `New` is used to load bases.
51+ // `New` is used to load bases.
5252//
53- // A base can be either a remote git repo URL, or
54- // a directory specified relative to the current
55- // root. In the former case, the repo is locally
56- // cloned, and the new loader is rooted on a path
57- // in that clone.
53+ // A base can be either a remote git repo URL, or
54+ // a directory specified relative to the current
55+ // root. In the former case, the repo is locally
56+ // cloned, and the new loader is rooted on a path
57+ // in that clone.
5858//
59- // As loaders create new loaders, a root history
60- // is established, and used to disallow:
59+ // As loaders create new loaders, a root history
60+ // is established, and used to disallow:
6161//
62- // - A base that is a repository that, in turn,
63- // specifies a base repository seen previously
64- // in the loading stack (a cycle).
62+ // - A base that is a repository that, in turn,
63+ // specifies a base repository seen previously
64+ // in the loading stack (a cycle).
6565//
66- // - An overlay depending on a base positioned at
67- // or above it. I.e. '../foo' is OK, but '.',
68- // '..', '../..', etc. are disallowed. Allowing
69- // such a base has no advantages and encourages
70- // cycles, particularly if some future change
71- // were to introduce globbing to file
72- // specifications in the kustomization file.
66+ // - An overlay depending on a base positioned at
67+ // or above it. I.e. '../foo' is OK, but '.',
68+ // '..', '../..', etc. are disallowed. Allowing
69+ // such a base has no advantages and encourages
70+ // cycles, particularly if some future change
71+ // were to introduce globbing to file
72+ // specifications in the kustomization file.
7373//
7474// These restrictions assure that kustomizations
7575// are self-contained and relocatable, and impose
7676// some safety when relying on remote kustomizations,
7777// e.g. a remotely loaded ConfigMap generator specified
7878// to read from /etc/passwd will fail.
79- //
80- type fileLoader struct {
79+ type FileLoader struct {
8180 // Loader that spawned this loader.
8281 // Used to avoid cycles.
83- referrer * fileLoader
82+ referrer * FileLoader
8483
8584 // An absolute, cleaned path to a directory.
8685 // The Load function will read non-absolute
@@ -107,23 +106,9 @@ type fileLoader struct {
107106 cleaner func () error
108107}
109108
110- // NewFileLoaderAtCwd returns a loader that loads from PWD.
111- // A convenience for kustomize edit commands.
112- func NewFileLoaderAtCwd (fSys filesys.FileSystem ) * fileLoader {
113- return newLoaderOrDie (
114- RestrictionRootOnly , fSys , filesys .SelfDir )
115- }
116-
117- // NewFileLoaderAtRoot returns a loader that loads from "/".
118- // A convenience for tests.
119- func NewFileLoaderAtRoot (fSys filesys.FileSystem ) * fileLoader {
120- return newLoaderOrDie (
121- RestrictionRootOnly , fSys , filesys .Separator )
122- }
123-
124109// Repo returns the absolute path to the repo that contains Root if this fileLoader was created from a url
125110// or the empty string otherwise.
126- func (fl * fileLoader ) Repo () string {
111+ func (fl * FileLoader ) Repo () string {
127112 if fl .repoSpec != nil {
128113 return fl .repoSpec .Dir .String ()
129114 }
@@ -132,13 +117,13 @@ func (fl *fileLoader) Repo() string {
132117
133118// Root returns the absolute path that is prepended to any
134119// relative paths used in Load.
135- func (fl * fileLoader ) Root () string {
120+ func (fl * FileLoader ) Root () string {
136121 return fl .root .String ()
137122}
138123
139- func newLoaderOrDie (
124+ func NewLoaderOrDie (
140125 lr LoadRestrictorFunc ,
141- fSys filesys.FileSystem , path string ) * fileLoader {
126+ fSys filesys.FileSystem , path string ) * FileLoader {
142127 root , err := filesys .ConfirmDir (fSys , path )
143128 if err != nil {
144129 log .Fatalf ("unable to make loader at '%s'; %v" , path , err )
@@ -147,12 +132,12 @@ func newLoaderOrDie(
147132 lr , root , fSys , nil , git .ClonerUsingGitExec )
148133}
149134
150- // newLoaderAtConfirmedDir returns a new fileLoader with given root.
135+ // newLoaderAtConfirmedDir returns a new FileLoader with given root.
151136func newLoaderAtConfirmedDir (
152137 lr LoadRestrictorFunc ,
153138 root filesys.ConfirmedDir , fSys filesys.FileSystem ,
154- referrer * fileLoader , cloner git.Cloner ) * fileLoader {
155- return & fileLoader {
139+ referrer * FileLoader , cloner git.Cloner ) * FileLoader {
140+ return & FileLoader {
156141 loadRestrictor : lr ,
157142 root : root ,
158143 referrer : referrer ,
@@ -164,7 +149,7 @@ func newLoaderAtConfirmedDir(
164149
165150// New returns a new Loader, rooted relative to current loader,
166151// or rooted in a temp directory holding a git repo clone.
167- func (fl * fileLoader ) New (path string ) (ifc.Loader , error ) {
152+ func (fl * FileLoader ) New (path string ) (ifc.Loader , error ) {
168153 if path == "" {
169154 return nil , errors .Errorf ("new root cannot be empty" )
170155 }
@@ -200,7 +185,7 @@ func (fl *fileLoader) New(path string) (ifc.Loader, error) {
200185// directory holding a cloned git repo.
201186func newLoaderAtGitClone (
202187 repoSpec * git.RepoSpec , fSys filesys.FileSystem ,
203- referrer * fileLoader , cloner git.Cloner ) (ifc.Loader , error ) {
188+ referrer * FileLoader , cloner git.Cloner ) (ifc.Loader , error ) {
204189 cleaner := repoSpec .Cleaner (fSys )
205190 err := cloner (repoSpec )
206191 if err != nil {
@@ -229,7 +214,7 @@ func newLoaderAtGitClone(
229214 return nil , fmt .Errorf ("%q refers to directory outside of repo %q" , repoSpec .AbsPath (),
230215 repoSpec .CloneDir ())
231216 }
232- return & fileLoader {
217+ return & FileLoader {
233218 // Clones never allowed to escape root.
234219 loadRestrictor : RestrictionRootOnly ,
235220 root : root ,
@@ -241,7 +226,7 @@ func newLoaderAtGitClone(
241226 }, nil
242227}
243228
244- func (fl * fileLoader ) errIfGitContainmentViolation (
229+ func (fl * FileLoader ) errIfGitContainmentViolation (
245230 base filesys.ConfirmedDir ) error {
246231 containingRepo := fl .containingRepo ()
247232 if containingRepo == nil {
@@ -259,7 +244,7 @@ func (fl *fileLoader) errIfGitContainmentViolation(
259244
260245// Looks back through referrers for a git repo, returning nil
261246// if none found.
262- func (fl * fileLoader ) containingRepo () * git.RepoSpec {
247+ func (fl * FileLoader ) containingRepo () * git.RepoSpec {
263248 if fl .repoSpec != nil {
264249 return fl .repoSpec
265250 }
@@ -271,7 +256,7 @@ func (fl *fileLoader) containingRepo() *git.RepoSpec {
271256
272257// errIfArgEqualOrHigher tests whether the argument,
273258// is equal to or above the root of any ancestor.
274- func (fl * fileLoader ) errIfArgEqualOrHigher (
259+ func (fl * FileLoader ) errIfArgEqualOrHigher (
275260 candidateRoot filesys.ConfirmedDir ) error {
276261 if fl .root .HasPrefix (candidateRoot ) {
277262 return fmt .Errorf (
@@ -288,7 +273,7 @@ func (fl *fileLoader) errIfArgEqualOrHigher(
288273// I.e. Allow a distinction between git URI with
289274// path foo and tag bar and a git URI with the same
290275// path but a different tag?
291- func (fl * fileLoader ) errIfRepoCycle (newRepoSpec * git.RepoSpec ) error {
276+ func (fl * FileLoader ) errIfRepoCycle (newRepoSpec * git.RepoSpec ) error {
292277 // TODO(monopole): Use parsed data instead of Raw().
293278 if fl .repoSpec != nil &&
294279 strings .HasPrefix (fl .repoSpec .Raw (), newRepoSpec .Raw ()) {
@@ -305,7 +290,7 @@ func (fl *fileLoader) errIfRepoCycle(newRepoSpec *git.RepoSpec) error {
305290// Load returns the content of file at the given path,
306291// else an error. Relative paths are taken relative
307292// to the root.
308- func (fl * fileLoader ) Load (path string ) ([]byte , error ) {
293+ func (fl * FileLoader ) Load (path string ) ([]byte , error ) {
309294 if IsRemoteFile (path ) {
310295 return fl .httpClientGetContent (path )
311296 }
@@ -319,7 +304,7 @@ func (fl *fileLoader) Load(path string) ([]byte, error) {
319304 return fl .fSys .ReadFile (path )
320305}
321306
322- func (fl * fileLoader ) httpClientGetContent (path string ) ([]byte , error ) {
307+ func (fl * FileLoader ) httpClientGetContent (path string ) ([]byte , error ) {
323308 var hc * http.Client
324309 if fl .http != nil {
325310 hc = fl .http
@@ -344,6 +329,6 @@ func (fl *fileLoader) httpClientGetContent(path string) ([]byte, error) {
344329}
345330
346331// Cleanup runs the cleaner.
347- func (fl * fileLoader ) Cleanup () error {
332+ func (fl * FileLoader ) Cleanup () error {
348333 return fl .cleaner ()
349334}
0 commit comments