本文整理汇总了Golang中github.com/openshift/source-to-image/pkg/util/user.IsUserAllowed函数的典型用法代码示例。如果您正苦于以下问题:Golang IsUserAllowed函数的具体用法?Golang IsUserAllowed怎么用?Golang IsUserAllowed使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IsUserAllowed函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: isOnbuildAllowed
// isOnbuildAllowed checks a list of Docker ONBUILD instructions for
// user directives. It ensures that any users specified by the directives
// falls within the specified range list of users.
func isOnbuildAllowed(directives []string, allowed *user.RangeList) bool {
for _, line := range directives {
parts := dockerLineDelim.Split(line, 2)
if strings.ToLower(parts[0]) != "user" {
continue
}
uname := extractUser(parts[1])
if !user.IsUserAllowed(uname, allowed) {
return false
}
}
return true
}
示例2: checkAllowedUser
func checkAllowedUser(d docker.Docker, config *api.Config, isOnbuild bool) error {
if config.AllowedUIDs == nil || config.AllowedUIDs.Empty() {
return nil
}
user, err := d.GetImageUser(config.BuilderImage)
if err != nil {
return err
}
if !userutil.IsUserAllowed(user, &config.AllowedUIDs) {
return errors.NewBuilderUserNotAllowedError(config.BuilderImage, false)
}
if isOnbuild {
cmds, err := d.GetOnBuild(config.BuilderImage)
if err != nil {
return err
}
if !userutil.IsOnbuildAllowed(cmds, &config.AllowedUIDs) {
return errors.NewBuilderUserNotAllowedError(config.BuilderImage, true)
}
}
return nil
}
示例3: CheckAllowedUser
// CheckAllowedUser checks if the Docker image contains allowed users
// FIXME: @cswong this need better godoc
func CheckAllowedUser(d Docker, imageName string, uids user.RangeList, isOnbuild bool) error {
if uids == nil || uids.Empty() {
return nil
}
imageUser, err := d.GetImageUser(imageName)
if err != nil {
return err
}
if !user.IsUserAllowed(imageUser, &uids) {
return errors.NewBuilderUserNotAllowedError(imageName, false)
}
if isOnbuild {
cmds, err := d.GetOnBuild(imageName)
if err != nil {
return err
}
if !user.IsOnbuildAllowed(cmds, &uids) {
return errors.NewBuilderUserNotAllowedError(imageName, true)
}
}
return nil
}