files

package
v4.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileSource

type FileSource interface {
	// Name returns a string describing the file source.
	Name() string

	// Match returns a slice of logical paths to spec files that should be
	// linted from the given resource set configuration.
	Match(*config.ResourceSet) ([]string, error)

	// Prefetch retrieves an entire directory tree starting at the given root,
	// for remote sources which need to download and cache a local copy. For
	// such sources, a call to Fetch without a pre-fetched root will error.
	// The path to the local copy of the "root" is returned.
	//
	// For local sources, this method may be a no-op / passthrough.
	//
	// The root must contain all relative OpenAPI $ref references in all linted
	// specs, or the lint will fail.
	Prefetch(root string) (string, error)

	// Fetch retrieves the contents of the requested logical path as a local
	// file and returns the absolute path where it may be found. An empty
	// string, rather than an error, is returned if the file does not exist.
	Fetch(path string) (string, error)

	// Close releases any resources consumed in content retrieval. Any files
	// returned by Fetch will no longer be available after calling Close, and
	// any further calls to Fetch will error.
	Close() error
}

FileSource defines a source of spec files to lint. This abstraction allows linters to operate seamlessly over version control systems and local files.

type LocalFSSource

type LocalFSSource struct{}

LocalFSSource is a FileSource that resolves files from the local filesystem relative to the current working directory.

func (LocalFSSource) Close

func (LocalFSSource) Close() error

Close implements FileSource.

func (LocalFSSource) Fetch

func (LocalFSSource) Fetch(path string) (string, error)

Fetch implements FileSource.

func (LocalFSSource) Match

func (LocalFSSource) Match(rcConfig *config.ResourceSet) ([]string, error)

Match implements FileSource.

func (LocalFSSource) Name

func (LocalFSSource) Name() string

Name implements FileSource.

func (LocalFSSource) Prefetch

func (LocalFSSource) Prefetch(root string) (string, error)

Prefetch implements FileSource.

type NilSource

type NilSource struct{}

NilSource is a FileSource that does not have any files in it.

func (NilSource) Close

func (NilSource) Close() error

Close implements FileSource.

func (NilSource) Fetch

func (NilSource) Fetch(path string) (string, error)

Fetch implements FileSource.

func (NilSource) Match

func (NilSource) Match(*config.ResourceSet) ([]string, error)

Match implements FileSource.

func (NilSource) Name

func (NilSource) Name() string

Name implements FileSource.

func (NilSource) Prefetch

func (NilSource) Prefetch(root string) (string, error)

Prefetch implements FileSource.

Jump to

Keyboard shortcuts

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