1
0
mirror of https://github.com/drone/drone-cli.git synced 2026-01-20 01:41:34 +01:00
drone-cli/drone/jsonnet/stdlib/stdlib.go

31 lines
667 B
Go
Raw Normal View History

2018-08-27 04:40:06 +02:00
package stdlib
2018-08-28 02:41:34 +02:00
import (
"path"
jsonnet "github.com/google/go-jsonnet"
)
2018-08-27 04:40:06 +02:00
//go:generate go run gen.go
// Importer provides a default importer that automatically
// loads the embedded drone standard library.
func Importer() jsonnet.Importer {
return &importer{
base: &jsonnet.FileImporter{},
}
}
type importer struct {
base jsonnet.Importer
}
func (i *importer) Import(importedFrom, importedPath string) (contents jsonnet.Contents, foundAt string, err error) {
2018-08-28 02:41:34 +02:00
dir, _ := path.Split(importedFrom)
path := path.Join(dir, importedPath)
if contents, ok := files[path]; ok {
return contents, path, nil
2018-08-27 04:40:06 +02:00
}
return i.base.Import(importedFrom, importedPath)
}