本文整理汇总了Golang中github.com/convox/rack/api/models.App.Formation方法的典型用法代码示例。如果您正苦于以下问题:Golang App.Formation方法的具体用法?Golang App.Formation怎么用?Golang App.Formation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/convox/rack/api/models.App
的用法示例。
在下文中一共展示了App.Formation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: assertFixture
func assertFixture(t *testing.T, name string) {
orig := manifest.ManifestRandomPorts
manifest.ManifestRandomPorts = false
defer func() { manifest.ManifestRandomPorts = orig }()
app := models.App{
Name: "httpd",
Tags: map[string]string{
"Name": "httpd",
"Type": "app",
"System": "convox",
"Rack": "convox-test",
},
}
data, err := ioutil.ReadFile(fmt.Sprintf("fixtures/%s.yml", name))
require.Nil(t, err)
manifest, err := manifest.Load(data)
require.Nil(t, err)
formation, err := app.Formation(*manifest)
require.Nil(t, err)
pretty, err := models.PrettyJSON(formation)
require.Nil(t, err)
data, err = ioutil.ReadFile(fmt.Sprintf("fixtures/%s.json", name))
require.Nil(t, err)
diff1 := strings.Split(strings.TrimSpace(string(data)), "\n")
diff2 := strings.Split(strings.TrimSpace(pretty), "\n")
diff := difflib.Diff(diff1, diff2)
diffs := []string{}
// bigger than max
prev := 1000000
for l, d := range diff {
switch d.Delta {
case difflib.LeftOnly:
if (l - prev) > 1 {
diffs = append(diffs, "")
}
diffs = append(diffs, fmt.Sprintf("%04d - %s", l, d.Payload))
prev = l
case difflib.RightOnly:
if (l - prev) > 1 {
diffs = append(diffs, "")
}
diffs = append(diffs, fmt.Sprintf("%04d + %s", l, d.Payload))
prev = l
}
}
if len(diffs) > 0 {
t.Errorf("Unexpected results for %s:\n%s", name, strings.Join(diffs, "\n"))
}
}
示例2: main
func main() {
if len(os.Args) < 2 {
die(fmt.Errorf("usage: fixture <docker-compose.yml>"))
}
os.Setenv("REGION", "test")
data, err := ioutil.ReadFile(os.Args[1])
if err != nil {
die(err)
}
app := models.App{
Name: "httpd",
Tags: map[string]string{
"Name": "httpd",
"Type": "app",
"System": "convox",
"Rack": "convox-test",
},
}
m, err := manifest.Load(data)
if err != nil {
die(err)
}
f, err := app.Formation(*m)
if err != nil {
die(err)
}
pretty, err := models.PrettyJSON(f)
if err != nil {
die(err)
}
fmt.Println(pretty)
}