Files
linuxkit/vendor/github.com/docker/infrakit/pkg/plugin/metadata/path.go
Rolf Neugebauer 48845bcfd9 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

31 lines
657 B
Go

package metadata
import (
"path/filepath"
"strings"
"github.com/docker/infrakit/pkg/spi/metadata"
)
// Path returns the path compoments of a / separated path
func Path(path string) metadata.Path {
return metadata.Path(strings.Split(filepath.Clean(path), "/"))
}
// PathFromStrings returns the path from a list of strings
func PathFromStrings(a string, b ...string) metadata.Path {
if a != "" {
return metadata.Path(append([]string{a}, b...))
}
return metadata.Path(b)
}
// String returns the string representation of path
func String(p metadata.Path) string {
s := strings.Join([]string(p), "/")
if len(s) == 0 {
return "."
}
return s
}