本文整理汇总了Golang中github.com/coreos/rkt/Godeps/_workspace/src/github.com/appc/spec/schema/types.SanitizeACName函数的典型用法代码示例。如果您正苦于以下问题:Golang SanitizeACName函数的具体用法?Golang SanitizeACName怎么用?Golang SanitizeACName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SanitizeACName函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: convertVolumesToMPs
func convertVolumesToMPs(dockerVolumes map[string]struct{}) ([]appctypes.MountPoint, error) {
mps := []appctypes.MountPoint{}
dup := make(map[string]int)
for p := range dockerVolumes {
n := filepath.Join("volume", p)
sn, err := appctypes.SanitizeACName(n)
if err != nil {
return nil, err
}
// check for duplicate names
if i, ok := dup[sn]; ok {
dup[sn] = i + 1
sn = fmt.Sprintf("%s-%d", sn, i)
} else {
dup[sn] = 1
}
mp := appctypes.MountPoint{
Name: *appctypes.MustACName(sn),
Path: p,
}
mps = append(mps, mp)
}
return mps, nil
}
开发者ID:danieltaborda,项目名称:rkt,代码行数:29,代码来源:common.go
示例2: Set
func (aam *appInjectVolume) Set(s string) error {
app := (*apps.Apps)(aam).Last()
if app == nil {
return fmt.Errorf("--inject-volume must follow an image")
}
p := strings.SplitN(s, ":", 2)
if len(p) != 2 {
return fmt.Errorf("must be SOURCE_PATH:TARGET_PATH")
}
volName, err := types.SanitizeACName(p[1])
if err != nil {
return fmt.Errorf("empty target in volume")
}
if volName != p[1] {
stderr("Changed volume target %q to %q", p[1], volName)
}
rVol := types.Volume{Name: *types.MustACName(volName), Source: p[0], Kind: "host"}
mount := schema.Mount{Volume: rVol.Name, Path: p[1]}
(*apps.Apps)(aam).Volumes = append((*apps.Apps)(aam).Volumes, rVol)
app.Mounts = append(app.Mounts, mount)
return nil
}
开发者ID:atd-schubert,项目名称:rkt,代码行数:28,代码来源:cli_apps.go
示例3: parseDockerPort
func parseDockerPort(dockerPort string) (*appctypes.Port, error) {
var portString string
proto := "tcp"
sp := strings.Split(dockerPort, "/")
if len(sp) < 2 {
portString = dockerPort
} else {
proto = sp[1]
portString = sp[0]
}
port, err := strconv.ParseUint(portString, 10, 0)
if err != nil {
return nil, fmt.Errorf("error parsing port %q: %v", portString, err)
}
sn, err := appctypes.SanitizeACName(dockerPort)
if err != nil {
return nil, err
}
appcPort := &appctypes.Port{
Name: *appctypes.MustACName(sn),
Protocol: proto,
Port: uint(port),
}
return appcPort, nil
}
开发者ID:danieltaborda,项目名称:rkt,代码行数:29,代码来源:common.go
示例4: imageNameToAppName
func imageNameToAppName(name types.ACIdentifier) (*types.ACName, error) {
parts := strings.Split(name.String(), "/")
last := parts[len(parts)-1]
sn, err := types.SanitizeACName(last)
if err != nil {
return nil, err
}
return types.MustACName(sn), nil
}
开发者ID:krieg,项目名称:rkt,代码行数:11,代码来源:run.go
示例5: GenerateManifest
func GenerateManifest(layerData types.DockerImageData, dockerURL *types.ParsedDockerURL) (*schema.ImageManifest, error) {
dockerConfig := layerData.Config
genManifest := &schema.ImageManifest{}
appURL := ""
// omit docker hub index URL in app name
if dockerURL.IndexURL != defaultIndex {
appURL = dockerURL.IndexURL + "/"
}
appURL += dockerURL.ImageName + "-" + layerData.ID
appURL, err := appctypes.SanitizeACName(appURL)
if err != nil {
return nil, err
}
name, err := appctypes.NewACName(appURL)
if err != nil {
return nil, err
}
genManifest.Name = *name
acVersion, err := appctypes.NewSemVer(schemaVersion)
if err != nil {
panic("invalid appc spec version")
}
genManifest.ACVersion = *acVersion
genManifest.ACKind = appctypes.ACKind(schema.ImageManifestKind)
var labels appctypes.Labels
var parentLabels appctypes.Labels
layer, _ := appctypes.NewACName("layer")
labels = append(labels, appctypes.Label{Name: *layer, Value: layerData.ID})
tag := dockerURL.Tag
version, _ := appctypes.NewACName("version")
labels = append(labels, appctypes.Label{Name: *version, Value: tag})
if layerData.OS != "" {
os, _ := appctypes.NewACName("os")
labels = append(labels, appctypes.Label{Name: *os, Value: layerData.OS})
parentLabels = append(parentLabels, appctypes.Label{Name: *os, Value: layerData.OS})
if layerData.Architecture != "" {
arch, _ := appctypes.NewACName("arch")
parentLabels = append(parentLabels, appctypes.Label{Name: *arch, Value: layerData.Architecture})
}
}
genManifest.Labels = labels
if dockerConfig != nil {
exec := getExecCommand(dockerConfig.Entrypoint, dockerConfig.Cmd)
if exec != nil {
user, group := parseDockerUser(dockerConfig.User)
var env appctypes.Environment
for _, v := range dockerConfig.Env {
parts := strings.SplitN(v, "=", 2)
env.Set(parts[0], parts[1])
}
app := &appctypes.App{
Exec: exec,
User: user,
Group: group,
Environment: env,
WorkingDirectory: dockerConfig.WorkingDir,
}
genManifest.App = app
}
}
if layerData.Parent != "" {
parentAppNameString := dockerURL.IndexURL + "/" + dockerURL.ImageName + "-" + layerData.Parent
parentAppNameString, err := appctypes.SanitizeACName(parentAppNameString)
if err != nil {
return nil, err
}
parentAppName, err := appctypes.NewACName(parentAppNameString)
if err != nil {
return nil, err
}
genManifest.Dependencies = append(genManifest.Dependencies, appctypes.Dependency{App: *parentAppName, Labels: parentLabels})
}
return genManifest, nil
}
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:87,代码来源:common.go
注:本文中的github.com/coreos/rkt/Godeps/_workspace/src/github.com/appc/spec/schema/types.SanitizeACName函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论