本文整理匯總了Golang中github.com/coreos/fleet/job.Unit.IsGlobal方法的典型用法代碼示例。如果您正苦於以下問題:Golang Unit.IsGlobal方法的具體用法?Golang Unit.IsGlobal怎麽用?Golang Unit.IsGlobal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/coreos/fleet/job.Unit
的用法示例。
在下文中一共展示了Unit.IsGlobal方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: UnitsCheck
func UnitsCheck() check.ExtensionCheckResult {
cl, err := NewFleetClient()
if err != nil {
return handler.Error(err.Error())
}
units, err := cl.Units()
if err != nil {
return handler.Error(err.Error())
}
wrongStates := []string{}
for _, u := range units {
if u.DesiredState != u.CurrentState || u.DesiredState == "inactive" {
ju := job.Unit{Unit: *schema.MapSchemaUnitOptionsToUnitFile(u.Options)}
if !ju.IsGlobal() {
wrongStates = append(wrongStates, u.Name)
}
}
}
if len(wrongStates) == 0 {
return handler.Ok("Every untis are in their desired states")
} else {
return handler.Error(
fmt.Sprintf(
"Units in an incoherent state: %s",
strings.Join(wrongStates, ","),
),
)
}
}
示例2: suToGlobal
// suToGlobal returns whether or not a schema.Unit refers to a global unit
func suToGlobal(su schema.Unit) bool {
u := job.Unit{
Unit: *schema.MapSchemaUnitOptionsToUnitFile(su.Options),
}
return u.IsGlobal()
}