importers

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: Apache-2.0 Imports: 13 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) CanProcess

func (c *CompositeImporter) CanProcess(importedPath string) bool

CanProcess implements the interface method of the ExtendedImporter

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 DataSourceImporter

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

DataSourceImporter implements an importer that delegates to a data source for resolution.

func NewDataSourceImporter

func NewDataSourceImporter(source datasource.DataSource) *DataSourceImporter

NewDataSourceImporter returns an importer that can resolve paths for the specified datasource. It processes entries of the form

data://{name}[/{path-to-be-resolved}]

If no path is provided, it is set to "/"

func (*DataSourceImporter) CanProcess

func (d *DataSourceImporter) CanProcess(path string) bool

CanProcess implements the interface method

func (*DataSourceImporter) Import

func (d *DataSourceImporter) Import(_, importedPath string) (contents jsonnet.Contents, foundAt string, err error)

Import implements the interface method. For the datasource importer, imports are always considered absolute and the import-from path has no significance.

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