本文整理匯總了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
}