本文整理匯總了Golang中github.com/coreos/fleet/unit.RecognizedUnitType函數的典型用法代碼示例。如果您正苦於以下問題:Golang RecognizedUnitType函數的具體用法?Golang RecognizedUnitType怎麽用?Golang RecognizedUnitType使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了RecognizedUnitType函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: unitNameMangle
// unitNameMangle tries to turn a string that might not be a unit name into a
// sensible unit name.
func unitNameMangle(baseName string) string {
name := path.Base(baseName)
if !unit.RecognizedUnitType(name) {
return unit.DefaultUnitType(name)
}
return name
}
示例2: lsUnitsDir
func lsUnitsDir(dir string) ([]string, error) {
filterFunc := func(name string) bool {
if !unit.RecognizedUnitType(name) {
log.Warningf("Found unrecognized file in %s, ignoring", path.Join(dir, name))
return true
}
return false
}
return pkg.ListDirectory(dir, filterFunc)
}
示例3: Units
// Units enumerates all files recognized as valid systemd units in
// this manager's units directory.
func (m *SystemdUnitManager) Units() (units []string, err error) {
fis, err := ioutil.ReadDir(m.UnitsDir)
if err != nil {
return
}
for _, fi := range fis {
name := fi.Name()
if !unit.RecognizedUnitType(name) {
log.Warningf("Found unrecognized file in %s, ignoring", path.Join(m.UnitsDir, name))
continue
}
units = append(units, name)
}
return
}
示例4: maybeAppendDefaultUnitType
func maybeAppendDefaultUnitType(arg string) string {
if !unit.RecognizedUnitType(arg) {
arg = unit.DefaultUnitType(arg)
}
return arg
}