本文整理汇总了Golang中github.com/aelsabbahy/goss/system.System.NewUser方法的典型用法代码示例。如果您正苦于以下问题:Golang System.NewUser方法的具体用法?Golang System.NewUser怎么用?Golang System.NewUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/aelsabbahy/goss/system.System
的用法示例。
在下文中一共展示了System.NewUser方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: AppendSysResource
func (r UserMap) AppendSysResource(sr string, sys *system.System, config util.Config) (*User, error) {
sysres := sys.NewUser(sr, sys, config)
res, err := NewUser(sysres, config)
if err != nil {
return nil, err
}
r[res.ID()] = res
return res, nil
}
示例2: AppendSysResourceIfExists
func (r UserMap) AppendSysResourceIfExists(sr string, sys *system.System) (*User, system.User, bool) {
sysres := sys.NewUser(sr, sys)
res := NewUser(sysres)
if e, _ := sysres.Exists(); e != true {
return res, sysres, false
}
r[res.ID()] = res
return res, sysres, true
}
示例3: AppendSysResourceIfExists
func (r UserMap) AppendSysResourceIfExists(sr string, sys *system.System) (*User, system.User, bool) {
sysres := sys.NewUser(sr, sys, util.Config{})
// FIXME: Do we want to be silent about errors?
res, _ := NewUser(sysres, util.Config{})
if e, _ := sysres.Exists(); e != true {
return res, sysres, false
}
r[res.ID()] = res
return res, sysres, true
}
示例4: AppendSysResource
func (r UserMap) AppendSysResource(sr string, sys *system.System, config util.Config) (*User, error) {
sysres := sys.NewUser(sr, sys, config)
res, err := NewUser(sysres, config)
if err != nil {
return nil, err
}
if old_res, ok := r[res.ID()]; ok {
res.Title = old_res.Title
res.Meta = old_res.Meta
}
r[res.ID()] = res
return res, nil
}
示例5: Validate
func (s *User) Validate(sys *system.System) []TestResult {
sysuser := sys.NewUser(s.Username, sys)
var results []TestResult
results = append(results, ValidateValue(s.Username, "exists", s.Exists, sysuser.Exists))
if !s.Exists {
return results
}
results = append(results, ValidateValue(s.Username, "uid", s.UID, sysuser.UID))
results = append(results, ValidateValue(s.Username, "gid", s.Gid, sysuser.Gid))
results = append(results, ValidateValue(s.Username, "home", s.Home, sysuser.Home))
results = append(results, ValidateValues(s.Username, "groups", s.Groups, sysuser.Groups))
return results
}
示例6: Validate
func (u *User) Validate(sys *system.System) []TestResult {
sysuser := sys.NewUser(u.Username, sys, util.Config{})
var results []TestResult
results = append(results, ValidateValue(u, "exists", u.Exists, sysuser.Exists))
if u.UID != "" {
results = append(results, ValidateValue(u, "uid", u.UID, sysuser.UID))
}
if u.GID != "" {
results = append(results, ValidateValue(u, "gid", u.GID, sysuser.GID))
}
if u.Home != "" {
results = append(results, ValidateValue(u, "home", u.Home, sysuser.Home))
}
if len(u.Groups) > 0 {
results = append(results, ValidateValues(u, "groups", u.Groups, sysuser.Groups))
}
return results
}
示例7: AppendSysResource
func (r UserMap) AppendSysResource(sr string, sys *system.System) (*User, system.User) {
sysres := sys.NewUser(sr, sys)
res := NewUser(sysres)
r[res.ID()] = res
return res, sysres
}