mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-12-26 17:24:44 +00:00
- The tools directory ideally should not contain source code - Removes double vendoring of packagages - Makes it easer to hook the build into the top-level Makefile Eventually, the plugin should be moved to the infrakit repo. Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
29 lines
593 B
Go
29 lines
593 B
Go
package template
|
|
|
|
import (
|
|
"net/url"
|
|
"path/filepath"
|
|
"strings"
|
|
)
|
|
|
|
// returns a url string of the base and a relative path.
|
|
// e.g. http://host/foo/bar/baz, ./boo.tpl gives http://host/foo/bar/boo.tpl
|
|
func getURL(root, rel string) (string, error) {
|
|
|
|
// handle the case when rel is actually a full url
|
|
if strings.Index(rel, "://") > 0 {
|
|
u, err := url.Parse(rel)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return u.String(), nil
|
|
}
|
|
|
|
u, err := url.Parse(root)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
u.Path = filepath.Clean(filepath.Join(filepath.Dir(u.Path), rel))
|
|
return u.String(), nil
|
|
}
|