本文整理匯總了Golang中github.com/coreos/fleet/schema.Unit.Options方法的典型用法代碼示例。如果您正苦於以下問題:Golang Unit.Options方法的具體用法?Golang Unit.Options怎麽用?Golang Unit.Options使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/coreos/fleet/schema.Unit
的用法示例。
在下文中一共展示了Unit.Options方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: MakeUnitChain
// MakeUnitChain creates the unit files of the benchmark units.
func (b *Builder) MakeUnitChain(id string) []schema.Unit {
unitsList := []schema.Unit{}
// 3 dependsOn 2; 2 dependsOn 1; 1 dependsOn 0
// 0 after 1; 1 after 2 ; 2 after 3
for i := b.instanceGroupSize - 1; i >= 0; i-- {
name := fmt.Sprintf("%s-%[email protected]%s.service", b.unitPrefix, i, id)
unit := schema.Unit{
Name: name,
}
if b.app.Type == "unitfiles" && b.unitFile != nil {
unit.Options = b.buildCustomService()
} else if b.app.Type == "docker" {
unit.Options = b.buildDockerService()
} else if b.app.Type == "rkt" {
unit.Options = b.buildRktService()
} else {
unit.Options = b.buildShellService()
}
if i > 0 {
depName := fmt.Sprintf("%s-%[email protected]%s.service", b.unitPrefix, i-1, id)
unit.Options = append(unit.Options,
&schema.UnitOption{
Section: "X-Fleet",
Name: "MachineOf",
Value: depName,
},
)
}
unitsList = append(unitsList, unit)
}
if len(unitsList) > 1 {
for i := 0; i < (len(unitsList) - 1); i++ {
depName := unitsList[i+1].Name
unitsList[i].Options = append(unitsList[i].Options,
&schema.UnitOption{
Section: "Unit",
Name: "Before",
Value: depName,
},
&schema.UnitOption{
Section: "Unit",
Name: "BindTo",
Value: depName,
},
)
}
}
return unitsList
}