Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Importer ¶
type Importer struct { // SearchPath is an ordered slice of paths (network or local filesystem) // that is prepended to the imported filename if the filename is not // found. Searching stops when it is found. SearchPath []string // Fetcher is the URLFetcher used to fetch paths. The default is a // http.Client that has a `file:` scheme handler. Fetcher URLFetcher // contains filtered or unexported fields }
Importer implements the jsonnet.Importer interface, allowing jsonnet code to be imported via https in addition to local files. Filenames starting with a double-slash (`//`) are fetched via HTTPS. Otherwise the path is treated as a local filesystem path.
Once an import path is successfully fetched, either with data or a definitive not found result, that result is cached for the lifetime of the Importer. This is a requirement of the jsonnet.Importer interface so it is not possible for the same import statement from different files to result in different content. If an Importer is shared across multiple jsonnet.VM instances, the the cache will be shared too. There is no cache expiry logic.
func (*Importer) AppendSearchFromEnv ¶
AppendSearchFromEnv appends a list of search paths specified in the given environment variable to the search path list. The elements of the path in the variable are separated by the filepath.SplitList() delimiter.
func (*Importer) Import ¶
Import loads imp from a file or a network location. If imp is a relative path, search for it relative to the directory of source and the search path elements. If the import found, return its contents and the absolute location where it was found. If it was not found, or there was an error reading the content, return the error.
Import will cache the result and return it the next time that path is requested.
This method is defined in the jsonnet.Importer interface:
https://godoc.org/github.com/google/go-jsonnet#Importer
type URLFetcher ¶
A URLFetcher retreives a URL returning a http.Response or an error. It is defined such that http.Client implements it, but allows a different implementation or a custom-configured http.Client to be provided to the Importer.