jpath

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

View Source
const DefaultEntrypoint = "main.jsonnet"

Variables

View Source
var ErrorNoRoot = errors.New(`unable to identify the project root.
Tried to find 'tkrc.yaml' or 'jsonnetfile.json' in the parent directories.
Please refer to https://tanka.dev/directory-structure for more information`)

ErrorNoRoot means no rootDir was found in the parent directories

Functions

func Dirs added in v0.14.0

func Dirs(path string) (root string, base string, err error)

Dirs returns the project-root (root) and environment directory (base)

func Entrypoint added in v0.13.0

func Entrypoint(path string) (string, error)

Entrypoint returns the absolute path of the environments entrypoint file (the one passed to jsonnet.EvaluateFile)

func Filename added in v0.14.0

func Filename(path string) (string, error)

Filename returns the name of the entrypoint file. It DOES NOT return an absolute path, only a plain name like "main.jsonnet" To obtain an absolute path, use Entrypoint() instead.

func FindBase added in v0.14.0

func FindBase(path string, root string) (string, error)

FindBase returns the absolute path of the environments base directory, the one which directly holds the entrypoint file.

func FindParentFile

func FindParentFile(file, start, stop string) (string, error)

FindParentFile traverses the parent directory tree for the given `file`, starting from `start` and ending in `stop`. If the file is not found an error is returned.

func FindRoot added in v0.13.0

func FindRoot(path string) (dir string, err error)

FindRoot returns the absolute path of the project root, being the directory that directly holds `tkrc.yaml` if it exists, otherwise the directory that directly holds `jsonnetfile.json`

func FsDir added in v0.14.0

func FsDir(path string) (string, error)

FsDir returns the most inner directory of path, as reported by the local filesystem

func Resolve

func Resolve(path string, allowMissingBase bool) (jpath []string, base, root string, err error)

Resolve the given path and resolves the jPath around it. This means it: - figures out the project root (the one with .jsonnetfile, vendor/ and lib/) - figures out the environments base directory (usually the main.jsonnet)

It then constructs a jPath with the base directory, vendor/ and lib/. This results in predictable imports, as it doesn't matter whether the user called called the command further down tree or not. A little bit like git.

Types

type ErrorFileNotFound

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

ErrorFileNotFound means that the searched file was not found

func (ErrorFileNotFound) Error

func (e ErrorFileNotFound) Error() string

type ErrorNoBase

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

ErrorNoBase means no baseDir was found in the parent directories

func (ErrorNoBase) Error added in v0.14.0

func (e ErrorNoBase) Error() string

Jump to

Keyboard shortcuts

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