本文整理汇总了Golang中github.com/convox/rack/manifest.Service.Ports方法的典型用法代码示例。如果您正苦于以下问题:Golang Service.Ports方法的具体用法?Golang Service.Ports怎么用?Golang Service.Ports使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/convox/rack/manifest.Service
的用法示例。
在下文中一共展示了Service.Ports方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: generateManifest
func generateManifest(dir string, def string) error {
if exists("Procfile") {
pf, err := readProcfile("Procfile")
if err != nil {
return err
}
m := manifest.Manifest{
Services: make(map[string]manifest.Service),
}
for _, e := range pf {
me := manifest.Service{
Build: manifest.Build{
Context: ".",
},
Command: manifest.Command{
String: e.Command,
},
Labels: make(manifest.Labels),
Ports: make(manifest.Ports, 0),
}
switch e.Name {
case "web":
me.Labels["convox.port.443.protocol"] = "tls"
me.Labels["convox.port.443.proxy"] = "true"
me.Ports = append(me.Ports, manifest.Port{
Balancer: 80,
Container: 4000,
Public: true,
})
me.Ports = append(me.Ports, manifest.Port{
Balancer: 443,
Container: 4001,
Public: true,
})
}
m.Services[e.Name] = me
}
data, err := yaml.Marshal(m)
if err != nil {
return err
}
// write the generated docker-compose.yml and return
return writeFile("docker-compose.yml", data, 0644)
}
// write the default if we get here
return writeAsset("docker-compose.yml", def)
}