lang: Add an embedded package for embedded imports
This adds a new "embedded" package which can be used to import system-like packages that are embedded into the binary.
This commit is contained in:
@@ -32,6 +32,7 @@ import (
|
||||
etcdfs "github.com/purpleidea/mgmt/etcd/fs"
|
||||
"github.com/purpleidea/mgmt/etcd/interfaces"
|
||||
"github.com/purpleidea/mgmt/etcd/scheduler"
|
||||
"github.com/purpleidea/mgmt/lang/embedded"
|
||||
"github.com/purpleidea/mgmt/util"
|
||||
)
|
||||
|
||||
@@ -191,6 +192,11 @@ func (obj *World) Fs(uri string) (engine.Fs, error) {
|
||||
return obj.StandaloneFs, nil
|
||||
}
|
||||
|
||||
if u.Scheme == embedded.Scheme {
|
||||
path := strings.TrimPrefix(u.Path, "/") // expect a leading slash
|
||||
return embedded.Lookup(path) // does not expect a leading slash
|
||||
}
|
||||
|
||||
if u.Scheme != etcdfs.Scheme {
|
||||
return nil, fmt.Errorf("unknown scheme: `%s`", u.Scheme)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user