importers

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompositeImporter

type CompositeImporter struct {
	// contains filtered or unexported fields
}

CompositeImporter tries multiple extended importers in sequence for a given path

func NewCompositeImporter

func NewCompositeImporter(importers ...ExtendedImporter) *CompositeImporter

NewCompositeImporter creates a composite importer with the supplied extended importers. Note that if two importers could match the same path, the first one will be used so order is important.

func (*CompositeImporter) Import

func (c *CompositeImporter) Import(importedFrom, importedPath string) (contents jsonnet.Contents, foundAt string, err error)

Import implements the interface method by delegating to installed importers in sequence

type ExtendedFileImporter

type ExtendedFileImporter struct {
	*jsonnet.FileImporter
}

ExtendedFileImporter wraps a file importer and declares that it can import any path.

func NewFileImporter

func NewFileImporter(jfi *jsonnet.FileImporter) *ExtendedFileImporter

NewFileImporter creates an extended file importer, wrapping the one supplied.

func (*ExtendedFileImporter) CanProcess

func (e *ExtendedFileImporter) CanProcess(_ string) bool

CanProcess implements the interface method.

type ExtendedImporter

type ExtendedImporter interface {
	jsonnet.Importer
	CanProcess(path string) bool
}

ExtendedImporter extends the jsonnet importer interface to add a new method that can determine whether an importer can be used for a path.

type GlobImporter

type GlobImporter struct {
	// contains filtered or unexported fields
}

GlobImporter provides facilities to import a bag of files using a glob pattern. Note that it will NOT honor any library paths and must be exactly resolved from the caller's location. It is initialized with a verb that configures how the inner imports are done (i.e. `import` or `importstr`) and it processes paths that start with `glob-{verb}:`

After the marker prefix is stripped, the input is treated as a file pattern that is resolved using Go's glob functionality. The return value is an object that is keyed by file names relative to the import location with values importing the contents of the file.

That is, given the following directory structure:

lib
	- a.json
	- b.json
caller
	- c.libsonnet

where c.libsonnet has the following contents

import 'glob-import:../lib/*.json'

evaluating `c.libsonnet` will return jsonnet code of the following form:

{
	'../lib/a.json': import '../lib/a.json',
	'../lib/b.json': import '../lib/b.json',
}

func NewGlobImporter

func NewGlobImporter(innerVerb string) *GlobImporter

NewGlobImporter creates a glob importer.

func (*GlobImporter) CanProcess

func (g *GlobImporter) CanProcess(path string) bool

CanProcess implements the interface method, returning true for paths that start with the string "glob:"

func (*GlobImporter) Import

func (g *GlobImporter) Import(importedFrom, importedPath string) (contents jsonnet.Contents, foundAt string, err error)

Import implements the interface method.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL