Documentation
¶
Overview ¶
Package loader has a data loading interface and various implementations.
Index ¶
- Variables
- func IsRemoteFile(path string) bool
- func NewLoader(lr LoadRestrictorFunc, target string, fSys filesys.FileSystem) (ifc.Loader, error)
- func RestrictionNone(_ filesys.FileSystem, _ filesys.ConfirmedDir, path string) (string, error)
- func RestrictionRootOnly(fSys filesys.FileSystem, root filesys.ConfirmedDir, path string) (string, error)
- type FileLoader
- type LoadRestrictorFunc
Constants ¶
This section is empty.
Variables ¶
var ( ErrHTTP = errors.Errorf("HTTP Error") ErrRtNotDir = errors.Errorf("must build at directory") )
Functions ¶
func IsRemoteFile ¶
IsRemoteFile returns whether path has a url scheme that kustomize allows for remote files. See https://github.com/kubernetes-sigs/kustomize/blob/master/examples/remoteBuild.md
func NewLoader ¶
func NewLoader( lr LoadRestrictorFunc, target string, fSys filesys.FileSystem) (ifc.Loader, error)
NewLoader returns a Loader pointed at the given target. If the target is remote, the loader will be restricted to the root and below only. If the target is local, the loader will have the restrictions passed in. Regardless, if a local target attempts to transitively load remote bases, the remote bases will all be root-only restricted.
func RestrictionNone ¶
func RestrictionNone( _ filesys.FileSystem, _ filesys.ConfirmedDir, path string) (string, error)
func RestrictionRootOnly ¶
func RestrictionRootOnly( fSys filesys.FileSystem, root filesys.ConfirmedDir, path string) (string, error)
Types ¶
type FileLoader ¶
type FileLoader struct {
// contains filtered or unexported fields
}
FileLoader is a kustomization's interface to files.
The directory in which a kustomization file sits is referred to below as the kustomization's _root_.
An instance of fileLoader has an immutable root, and offers a `New` method returning a new loader with a new root.
A kustomization file refers to two kinds of files:
* supplemental data paths
`Load` is used to visit these paths. These paths refer to resources, patches, data for ConfigMaps and Secrets, etc. The loadRestrictor may disallow certain paths or classes of paths.
* bases (other kustomizations)
`New` is used to load bases. A base can be either a remote git repo URL, or a directory specified relative to the current root. In the former case, the repo is locally cloned, and the new loader is rooted on a path in that clone. As loaders create new loaders, a root history is established, and used to disallow: - A base that is a repository that, in turn, specifies a base repository seen previously in the loading stack (a cycle). - An overlay depending on a base positioned at or above it. I.e. '../foo' is OK, but '.', '..', '../..', etc. are disallowed. Allowing such a base has no advantages and encourages cycles, particularly if some future change were to introduce globbing to file specifications in the kustomization file.
These restrictions assure that kustomizations are self-contained and relocatable, and impose some safety when relying on remote kustomizations, e.g. a remotely loaded ConfigMap generator specified to read from /etc/passwd will fail.
func NewLoaderOrDie ¶
func NewLoaderOrDie( lr LoadRestrictorFunc, fSys filesys.FileSystem, path string) *FileLoader
func (*FileLoader) Load ¶
func (fl *FileLoader) Load(path string) ([]byte, error)
Load returns the content of file at the given path, else an error. Relative paths are taken relative to the root.
func (*FileLoader) New ¶
func (fl *FileLoader) New(path string) (ifc.Loader, error)
New returns a new Loader, rooted relative to current loader, or rooted in a temp directory holding a git repo clone.
func (*FileLoader) Repo ¶
func (fl *FileLoader) Repo() string
Repo returns the absolute path to the repo that contains Root if this fileLoader was created from a url or the empty string otherwise.
func (*FileLoader) Root ¶
func (fl *FileLoader) Root() string
Root returns the absolute path that is prepended to any relative paths used in Load.
type LoadRestrictorFunc ¶
type LoadRestrictorFunc func( filesys.FileSystem, filesys.ConfirmedDir, string) (string, error)