Files
linuxkit/vendor/github.com/docker/infrakit/pkg/template/util.go
Rolf Neugebauer 6a29d153f5 infrakit: Move the hyperkit instance plugin into the source directory
- 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>
2017-03-25 13:02:45 +01:00

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
}